@mastra/mcp-docs-server 0.13.44 → 0.13.45

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 (98) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fchangeset-cli.md +2 -0
  2. package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +2 -0
  3. package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +201 -1
  4. package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
  5. package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +201 -1
  6. package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +251 -51
  7. package/.docs/organized/changelogs/%40mastra%2Fastra.md +201 -1
  8. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +201 -1
  9. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +201 -1
  10. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +201 -1
  11. package/.docs/organized/changelogs/%40mastra%2Fcloud.md +201 -1
  12. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +201 -1
  13. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +201 -1
  14. package/.docs/organized/changelogs/%40mastra%2Fcore.md +422 -222
  15. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +201 -1
  16. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +201 -1
  17. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +201 -1
  18. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +201 -1
  19. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +201 -1
  20. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +201 -1
  21. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +201 -1
  22. package/.docs/organized/changelogs/%40mastra%2Fevals.md +201 -1
  23. package/.docs/organized/changelogs/%40mastra%2Flance.md +201 -1
  24. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +201 -1
  25. package/.docs/organized/changelogs/%40mastra%2Floggers.md +201 -1
  26. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +201 -1
  27. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +201 -1
  28. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +201 -1
  29. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +201 -1
  30. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +201 -1
  31. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +201 -1
  32. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +201 -1
  33. package/.docs/organized/changelogs/%40mastra%2Fpg.md +201 -1
  34. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +201 -1
  35. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +201 -1
  36. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +201 -1
  37. package/.docs/organized/changelogs/%40mastra%2Frag.md +201 -1
  38. package/.docs/organized/changelogs/%40mastra%2Freact.md +201 -1
  39. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +72 -0
  40. package/.docs/organized/changelogs/%40mastra%2Fserver.md +201 -1
  41. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +201 -1
  42. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +201 -1
  43. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +201 -1
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +201 -1
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +201 -1
  46. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +201 -1
  47. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +201 -1
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +104 -1
  49. package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +49 -1
  50. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +201 -1
  51. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +201 -1
  52. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +201 -1
  53. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +201 -1
  54. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +201 -1
  55. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +201 -1
  56. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +201 -1
  57. package/.docs/organized/changelogs/create-mastra.md +201 -1
  58. package/.docs/organized/changelogs/mastra.md +201 -1
  59. package/.docs/raw/agents/adding-voice.mdx +49 -0
  60. package/.docs/raw/course/01-first-agent/05-running-playground.md +5 -5
  61. package/.docs/raw/course/01-first-agent/09-testing-your-agent.md +3 -3
  62. package/.docs/raw/course/01-first-agent/13-testing-your-tool.md +3 -3
  63. package/.docs/raw/course/01-first-agent/17-testing-memory.md +2 -2
  64. package/.docs/raw/course/04-workflows/07-using-playground.md +1 -1
  65. package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +23 -1
  66. package/.docs/raw/reference/client-js/memory.mdx +43 -0
  67. package/.docs/raw/reference/core/mastra-class.mdx +8 -0
  68. package/.docs/raw/reference/core/mastra-model-gateway.mdx +223 -0
  69. package/.docs/raw/reference/scorers/answer-relevancy.mdx +28 -98
  70. package/.docs/raw/reference/scorers/answer-similarity.mdx +12 -258
  71. package/.docs/raw/reference/scorers/bias.mdx +29 -87
  72. package/.docs/raw/reference/scorers/completeness.mdx +32 -91
  73. package/.docs/raw/reference/scorers/content-similarity.mdx +29 -99
  74. package/.docs/raw/reference/scorers/context-precision.mdx +28 -130
  75. package/.docs/raw/reference/scorers/faithfulness.mdx +28 -101
  76. package/.docs/raw/reference/scorers/hallucination.mdx +28 -103
  77. package/.docs/raw/reference/scorers/keyword-coverage.mdx +28 -107
  78. package/.docs/raw/reference/scorers/textual-difference.mdx +27 -100
  79. package/.docs/raw/reference/scorers/tone-consistency.mdx +25 -98
  80. package/.docs/raw/reference/scorers/toxicity.mdx +29 -92
  81. package/.docs/raw/reference/storage/cloudflare-d1.mdx +37 -0
  82. package/.docs/raw/reference/storage/lance.mdx +33 -0
  83. package/.docs/raw/reference/storage/libsql.mdx +37 -0
  84. package/.docs/raw/reference/storage/mongodb.mdx +39 -0
  85. package/.docs/raw/reference/storage/mssql.mdx +37 -0
  86. package/.docs/raw/reference/storage/postgresql.mdx +37 -0
  87. package/.docs/raw/reference/streaming/agents/stream.mdx +7 -0
  88. package/.docs/raw/reference/voice/composite-voice.mdx +71 -28
  89. package/.docs/raw/reference/voice/voice.listen.mdx +86 -52
  90. package/.docs/raw/reference/voice/voice.speak.mdx +75 -40
  91. package/.docs/raw/voice/overview.mdx +67 -0
  92. package/.docs/raw/workflows/control-flow.mdx +180 -0
  93. package/CHANGELOG.md +20 -0
  94. package/dist/{chunk-TUAHUTTB.js → chunk-VE65X75W.js} +24 -4
  95. package/dist/prepare-docs/package-changes.d.ts.map +1 -1
  96. package/dist/prepare-docs/prepare.js +1 -1
  97. package/dist/stdio.js +1 -1
  98. package/package.json +5 -5
@@ -94,116 +94,43 @@ Object with tone metrics:
94
94
  - **avgSentiment**: Average sentiment across sentences (stability mode).
95
95
  - **sentimentVariance**: Variance of sentiment across sentences (stability mode).
96
96
 
97
- ## Examples
97
+ ## Example
98
98
 
99
- ### Positive tone example
99
+ Evaluate tone consistency between related agent responses:
100
100
 
101
- In this example, the texts exhibit a similar positive sentiment. The scorer measures the consistency between the tones, resulting in a high score.
102
-
103
- ```typescript title="src/example-positive-tone.ts" showLineNumbers copy
104
- import { createToneScorer } from "@mastra/evals/scorers/code";
105
-
106
- const scorer = createToneScorer();
107
-
108
- const input = "This product is fantastic and amazing!";
109
- const output = "The product is excellent and wonderful!";
110
-
111
- const result = await scorer.run({
112
- input: [{ role: "user", content: input }],
113
- output: { role: "assistant", text: output },
114
- });
115
-
116
- console.log("Score:", result.score);
117
- console.log("AnalyzeStepResult:", result.analyzeStepResult);
118
- ```
119
-
120
- #### Positive tone output
121
-
122
- The scorer returns a high score reflecting strong sentiment alignment. The `analyzeStepResult` field provides sentiment values and the difference between them.
123
-
124
- ```typescript
125
- {
126
- score: 0.8333333333333335,
127
- analyzeStepResult: {
128
- responseSentiment: 1.3333333333333333,
129
- referenceSentiment: 1.1666666666666667,
130
- difference: 0.16666666666666652,
131
- },
132
- }
133
- ```
134
-
135
- ### Stable tone example
136
-
137
- In this example, the text’s internal tone consistency is analyzed by passing an empty response. This signals the scorer to evaluate sentiment stability within the single input text, resulting in a score reflecting how uniform the tone is throughout.
138
-
139
- ```typescript title="src/example-stable-tone.ts" showLineNumbers copy
101
+ ```typescript title="src/example-tone-consistency.ts" showLineNumbers copy
102
+ import { runExperiment } from "@mastra/core/scores";
140
103
  import { createToneScorer } from "@mastra/evals/scorers/code";
104
+ import { myAgent } from "./agent";
141
105
 
142
106
  const scorer = createToneScorer();
143
107
 
144
- const input = "Great service! Friendly staff. Perfect atmosphere.";
145
- const output = "";
146
-
147
- const result = await scorer.run({
148
- input: [{ role: "user", content: input }],
149
- output: { role: "assistant", text: output },
150
- });
151
-
152
- console.log("Score:", result.score);
153
- console.log("AnalyzeStepResult:", result.analyzeStepResult);
154
- ```
155
-
156
- #### Stable tone output
157
-
158
- The scorer returns a high score indicating consistent sentiment throughout the input text. The `analyzeStepResult` field includes the average sentiment and sentiment variance, reflecting tone stability.
159
-
160
- ```typescript
161
- {
162
- score: 0.9444444444444444,
163
- analyzeStepResult: {
164
- avgSentiment: 1.3333333333333333,
165
- sentimentVariance: 0.05555555555555556,
108
+ const result = await runExperiment({
109
+ data: [
110
+ {
111
+ input: "How was your experience with our service?",
112
+ groundTruth: "The service was excellent and exceeded expectations!",
113
+ },
114
+ {
115
+ input: "Tell me about the customer support",
116
+ groundTruth: "The support team was friendly and very helpful.",
117
+ },
118
+ ],
119
+ scorers: [scorer],
120
+ target: myAgent,
121
+ onItemComplete: ({ scorerResults }) => {
122
+ console.log({
123
+ score: scorerResults[scorer.name].score,
124
+ });
166
125
  },
167
- }
168
- ```
169
-
170
- ### Mixed tone example
171
-
172
- In this example, the input and response have different emotional tones. The scorer picks up on these variations and gives a lower consistency score.
173
-
174
- ```typescript title="src/example-mixed-tone.ts" showLineNumbers copy
175
- import { createToneScorer } from "@mastra/evals/scorers/code";
176
-
177
- const scorer = createToneScorer();
178
-
179
- const input =
180
- "The interface is frustrating and confusing, though it has potential.";
181
- const output =
182
- "The design shows promise but needs significant improvements to be usable.";
183
-
184
- const result = await scorer.run({
185
- input: [{ role: "user", content: input }],
186
- output: { role: "assistant", text: output },
187
126
  });
188
127
 
189
- console.log("Score:", result.score);
190
- console.log("AnalyzeStepResult:", result.analyzeStepResult);
128
+ console.log(result.scores);
191
129
  ```
192
130
 
193
- #### Mixed tone output
194
-
195
- The scorer returns a low score due to the noticeable differences in emotional tone. The `analyzeStepResult` field highlights the sentiment values and the degree of variation between them.
131
+ For more details on `runExperiment`, see the [runExperiment reference](/reference/scorers/run-experiment).
196
132
 
197
- ```typescript
198
- {
199
- score: 0.4181818181818182,
200
- analyzeStepResult: {
201
- responseSentiment: -0.4,
202
- referenceSentiment: 0.18181818181818182,
203
- difference: 0.5818181818181818,
204
- },
205
- }
206
- ```
133
+ To add this scorer to an agent, see the [Scorers overview](/docs/scorers/overview#adding-scorers-to-agents) guide.
207
134
 
208
135
  ## Related
209
136
 
@@ -119,108 +119,45 @@ A toxicity score between 0 and 1:
119
119
  - **0.1–0.3**: Mild toxicity.
120
120
  - **0.0**: No toxic elements detected.
121
121
 
122
- ## Examples
122
+ ## Example
123
123
 
124
- ### High toxicity example
124
+ Evaluate agent responses for toxic, biased, or harmful content:
125
125
 
126
- In this example, the response contains explicit personal attacks and harmful language, resulting in a high toxicity score.
127
-
128
- ```typescript title="src/example-high-toxicity.ts" showLineNumbers copy
129
- import { createToxicityScorer } from "@mastra/evals/scorers/llm";
130
-
131
- const scorer = createToxicityScorer({ model: "openai/gpt-4o-mini" });
132
-
133
- const query = "What do you think about the new team member?";
134
- const response =
135
- "That incompetent fool is a complete waste of space. They clearly bought their degree and have no business being here. Everyone hates working with them.";
136
-
137
- const result = await scorer.run({
138
- input: [{ role: "user", content: query }],
139
- output: { role: "assistant", text: response },
140
- });
141
-
142
- console.log("Score:", result.score);
143
- console.log("Reason:", result.reason);
144
- ```
145
-
146
- #### High toxicity output
147
-
148
- The scorer returns a high score indicating severe toxic content. The `reason` field details the presence of personal attacks, derogatory language, and harmful generalizations.
149
-
150
- ```typescript
151
- {
152
- score: 1,
153
- reason: "The score is 1 because the output contains personal attacks such as 'incompetent fool' and 'complete waste of space', along with derogatory assumptions about the new team member's qualifications, stating they 'clearly bought their degree'. Additionally, it generalizes the feelings of others negatively by claiming 'Everyone hates working with them', which contributes to a toxic environment."
154
- }
155
- ```
156
-
157
- ### Mixed toxicity example
158
-
159
- In this example, the response combines toxic and professional elements. The scorer identifies the problematic language while acknowledging the constructive feedback, resulting in a moderate toxicity score.
160
-
161
- ```typescript title="src/example-mixed-toxicity.ts" showLineNumbers copy
162
- import { createToxicityScorer } from "@mastra/evals/scorers/llm";
163
-
164
- const scorer = createToxicityScorer({ model: "openai/gpt-4o-mini" });
165
-
166
- const query = "How was the meeting discussion?";
167
- const response = [
168
- "Half the meeting was just listening to the marketing team ramble on with their usual clueless suggestions.",
169
- "At least the engineering team's presentation was focused and had some solid technical solutions we can actually use.",
170
- ];
171
-
172
- const result = await scorer.run({
173
- input: [{ role: "user", content: query }],
174
- output: { role: "assistant", text: response },
175
- });
176
-
177
- console.log("Score:", result.score);
178
- console.log("Reason:", result.reason);
179
- ```
180
-
181
- #### Mixed toxicity output
182
-
183
- The scorer returns a moderate score reflecting a combination of dismissive language and professional feedback. The `reason` field explains the presence of both toxic and constructive elements in the response.
184
-
185
- ```typescript
186
- {
187
- score: 0.5,
188
- reason: "The score is 0.5 because the output contains some dismissive language towards the marketing team but maintains professional and constructive comments about the engineering team."
189
- }
190
- ```
191
-
192
- ### No toxicity example
193
-
194
- In this example, the response is professional and constructive, with no toxic or harmful language detected.
195
-
196
- ```typescript title="src/example-no-toxicity.ts" showLineNumbers copy
126
+ ```typescript title="src/example-toxicity.ts" showLineNumbers copy
127
+ import { runExperiment } from "@mastra/core/scores";
197
128
  import { createToxicityScorer } from "@mastra/evals/scorers/llm";
129
+ import { myAgent } from "./agent";
198
130
 
199
- const scorer = createToxicityScorer({ model: "openai/gpt-4o-mini" });
200
-
201
- const query = "Can you provide feedback on the project proposal?";
202
- const response =
203
- "The proposal has strong points in its technical approach but could benefit from more detailed market analysis. I suggest we collaborate with the research team to strengthen these sections.";
131
+ const scorer = createToxicityScorer({ model: "openai/gpt-4o" });
204
132
 
205
- const result = await scorer.run({
206
- input: [{ role: "user", content: query }],
207
- output: { role: "assistant", text: response },
133
+ const result = await runExperiment({
134
+ data: [
135
+ {
136
+ input: "What do you think about the new team member?",
137
+ },
138
+ {
139
+ input: "How was the meeting discussion?",
140
+ },
141
+ {
142
+ input: "Can you provide feedback on the project proposal?",
143
+ },
144
+ ],
145
+ scorers: [scorer],
146
+ target: myAgent,
147
+ onItemComplete: ({ scorerResults }) => {
148
+ console.log({
149
+ score: scorerResults[scorer.name].score,
150
+ reason: scorerResults[scorer.name].reason,
151
+ });
152
+ },
208
153
  });
209
154
 
210
- console.log("Score:", result.score);
211
- console.log("Reason:", result.reason);
155
+ console.log(result.scores);
212
156
  ```
213
157
 
214
- #### No toxicity output
215
-
216
- The scorer returns a low score indicating the response is free from toxic content. The `reason` field confirms the professional and respectful nature of the feedback.
158
+ For more details on `runExperiment`, see the [runExperiment reference](/reference/scorers/run-experiment).
217
159
 
218
- ```typescript
219
- {
220
- score: 0,
221
- reason: 'The score is 0 because the output provides constructive feedback on the project proposal, highlighting both strengths and areas for improvement. It uses respectful language and encourages collaboration, making it a non-toxic contribution.'
222
- }
223
- ```
160
+ To add this scorer to an agent, see the [Scorers overview](/docs/scorers/overview#adding-scorers-to-agents) guide.
224
161
 
225
162
  ## Related
226
163
 
@@ -95,6 +95,43 @@ The storage implementation handles schema creation and updates automatically. It
95
95
  - `messages`: Stores individual messages
96
96
  - `metadata`: Stores additional metadata for threads and messages
97
97
 
98
+ ### Initialization
99
+
100
+ When you pass storage to the Mastra class, `init()` is called automatically before any storage operation:
101
+
102
+ ```typescript copy
103
+ import { Mastra } from "@mastra/core";
104
+ import { D1Store } from "@mastra/cloudflare-d1";
105
+
106
+ const storage = new D1Store({
107
+ binding: D1Database,
108
+ });
109
+
110
+ const mastra = new Mastra({
111
+ storage, // init() is called automatically
112
+ });
113
+ ```
114
+
115
+ If you're using storage directly without Mastra, you must call `init()` explicitly to create the tables:
116
+
117
+ ```typescript copy
118
+ import { D1Store } from "@mastra/cloudflare-d1";
119
+
120
+ const storage = new D1Store({
121
+ binding: D1Database,
122
+ });
123
+
124
+ // Required when using storage directly
125
+ await storage.init();
126
+
127
+ // Now you can use the storage
128
+ await storage.getThread({ threadId: "..." });
129
+ ```
130
+
131
+ :::warning
132
+ If `init()` is not called, tables won't be created and storage operations will fail silently or throw errors.
133
+ :::
134
+
98
135
  ### Transactions & Consistency
99
136
 
100
137
  Cloudflare D1 provides transactional guarantees for single-row operations. This means that multiple operations can be executed as a single, all-or-nothing unit of work.
@@ -73,6 +73,39 @@ The LanceStorage implementation automatically handles schema creation and update
73
73
  - `jsonb`, `json` → Utf8 (serialized)
74
74
  - `binary` → Binary
75
75
 
76
+ ### Initialization
77
+
78
+ When you pass storage to the Mastra class, `init()` is called automatically before any storage operation:
79
+
80
+ ```typescript copy
81
+ import { Mastra } from "@mastra/core";
82
+ import { LanceStorage } from "@mastra/lance";
83
+
84
+ const storage = await LanceStorage.create("my-storage", "/path/to/db");
85
+
86
+ const mastra = new Mastra({
87
+ storage, // init() is called automatically
88
+ });
89
+ ```
90
+
91
+ If you're using storage directly without Mastra, you must call `init()` explicitly to create the tables:
92
+
93
+ ```typescript copy
94
+ import { LanceStorage } from "@mastra/lance";
95
+
96
+ const storage = await LanceStorage.create("my-storage", "/path/to/db");
97
+
98
+ // Required when using storage directly
99
+ await storage.init();
100
+
101
+ // Now you can use the storage
102
+ await storage.getThread({ threadId: "..." });
103
+ ```
104
+
105
+ :::warning
106
+ If `init()` is not called, tables won't be created and storage operations will fail silently or throw errors.
107
+ :::
108
+
76
109
  ### Deployment Options
77
110
 
78
111
  LanceDB storage can be configured for different deployment scenarios:
@@ -72,3 +72,40 @@ The storage implementation handles schema creation and updates automatically. It
72
72
  - `mastra_traces`: Stores telemetry and tracing data
73
73
  - `mastra_scorers`: Stores scoring and evaluation data
74
74
  - `mastra_resources`: Stores resource working memory data
75
+
76
+ ### Initialization
77
+
78
+ When you pass storage to the Mastra class, `init()` is called automatically before any storage operation:
79
+
80
+ ```typescript copy
81
+ import { Mastra } from "@mastra/core";
82
+ import { LibSQLStore } from "@mastra/libsql";
83
+
84
+ const storage = new LibSQLStore({
85
+ url: "file:./storage.db",
86
+ });
87
+
88
+ const mastra = new Mastra({
89
+ storage, // init() is called automatically
90
+ });
91
+ ```
92
+
93
+ If you're using storage directly without Mastra, you must call `init()` explicitly to create the tables:
94
+
95
+ ```typescript copy
96
+ import { LibSQLStore } from "@mastra/libsql";
97
+
98
+ const storage = new LibSQLStore({
99
+ url: "file:./storage.db",
100
+ });
101
+
102
+ // Required when using storage directly
103
+ await storage.init();
104
+
105
+ // Now you can use the storage
106
+ await storage.getThread({ threadId: "..." });
107
+ ```
108
+
109
+ :::warning
110
+ If `init()` is not called, tables won't be created and storage operations will fail silently or throw errors.
111
+ :::
@@ -93,6 +93,45 @@ The storage implementation handles collection creation and management automatica
93
93
  - `mastra_scorers`: Stores scoring and evaluation data
94
94
  - `mastra_resources`: Stores resource working memory data
95
95
 
96
+ ### Initialization
97
+
98
+ When you pass storage to the Mastra class, `init()` is called automatically before any storage operation:
99
+
100
+ ```typescript copy
101
+ import { Mastra } from "@mastra/core";
102
+ import { MongoDBStore } from "@mastra/mongodb";
103
+
104
+ const storage = new MongoDBStore({
105
+ url: process.env.MONGODB_URL,
106
+ dbName: process.env.MONGODB_DATABASE,
107
+ });
108
+
109
+ const mastra = new Mastra({
110
+ storage, // init() is called automatically
111
+ });
112
+ ```
113
+
114
+ If you're using storage directly without Mastra, you must call `init()` explicitly to create the collections:
115
+
116
+ ```typescript copy
117
+ import { MongoDBStore } from "@mastra/mongodb";
118
+
119
+ const storage = new MongoDBStore({
120
+ url: process.env.MONGODB_URL,
121
+ dbName: process.env.MONGODB_DATABASE,
122
+ });
123
+
124
+ // Required when using storage directly
125
+ await storage.init();
126
+
127
+ // Now you can use the storage
128
+ await storage.getThread({ threadId: "..." });
129
+ ```
130
+
131
+ :::warning
132
+ If `init()` is not called, collections won't be created and storage operations will fail silently or throw errors.
133
+ :::
134
+
96
135
  ## Vector Search Capabilities
97
136
 
98
137
  MongoDB storage includes built-in vector search capabilities for AI applications:
@@ -96,6 +96,43 @@ The storage implementation handles schema creation and updates automatically. It
96
96
  - `mastra_scorers`: Stores scoring and evaluation data
97
97
  - `mastra_resources`: Stores resource working memory data
98
98
 
99
+ ### Initialization
100
+
101
+ When you pass storage to the Mastra class, `init()` is called automatically before any storage operation:
102
+
103
+ ```typescript copy
104
+ import { Mastra } from "@mastra/core";
105
+ import { MSSQLStore } from "@mastra/mssql";
106
+
107
+ const storage = new MSSQLStore({
108
+ connectionString: process.env.DATABASE_URL,
109
+ });
110
+
111
+ const mastra = new Mastra({
112
+ storage, // init() is called automatically
113
+ });
114
+ ```
115
+
116
+ If you're using storage directly without Mastra, you must call `init()` explicitly to create the tables:
117
+
118
+ ```typescript copy
119
+ import { MSSQLStore } from "@mastra/mssql";
120
+
121
+ const storage = new MSSQLStore({
122
+ connectionString: process.env.DATABASE_URL,
123
+ });
124
+
125
+ // Required when using storage directly
126
+ await storage.init();
127
+
128
+ // Now you can use the storage
129
+ await storage.getThread({ threadId: "..." });
130
+ ```
131
+
132
+ :::warning
133
+ If `init()` is not called, tables won't be created and storage operations will fail silently or throw errors.
134
+ :::
135
+
99
136
  ### Direct Database and Pool Access
100
137
 
101
138
  `MSSQLStore` exposes the mssql connection pool as public fields:
@@ -96,6 +96,43 @@ The storage implementation handles schema creation and updates automatically. It
96
96
  - `mastra_scorers`: Stores scoring and evaluation data
97
97
  - `mastra_resources`: Stores resource working memory data
98
98
 
99
+ ### Initialization
100
+
101
+ When you pass storage to the Mastra class, `init()` is called automatically before any storage operation:
102
+
103
+ ```typescript copy
104
+ import { Mastra } from "@mastra/core";
105
+ import { PostgresStore } from "@mastra/pg";
106
+
107
+ const storage = new PostgresStore({
108
+ connectionString: process.env.DATABASE_URL,
109
+ });
110
+
111
+ const mastra = new Mastra({
112
+ storage, // init() is called automatically
113
+ });
114
+ ```
115
+
116
+ If you're using storage directly without Mastra, you must call `init()` explicitly to create the tables:
117
+
118
+ ```typescript copy
119
+ import { PostgresStore } from "@mastra/pg";
120
+
121
+ const storage = new PostgresStore({
122
+ connectionString: process.env.DATABASE_URL,
123
+ });
124
+
125
+ // Required when using storage directly
126
+ await storage.init();
127
+
128
+ // Now you can use the storage
129
+ await storage.getThread({ threadId: "..." });
130
+ ```
131
+
132
+ :::warning
133
+ If `init()` is not called, tables won't be created and storage operations will fail silently or throw errors.
134
+ :::
135
+
99
136
  ### Direct Database and Pool Access
100
137
 
101
138
  `PostgresStore` exposes both the underlying database object and the pg-promise instance as public fields:
@@ -254,6 +254,13 @@ const aiSdkStream = await agent.stream("message for agent", {
254
254
  description:
255
255
  "Overrides the output processors set on the agent. Output processors that can modify or validate messages from the agent before they are returned to the user. Must implement either (or both) of the `processOutputResult` and `processOutputStream` functions.",
256
256
  },
257
+ {
258
+ name: "includeRawChunks",
259
+ type: "boolean",
260
+ isOptional: true,
261
+ description:
262
+ "Whether to include raw chunks in the stream output (not available on all model providers).",
263
+ },
257
264
  {
258
265
  name: "inputProcessors",
259
266
  type: "Processor[]",
@@ -7,31 +7,7 @@ description: "Documentation for the CompositeVoice class, which enables combinin
7
7
 
8
8
  The CompositeVoice class allows you to combine different voice providers for text-to-speech and speech-to-text operations. This is particularly useful when you want to use the best provider for each operation - for example, using OpenAI for speech-to-text and PlayAI for text-to-speech.
9
9
 
10
- CompositeVoice is used internally by the Agent class to provide flexible voice capabilities.
11
-
12
- ## Usage Example
13
-
14
- ```typescript
15
- import { CompositeVoice } from "@mastra/core/voice";
16
- import { OpenAIVoice } from "@mastra/voice-openai";
17
- import { PlayAIVoice } from "@mastra/voice-playai";
18
-
19
- // Create voice providers
20
- const openai = new OpenAIVoice();
21
- const playai = new PlayAIVoice();
22
-
23
- // Use OpenAI for listening (speech-to-text) and PlayAI for speaking (text-to-speech)
24
- const voice = new CompositeVoice({
25
- input: openai,
26
- output: playai,
27
- });
28
-
29
- // Convert speech to text using OpenAI
30
- const text = await voice.listen(audioStream);
31
-
32
- // Convert text to speech using PlayAI
33
- const audio = await voice.speak("Hello, world!");
34
- ```
10
+ CompositeVoice supports both Mastra voice providers and AI SDK model providers
35
11
 
36
12
  ## Constructor Parameters
37
13
 
@@ -45,14 +21,20 @@ const audio = await voice.speak("Hello, world!");
45
21
  },
46
22
  {
47
23
  name: "config.input",
48
- type: "MastraVoice",
49
- description: "Voice provider to use for speech-to-text operations",
24
+ type: "MastraVoice | TranscriptionModel",
25
+ description: "Voice provider or AI SDK transcription model to use for speech-to-text operations. AI SDK models are automatically wrapped.",
50
26
  isOptional: true,
51
27
  },
52
28
  {
53
29
  name: "config.output",
30
+ type: "MastraVoice | SpeechModel",
31
+ description: "Voice provider or AI SDK speech model to use for text-to-speech operations. AI SDK models are automatically wrapped.",
32
+ isOptional: true,
33
+ },
34
+ {
35
+ name: "config.realtime",
54
36
  type: "MastraVoice",
55
- description: "Voice provider to use for text-to-speech operations",
37
+ description: "Voice provider to use for real-time speech-to-speech operations",
56
38
  isOptional: true,
57
39
  },
58
40
  ]}
@@ -142,3 +124,64 @@ Notes:
142
124
  - If no speaking provider is configured, returns an empty array
143
125
  - Each voice object will have at least a voiceId property
144
126
  - Additional voice properties depend on the speaking provider
127
+
128
+ ## Usage Examples
129
+
130
+ ### Using Mastra Voice Providers
131
+
132
+ ```typescript
133
+ import { CompositeVoice } from "@mastra/core/voice";
134
+ import { OpenAIVoice } from "@mastra/voice-openai";
135
+ import { PlayAIVoice } from "@mastra/voice-playai";
136
+
137
+ // Create voice providers
138
+ const openai = new OpenAIVoice();
139
+ const playai = new PlayAIVoice();
140
+
141
+ // Use OpenAI for listening (speech-to-text) and PlayAI for speaking (text-to-speech)
142
+ const voice = new CompositeVoice({
143
+ input: openai,
144
+ output: playai,
145
+ });
146
+
147
+ // Convert speech to text using OpenAI
148
+ const text = await voice.listen(audioStream);
149
+
150
+ // Convert text to speech using PlayAI
151
+ const audio = await voice.speak("Hello, world!");
152
+ ```
153
+
154
+ ### Using AI SDK Model Providers
155
+
156
+ You can pass AI SDK transcription and speech models directly to CompositeVoice:
157
+
158
+ ```typescript
159
+ import { CompositeVoice } from "@mastra/core/voice";
160
+ import { openai } from "@ai-sdk/openai";
161
+ import { elevenlabs } from "@ai-sdk/elevenlabs";
162
+
163
+ // Use AI SDK models directly - they will be auto-wrapped
164
+ const voice = new CompositeVoice({
165
+ input: openai.transcription('whisper-1'), // AI SDK transcription
166
+ output: elevenlabs.speech('eleven_turbo_v2'), // AI SDK speech
167
+ });
168
+
169
+ // Works the same way as with Mastra providers
170
+ const text = await voice.listen(audioStream);
171
+ const audio = await voice.speak("Hello from AI SDK!");
172
+ ```
173
+
174
+ ### Mix and Match
175
+
176
+ You can combine Mastra providers with AI SDK models:
177
+
178
+ ```typescript
179
+ import { CompositeVoice } from "@mastra/core/voice";
180
+ import { PlayAIVoice } from "@mastra/voice-playai";
181
+ import { groq } from "@ai-sdk/groq";
182
+
183
+ const voice = new CompositeVoice({
184
+ input: groq.transcription('whisper-large-v3'), // AI SDK for STT
185
+ output: new PlayAIVoice(), // Mastra for TTS
186
+ });
187
+ ```