@mastra/mcp-docs-server 0.13.10 → 0.13.11-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +9 -9
  2. package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
  3. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +26 -26
  4. package/.docs/organized/changelogs/%40mastra%2Fcore.md +30 -30
  5. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +20 -20
  6. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +20 -20
  7. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +20 -20
  8. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +30 -30
  9. package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +13 -13
  10. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +9 -9
  11. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +26 -26
  12. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +21 -21
  13. package/.docs/organized/changelogs/%40mastra%2Fpg.md +9 -9
  14. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +21 -21
  15. package/.docs/organized/changelogs/%40mastra%2Frag.md +12 -12
  16. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +7 -0
  17. package/.docs/organized/changelogs/%40mastra%2Fserver.md +26 -26
  18. package/.docs/organized/changelogs/create-mastra.md +11 -11
  19. package/.docs/organized/changelogs/mastra.md +31 -31
  20. package/.docs/organized/code-examples/agent-network.md +4 -3
  21. package/.docs/organized/code-examples/agent.md +33 -2
  22. package/.docs/raw/agents/overview.mdx +21 -1
  23. package/.docs/raw/getting-started/mcp-docs-server.mdx +2 -2
  24. package/.docs/raw/rag/chunking-and-embedding.mdx +11 -0
  25. package/.docs/raw/reference/agents/agent.mdx +64 -38
  26. package/.docs/raw/reference/agents/generate.mdx +206 -202
  27. package/.docs/raw/reference/agents/getAgent.mdx +23 -38
  28. package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +62 -0
  29. package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +62 -0
  30. package/.docs/raw/reference/agents/getDefaultVNextStreamOptions.mdx +62 -0
  31. package/.docs/raw/reference/agents/getDescription.mdx +30 -0
  32. package/.docs/raw/reference/agents/getInstructions.mdx +36 -73
  33. package/.docs/raw/reference/agents/getLLM.mdx +69 -0
  34. package/.docs/raw/reference/agents/getMemory.mdx +42 -119
  35. package/.docs/raw/reference/agents/getModel.mdx +36 -75
  36. package/.docs/raw/reference/agents/getScorers.mdx +62 -0
  37. package/.docs/raw/reference/agents/getTools.mdx +36 -128
  38. package/.docs/raw/reference/agents/getVoice.mdx +36 -83
  39. package/.docs/raw/reference/agents/getWorkflows.mdx +37 -74
  40. package/.docs/raw/reference/agents/stream.mdx +263 -226
  41. package/.docs/raw/reference/agents/streamVNext.mdx +208 -402
  42. package/.docs/raw/reference/cli/build.mdx +1 -0
  43. package/.docs/raw/reference/rag/chunk.mdx +51 -2
  44. package/.docs/raw/reference/scorers/answer-relevancy.mdx +6 -6
  45. package/.docs/raw/reference/scorers/bias.mdx +6 -6
  46. package/.docs/raw/reference/scorers/completeness.mdx +2 -2
  47. package/.docs/raw/reference/scorers/content-similarity.mdx +1 -1
  48. package/.docs/raw/reference/scorers/create-scorer.mdx +445 -0
  49. package/.docs/raw/reference/scorers/faithfulness.mdx +6 -6
  50. package/.docs/raw/reference/scorers/hallucination.mdx +6 -6
  51. package/.docs/raw/reference/scorers/keyword-coverage.mdx +2 -2
  52. package/.docs/raw/reference/scorers/mastra-scorer.mdx +116 -158
  53. package/.docs/raw/reference/scorers/toxicity.mdx +2 -2
  54. package/.docs/raw/scorers/custom-scorers.mdx +166 -268
  55. package/.docs/raw/scorers/overview.mdx +21 -13
  56. package/.docs/raw/server-db/local-dev-playground.mdx +3 -3
  57. package/package.json +5 -5
  58. package/.docs/raw/reference/agents/createTool.mdx +0 -241
  59. package/.docs/raw/reference/scorers/custom-code-scorer.mdx +0 -155
  60. package/.docs/raw/reference/scorers/llm-scorer.mdx +0 -210
@@ -1,34 +1,51 @@
1
1
  ---
2
- title: "Reference: Agent.streamVNext() | Streaming | Agents | Mastra Docs"
3
- description: Documentation for the `.streamVNext()` method in Mastra agents, which enables real-time streaming of responses.
2
+ title: "Reference: streamVNext() | Agents | Mastra Docs"
3
+ description: "Documentation for the `.streamVNext()` method in Mastra agents, which enables real-time streaming of responses with enhanced capabilities."
4
4
  ---
5
5
 
6
- # `streamVNext()`
6
+ # streamVNext()
7
7
 
8
- The `streamVNext()` method enables real-time streaming of responses from an agent. This method accepts `messages` and an optional `options` object as parameters, similar to `generate()`.
8
+ The `.streamVNext()` method enables real-time streaming of responses from an agent with enhanced capabilities. This method accepts messages and optional streaming options, providing a next-generation streaming experience.
9
9
 
10
- ## Parameters
10
+ ## Usage example
11
11
 
12
- ### `messages`
12
+ ```typescript showLineNumbers copy
13
+ const response = await agent.streamVNext("message for agent");
14
+ ```
13
15
 
14
- The `messages` parameter can be:
16
+ ## Parameters
15
17
 
16
- - A single string
17
- - An array of strings
18
- - An array of message objects with `role` and `content` properties
18
+ <PropertiesTable
19
+ content={[
20
+ {
21
+ name: "messages",
22
+ type: "string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[]",
23
+ description: "The messages to send to the agent. Can be a single string, array of strings, or structured message objects.",
24
+ },
25
+ {
26
+ name: "options",
27
+ type: "AgentVNextStreamOptions<Output, StructuredOutput>",
28
+ isOptional: true,
29
+ description: "Optional configuration for the streaming process.",
30
+ },
31
+ ]}
32
+ />
19
33
 
20
- The message object structure:
34
+ ## Extended usage example
21
35
 
22
- ```typescript
23
- interface Message {
24
- role: "system" | "user" | "assistant";
25
- content: string;
26
- }
36
+ ```typescript showLineNumbers copy
37
+ const response = await agent.streamVNext("message for agent", {
38
+ temperature: 0.7,
39
+ maxSteps: 3,
40
+ memory: {
41
+ thread: "user-123",
42
+ resource: "test-app"
43
+ },
44
+ toolChoice: "auto"
45
+ });
27
46
  ```
28
47
 
29
- ### `options` (Optional)
30
-
31
- An optional object that can include configuration for output structure, memory management, tool usage, telemetry, and more.
48
+ ### Options parameters
32
49
 
33
50
  <PropertiesTable
34
51
  content={[
@@ -59,6 +76,13 @@ An optional object that can include configuration for output structure, memory m
59
76
  description:
60
77
  "Custom instructions that override the agent's default instructions for this specific generation. Useful for dynamically modifying agent behavior without creating a new agent instance.",
61
78
  },
79
+ {
80
+ name: "output",
81
+ type: "Zod schema | JsonSchema7",
82
+ isOptional: true,
83
+ description:
84
+ "Defines the expected structure of the output. Can be a JSON Schema object or a Zod schema.",
85
+ },
62
86
  {
63
87
  name: "memory",
64
88
  type: "object",
@@ -86,7 +110,7 @@ An optional object that can include configuration for output structure, memory m
86
110
  name: "options",
87
111
  type: "MemoryConfig",
88
112
  isOptional: true,
89
- description: "Configuration for memory behavior, like message history and semantic recall. See `MemoryConfig` below."
113
+ description: "Configuration for memory behavior, like message history and semantic recall."
90
114
  }]
91
115
  }
92
116
  ]
@@ -96,7 +120,7 @@ An optional object that can include configuration for output structure, memory m
96
120
  type: "number",
97
121
  isOptional: true,
98
122
  defaultValue: "5",
99
- description: "Maximum number of steps allowed during streaming.",
123
+ description: "Maximum number of execution steps allowed.",
100
124
  },
101
125
  {
102
126
  name: "maxRetries",
@@ -110,34 +134,69 @@ An optional object that can include configuration for output structure, memory m
110
134
  type: "MemoryConfig",
111
135
  isOptional: true,
112
136
  description:
113
- "**Deprecated.** Use `memory.options` instead. Configuration options for memory management. See MemoryConfig section below for details.",
137
+ "**Deprecated.** Use `memory.options` instead. Configuration options for memory management.",
114
138
  },
115
139
  {
116
140
  name: "onFinish",
117
- type: "StreamTextOnFinishCallback | StreamObjectOnFinishCallback",
141
+ type: "StreamTextOnFinishCallback<any> | StreamObjectOnFinishCallback<OUTPUT>",
118
142
  isOptional: true,
119
- description: "Callback function called when streaming is complete.",
143
+ description:
144
+ "Callback function called when streaming completes. Receives the final result.",
120
145
  },
121
146
  {
122
147
  name: "onStepFinish",
123
- type: "GenerateTextOnStepFinishCallback<any> | never",
148
+ type: "StreamTextOnStepFinishCallback<any> | never",
124
149
  isOptional: true,
125
150
  description:
126
- "Callback function called after each step during streaming. Unavailable for structured output",
151
+ "Callback function called after each execution step. Receives step details as a JSON string. Unavailable for structured output",
127
152
  },
128
153
  {
129
- name: "output",
130
- type: "Zod schema | JsonSchema7",
154
+ name: "resourceId",
155
+ type: "string",
131
156
  isOptional: true,
132
157
  description:
133
- "Defines the expected structure of the output. Can be a JSON Schema object or a Zod schema.",
158
+ "**Deprecated.** Use `memory.resource` instead. Identifier for the user or resource interacting with the agent. Must be provided if threadId is provided.",
134
159
  },
135
160
  {
136
161
  name: "telemetry",
137
162
  type: "TelemetrySettings",
138
163
  isOptional: true,
139
164
  description:
140
- "Settings for telemetry collection during streaming. See TelemetrySettings section below for details.",
165
+ "Settings for telemetry collection during streaming.",
166
+ properties: [
167
+ {
168
+ parameters: [{
169
+ name: "isEnabled",
170
+ type: "boolean",
171
+ isOptional: true,
172
+ description: "Enable or disable telemetry. Disabled by default while experimental."
173
+ }]
174
+ },
175
+ {
176
+ parameters: [{
177
+ name: "recordInputs",
178
+ type: "boolean",
179
+ isOptional: true,
180
+ description: "Enable or disable input recording. Enabled by default. You might want to disable input recording to avoid recording sensitive information."
181
+ }]
182
+ },
183
+ {
184
+ parameters: [{
185
+ name: "recordOutputs",
186
+ type: "boolean",
187
+ isOptional: true,
188
+ description: "Enable or disable output recording. Enabled by default. You might want to disable output recording to avoid recording sensitive information."
189
+ }]
190
+ },
191
+ {
192
+ parameters: [{
193
+ name: "functionId",
194
+ type: "string",
195
+ isOptional: true,
196
+ description: "Identifier for this function. Used to group telemetry data by function."
197
+ }]
198
+ }
199
+ ]
141
200
  },
142
201
  {
143
202
  name: "temperature",
@@ -146,19 +205,56 @@ An optional object that can include configuration for output structure, memory m
146
205
  description:
147
206
  "Controls randomness in the model's output. Higher values (e.g., 0.8) make the output more random, lower values (e.g., 0.2) make it more focused and deterministic.",
148
207
  },
208
+ {
209
+ name: "threadId",
210
+ type: "string",
211
+ isOptional: true,
212
+ description:
213
+ "**Deprecated.** Use `memory.thread` instead. Identifier for the conversation thread. Allows for maintaining context across multiple interactions. Must be provided if resourceId is provided.",
214
+ },
149
215
  {
150
216
  name: "toolChoice",
151
217
  type: "'auto' | 'none' | 'required' | { type: 'tool'; toolName: string }",
152
218
  isOptional: true,
153
219
  defaultValue: "'auto'",
154
220
  description: "Controls how the agent uses tools during streaming.",
221
+ properties: [
222
+ {
223
+ parameters: [{
224
+ name: "'auto'",
225
+ type: "string",
226
+ description: "Let the model decide whether to use tools (default)."
227
+ }]
228
+ },
229
+ {
230
+ parameters: [{
231
+ name: "'none'",
232
+ type: "string",
233
+ description: "Do not use any tools."
234
+ }]
235
+ },
236
+ {
237
+ parameters: [{
238
+ name: "'required'",
239
+ type: "string",
240
+ description: "Require the model to use at least one tool."
241
+ }]
242
+ },
243
+ {
244
+ parameters: [{
245
+ name: "{ type: 'tool'; toolName: string }",
246
+ type: "object",
247
+ description: "Require the model to use a specific tool by name."
248
+ }]
249
+ }
250
+ ]
155
251
  },
156
252
  {
157
253
  name: "toolsets",
158
254
  type: "ToolsetsInput",
159
255
  isOptional: true,
160
256
  description:
161
- "Additional toolsets to make available to the agent during this stream.",
257
+ "Additional toolsets to make available to the agent during streaming.",
162
258
  },
163
259
  {
164
260
  name: "clientTools",
@@ -167,432 +263,142 @@ An optional object that can include configuration for output structure, memory m
167
263
  description:
168
264
  "Tools that are executed on the 'client' side of the request. These tools do not have execute functions in the definition.",
169
265
  },
170
- ]}
171
- />
172
-
173
- #### MemoryConfig
174
-
175
- Configuration options for memory management:
176
-
177
- <PropertiesTable
178
- content={[
179
266
  {
180
- name: "lastMessages",
181
- type: "number | false",
267
+ name: "savePerStep",
268
+ type: "boolean",
182
269
  isOptional: true,
183
- description:
184
- "Number of most recent messages to include in context. Set to false to disable.",
270
+ description: "Save messages incrementally after each stream step completes (default: false).",
185
271
  },
186
272
  {
187
- name: "semanticRecall",
188
- type: "boolean | object",
273
+ name: "providerOptions",
274
+ type: "Record<string, Record<string, JSONValue>>",
189
275
  isOptional: true,
190
- description:
191
- "Configuration for semantic memory recall. Can be boolean or detailed config.",
276
+ description: "Additional provider-specific options that are passed through to the underlying LLM provider. The structure is `{ providerName: { optionKey: value } }`. For example: `{ openai: { reasoningEffort: 'high' }, anthropic: { maxTokens: 1000 } }`.",
192
277
  properties: [
193
278
  {
194
- type: "number",
195
- parameters: [
196
- {
197
- name: "topK",
198
- type: "number",
199
- isOptional: true,
200
- description:
201
- "Number of most semantically similar messages to retrieve.",
202
- },
203
- ],
279
+ parameters: [{
280
+ name: "openai",
281
+ type: "Record<string, JSONValue>",
282
+ isOptional: true,
283
+ description: "OpenAI-specific options. Example: `{ reasoningEffort: 'high' }`"
284
+ }]
204
285
  },
205
286
  {
206
- type: "number | object",
207
- parameters: [
208
- {
209
- name: "messageRange",
210
- type: "number | { before: number; after: number }",
211
- isOptional: true,
212
- description:
213
- "Range of messages to consider for semantic search. Can be a single number or before/after configuration.",
214
- },
215
- ],
287
+ parameters: [{
288
+ name: "anthropic",
289
+ type: "Record<string, JSONValue>",
290
+ isOptional: true,
291
+ description: "Anthropic-specific options. Example: `{ maxTokens: 1000 }`"
292
+ }]
216
293
  },
217
- ],
218
- },
219
- {
220
- name: "workingMemory",
221
- type: "object",
222
- isOptional: true,
223
- description: "Configuration for working memory.",
224
- properties: [
225
294
  {
226
- type: "boolean",
227
- parameters: [
228
- {
229
- name: "enabled",
230
- type: "boolean",
231
- isOptional: true,
232
- description: "Whether to enable working memory.",
233
- },
234
- ],
295
+ parameters: [{
296
+ name: "google",
297
+ type: "Record<string, JSONValue>",
298
+ isOptional: true,
299
+ description: "Google-specific options. Example: `{ safetySettings: [...] }`"
300
+ }]
235
301
  },
236
302
  {
237
- type: "string",
238
- parameters: [
239
- {
240
- name: "template",
241
- type: "string",
242
- isOptional: true,
243
- description: "Template to use for working memory.",
244
- },
245
- ],
246
- },
247
- ],
303
+ parameters: [{
304
+ name: "[providerName]",
305
+ type: "Record<string, JSONValue>",
306
+ isOptional: true,
307
+ description: "Other provider-specific options. The key is the provider name and the value is a record of provider-specific options."
308
+ }]
309
+ }
310
+ ]
248
311
  },
249
312
  {
250
- name: "threads",
251
- type: "object",
313
+ name: "runId",
314
+ type: "string",
252
315
  isOptional: true,
253
- description: "Thread-specific memory configuration.",
254
- properties: [
255
- {
256
- type: "boolean | object",
257
- parameters: [
258
- {
259
- name: "generateTitle",
260
- type: "boolean | { model: LanguageModelV1 | ((ctx: RuntimeContext) => LanguageModelV1 | Promise<LanguageModelV1>), instructions: string | ((ctx: RuntimeContext) => string | Promise<string>) }",
261
- isOptional: true,
262
- description:
263
- `Controls automatic thread title generation from the user's first message. Can be a boolean to enable/disable using the agent's model, or an object specifying a custom model and/or custom instructions for title generation (useful for cost optimization or title customization).
264
- Example: { model: openai('gpt-4.1-nano'), instructions: 'Generate a concise title based on the initial user message.' }`,
265
- },
266
- ],
267
- },
268
- ],
316
+ description: "Unique ID for this generation run. Useful for tracking and debugging purposes.",
269
317
  },
270
- ]}
271
- />
272
-
273
- #### TelemetrySettings
274
-
275
- Settings for telemetry collection during streaming:
276
-
277
- <PropertiesTable
278
- content={[
279
318
  {
280
- name: "isEnabled",
281
- type: "boolean",
319
+ name: "runtimeContext",
320
+ type: "RuntimeContext",
282
321
  isOptional: true,
283
- defaultValue: "false",
284
- description:
285
- "Enable or disable telemetry. Disabled by default while experimental.",
322
+ description: "Runtime context for dependency injection and contextual information.",
286
323
  },
287
324
  {
288
- name: "recordInputs",
289
- type: "boolean",
325
+ name: "experimental_generateMessageId",
326
+ type: "IDGenerator",
290
327
  isOptional: true,
291
- defaultValue: "true",
292
- description:
293
- "Enable or disable input recording. You might want to disable this to avoid recording sensitive information, reduce data transfers, or increase performance.",
328
+ description: "Generate a unique ID for each message.",
294
329
  },
295
330
  {
296
- name: "recordOutputs",
297
- type: "boolean",
331
+ name: "maxTokens",
332
+ type: "number",
298
333
  isOptional: true,
299
- defaultValue: "true",
300
- description:
301
- "Enable or disable output recording. You might want to disable this to avoid recording sensitive information, reduce data transfers, or increase performance.",
334
+ description: "Maximum number of tokens to generate.",
302
335
  },
303
336
  {
304
- name: "functionId",
305
- type: "string",
337
+ name: "topP",
338
+ type: "number",
306
339
  isOptional: true,
307
- description:
308
- "Identifier for this function. Used to group telemetry data by function.",
340
+ description: "Nucleus sampling. This is a number between 0 and 1. It is recommended to set either `temperature` or `topP`, but not both.",
309
341
  },
310
342
  {
311
- name: "metadata",
312
- type: "Record<string, AttributeValue>",
343
+ name: "topK",
344
+ type: "number",
313
345
  isOptional: true,
314
- description:
315
- "Additional information to include in the telemetry data. AttributeValue can be string, number, boolean, array of these types, or null.",
346
+ description: "Only sample from the top K options for each subsequent token. Used to remove 'long tail' low probability responses.",
316
347
  },
317
348
  {
318
- name: "tracer",
319
- type: "Tracer",
349
+ name: "presencePenalty",
350
+ type: "number",
320
351
  isOptional: true,
321
- description:
322
- "A custom OpenTelemetry tracer instance to use for the telemetry data. See OpenTelemetry documentation for details.",
323
- },
324
- ]}
325
- />
326
-
327
-
328
-
329
- ## Protocol
330
-
331
- <PropertiesTable
332
- content={[
333
- {
334
- name: "start",
335
- type: "object",
336
- description: "The agent starts",
337
- isOptional: false,
338
- properties: [
339
- {
340
- type: "object",
341
- parameters: [
342
- {
343
- name: "example",
344
- type: "{ type: 'start', runId: '1', from: 'AGENT', payload: {} }",
345
- description: "Example message structure",
346
- isOptional: false,
347
- },
348
- ],
349
- },
350
- ],
352
+ description: "Presence penalty setting. It affects the likelihood of the model to repeat information that is already in the prompt. A number between -1 (increase repetition) and 1 (maximum penalty, decrease repetition).",
351
353
  },
352
354
  {
353
- name: "step-start",
354
- type: "object",
355
- description: "The start of a step",
356
- isOptional: false,
357
- properties: [
358
- {
359
- type: "object",
360
- parameters: [
361
- {
362
- name: "example",
363
- type: "{ type: 'step-start', runId: '1', from: 'AGENT', payload: { messageId: 'uuid', request: { /* Raw request object */ }, warnings: [] } }",
364
- description: "Example message structure",
365
- isOptional: false,
366
- },
367
- ],
368
- },
369
- ],
355
+ name: "frequencyPenalty",
356
+ type: "number",
357
+ isOptional: true,
358
+ description: "Frequency penalty setting. It affects the likelihood of the model to repeatedly use the same words or phrases. A number between -1 (increase repetition) and 1 (maximum penalty, decrease repetition).",
370
359
  },
371
360
  {
372
- name: "tool-call",
373
- type: "object",
374
- description: "The start of a tool call",
375
- isOptional: false,
376
- properties: [
377
- {
378
- type: "object",
379
- parameters: [
380
- {
381
- name: "example",
382
- type: "{ type: 'tool-call', runId: '1', from: 'AGENT', payload: { toolCallId: 'uuid', args: { ... }, toolName: 'my tool' } }",
383
- description: "Example message structure",
384
- isOptional: false,
385
- },
386
- ],
387
- },
388
- ],
361
+ name: "stopSequences",
362
+ type: "string[]",
363
+ isOptional: true,
364
+ description: "Stop sequences. If set, the model will stop generating text when one of the stop sequences is generated.",
389
365
  },
390
366
  {
391
- name: "tool-output",
392
- type: "object",
393
- description: "Custom output from a step",
394
- isOptional: false,
395
- properties: [
396
- {
397
- type: "object",
398
- parameters: [
399
- {
400
- name: "example",
401
- type: "{ type: 'tool-output', runId: '1', from: 'AGENT', payload: { toolName: 'my step', output: { ... }, toolCallId: 'uuid' } }",
402
- description: "Example message structure",
403
- isOptional: false,
404
- },
405
- ],
406
- },
407
- ],
367
+ name: "seed",
368
+ type: "number",
369
+ isOptional: true,
370
+ description: "The seed (integer) to use for random sampling. If set and supported by the model, calls will generate deterministic results.",
408
371
  },
409
372
  {
410
- name: "tool-result",
411
- type: "object",
412
- description: "The result of a step",
413
- isOptional: false,
414
- properties: [
415
- {
416
- type: "object",
417
- parameters: [
418
- {
419
- name: "example",
420
- type: "{ type: 'tool-result', runId: '1', from: 'AGENT', payload: { toolCallId: 'uuid', result: { ... }, toolName: 'my tool' } }",
421
- description: "Example message structure",
422
- isOptional: false,
423
- },
424
- ],
425
- },
426
- ],
373
+ name: "headers",
374
+ type: "Record<string, string | undefined>",
375
+ isOptional: true,
376
+ description: "Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.",
427
377
  },
428
378
  {
429
- name: "step-finish",
430
- type: "object",
431
- description: "The end of a step",
432
- isOptional: false,
433
- properties: [
434
- {
435
- type: "object",
436
- parameters: [
437
- {
438
- name: "example",
439
- type: "{ type: 'step-finish', runId: '1', from: 'AGENT', payload: { reason: 'stop', usage: { promptTokens: 100, completionTokens: 100, totalTokens: 200 }, response: Response, messageId: 'uuid', providerMetadata: { ... } } }",
440
- description: "Example message structure",
441
- isOptional: false,
442
- },
443
- ],
444
- },
445
- ],
379
+ name: "system",
380
+ type: "string",
381
+ isOptional: true,
382
+ description: "System message to include in the prompt. Can be used with `prompt` or `messages`.",
446
383
  },
447
384
  {
448
- name: "finish",
449
- type: "object",
450
- description: "The end of the workflow",
451
- isOptional: false,
452
- properties: [
453
- {
454
- type: "object",
455
- parameters: [
456
- {
457
- name: "example",
458
- type: "{ type: 'finish', runId: '1', from: 'AGENT', payload: { totalUsage: { promptTokens: 100, completionTokens: 100, totalTokens: 200 } } }",
459
- description: "Example message structure",
460
- isOptional: false,
461
- },
462
- ],
463
- },
464
- ],
465
- },
385
+ name: "prompt",
386
+ type: "string",
387
+ isOptional: true,
388
+ description: "A simple text prompt. You can either use `prompt` or `messages` but not both.",
389
+ }
466
390
  ]}
467
391
  />
468
392
 
469
393
  ## Returns
470
394
 
471
- The return value of the `streamVNext()` method is a custom MatraAgentStream. This stream extends a ReadableStream, so all basic stream methods are available.
472
-
473
- ### PropertiesTable for Return Values
474
-
475
395
  <PropertiesTable
476
396
  content={[
477
397
  {
478
- name: "textStream",
479
- type: "ReadableStream<string>",
480
- isOptional: true,
481
- description:
482
- "Stream of text chunks. Present when output is 'text' (no schema provided) or when using `experimental_output`.",
483
- },
484
- {
485
- name: "usage",
486
- type: "Promise<object>",
487
- isOptional: true,
488
- description:
489
- "Total usage of the agent, including agents/workflows as a tool.",
490
- properties: [
491
- {
492
- type: "number",
493
- parameters: [
494
- {
495
- name: "promptTokens",
496
- type: "number",
497
- isOptional: true,
498
- description: "The number of prompt tokens used by the agent.",
499
- },
500
- ],
501
- },
502
- {
503
- type: "number",
504
- parameters: [
505
- {
506
- name: "completionTokens",
507
- type: "number",
508
- isOptional: true,
509
- description: "The number of completion tokens used by the agent.",
510
- },
511
- ],
512
- },
513
- {
514
- type: "number",
515
- parameters: [
516
- {
517
- name: "totalTokens",
518
- type: "number",
519
- isOptional: true,
520
- description: "The total number of tokens used by the agent.",
521
- },
522
- ],
523
- },
524
- ],
525
- },
526
- {
527
- name: "finishReason",
528
- type: "Promise<string>",
529
- isOptional: true,
530
- description:
531
- "The reason the agent stopped streaming.",
532
- },
533
- {
534
- name: "toolCalls",
535
- type: "Promise<object>",
536
- isOptional: true,
537
- description:
538
- "The tool calls made by the agent.",
539
- },
540
- {
541
- name: "toolResults",
542
- type: "Promise<object>",
543
- isOptional: true,
544
- description:
545
- "The tool results returned by the agent.",
546
- },
547
- {
548
- name: "text",
549
- type: "Promise<string>",
550
- isOptional: true,
551
- description:
552
- "The full text of the agent's response.",
553
- },
554
- {
555
- name: "object",
556
- type: "Promise<object>",
557
- isOptional: true,
558
- description:
559
- "The object of the agent's response, if you use output or experimental output.",
398
+ name: "stream",
399
+ type: "MastraAgentStream<Output extends ZodSchema ? z.infer<Output> : StructuredOutput extends ZodSchema ? z.infer<StructuredOutput> : unknown>",
400
+ description: "A streaming interface that provides enhanced streaming capabilities for text and structured output.",
560
401
  },
561
402
  ]}
562
403
  />
563
404
 
564
- ## Examples
565
-
566
- ### Basic Text Streaming
567
-
568
- ```typescript
569
- const stream = await myAgent.streamVNext([
570
- { role: "user", content: "Tell me a story." },
571
- ]);
572
-
573
- for await (const chunk of stream.textStream) {
574
- process.stdout.write(chunk);
575
- }
576
- ```
577
-
578
- ### Structured Output Streaming with Thread Context
579
-
580
- ```typescript
581
- import { z } from "zod";
582
-
583
- const schema = z.object({
584
- summary: z.string(),
585
- nextSteps: z.array(z.string()),
586
- });
587
-
588
- const response = await myAgent.streamVNext("What should we do next?", {
589
- output: schema,
590
- memory: {
591
- thread: "project-123",
592
- },
593
- });
594
-
595
- const result = await response.object;
596
- console.log("Final structured result:", result);
597
- ```
598
-