@mastra/mcp-docs-server 0.13.20 → 0.13.21-alpha.0
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.
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +8 -8
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +8 -0
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +13 -13
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +41 -41
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +22 -22
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +17 -17
- package/.docs/organized/changelogs/create-mastra.md +5 -5
- package/.docs/organized/changelogs/mastra.md +21 -21
- package/.docs/organized/code-examples/agent.md +34 -9
- package/.docs/organized/code-examples/ai-sdk-v5.md +16 -14
- package/.docs/organized/code-examples/heads-up-game.md +3 -3
- package/.docs/raw/auth/clerk.mdx +142 -0
- package/.docs/raw/getting-started/installation.mdx +3 -1
- package/.docs/raw/getting-started/model-providers.mdx +31 -31
- package/.docs/raw/observability/ai-tracing.mdx +123 -24
- package/.docs/raw/reference/agents/ChunkType.mdx +857 -0
- package/.docs/raw/reference/agents/MastraModelOutput.mdx +321 -0
- package/.docs/raw/reference/agents/generateVNext.mdx +519 -0
- package/.docs/raw/reference/agents/streamVNext.mdx +6 -20
- package/.docs/raw/reference/auth/clerk.mdx +71 -0
- package/.docs/raw/reference/scorers/answer-similarity.mdx +179 -0
- package/.docs/raw/scorers/off-the-shelf-scorers.mdx +1 -0
- package/.docs/raw/server-db/production-server.mdx +27 -2
- package/.docs/raw/tools-mcp/mcp-overview.mdx +144 -159
- package/.docs/raw/workflows/control-flow.mdx +1 -1
- package/.docs/raw/workflows/suspend-and-resume.mdx +5 -0
- package/CHANGELOG.md +9 -0
- package/dist/stdio.js +11 -4
- package/dist/tools/docs.d.ts.map +1 -1
- package/package.json +4 -4
- /package/.docs/raw/reference/{templates.mdx → templates/overview.mdx} +0 -0
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Agent.generateVNext() (Experimental) | Agents | Mastra Docs"
|
|
3
|
+
description: "Documentation for the `Agent.generateVNext()` method in Mastra agents, which enables non-streaming generation of responses with enhanced capabilities."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { GenerateVNextCallout } from "@/components/generateVNext-callout.tsx"
|
|
7
|
+
|
|
8
|
+
# Agent.generateVNext() (Experimental)
|
|
9
|
+
|
|
10
|
+
<GenerateVNextCallout />
|
|
11
|
+
|
|
12
|
+
The `.generateVNext()` method enables non-streaming response generation from an agent, with enhanced capabilities and flexible output formats. It accepts messages and optional generation options, supporting both Mastra’s native format and AI SDK v5 compatibility.
|
|
13
|
+
|
|
14
|
+
## Usage example
|
|
15
|
+
|
|
16
|
+
```typescript copy
|
|
17
|
+
// Default Mastra format
|
|
18
|
+
const mastraResult = await agent.generateVNext("message for agent");
|
|
19
|
+
|
|
20
|
+
// AI SDK v5 compatible format
|
|
21
|
+
const aiSdkResult = await agent.generateVNext("message for agent", {
|
|
22
|
+
format: 'aisdk'
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Parameters
|
|
27
|
+
|
|
28
|
+
<PropertiesTable
|
|
29
|
+
content={[
|
|
30
|
+
{
|
|
31
|
+
name: "messages",
|
|
32
|
+
type: "string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[]",
|
|
33
|
+
description: "The messages to send to the agent. Can be a single string, array of strings, or structured message objects.",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "options",
|
|
37
|
+
type: "AgentExecutionOptions<Output, StructuredOutput, Format>",
|
|
38
|
+
isOptional: true,
|
|
39
|
+
description: "Optional configuration for the generation process.",
|
|
40
|
+
},
|
|
41
|
+
]}
|
|
42
|
+
/>
|
|
43
|
+
|
|
44
|
+
### Options
|
|
45
|
+
|
|
46
|
+
<PropertiesTable
|
|
47
|
+
content={[
|
|
48
|
+
{
|
|
49
|
+
name: "format",
|
|
50
|
+
type: "'mastra' | 'aisdk'",
|
|
51
|
+
isOptional: true,
|
|
52
|
+
defaultValue: "'mastra'",
|
|
53
|
+
description: "Determines the output format. Use 'mastra' for Mastra's native format (default) or 'aisdk' for AI SDK v5 compatibility.",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "maxSteps",
|
|
57
|
+
type: "number",
|
|
58
|
+
isOptional: true,
|
|
59
|
+
description: "Maximum number of steps to run during execution.",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "scorers",
|
|
63
|
+
type: "MastraScorers | Record<string, { scorer: MastraScorer['name']; sampling?: ScoringSamplingConfig }>",
|
|
64
|
+
isOptional: true,
|
|
65
|
+
description: "Evaluation scorers to run on the execution results.",
|
|
66
|
+
properties: [
|
|
67
|
+
{
|
|
68
|
+
parameters: [{
|
|
69
|
+
name: "scorer",
|
|
70
|
+
type: "string",
|
|
71
|
+
isOptional: false,
|
|
72
|
+
description: "Name of the scorer to use."
|
|
73
|
+
}]
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
parameters: [{
|
|
77
|
+
name: "sampling",
|
|
78
|
+
type: "ScoringSamplingConfig",
|
|
79
|
+
isOptional: true,
|
|
80
|
+
description: "Sampling configuration for the scorer.",
|
|
81
|
+
properties: [
|
|
82
|
+
{
|
|
83
|
+
parameters: [{
|
|
84
|
+
name: "type",
|
|
85
|
+
type: "'none' | 'ratio'",
|
|
86
|
+
isOptional: false,
|
|
87
|
+
description: "Type of sampling strategy. Use 'none' to disable sampling or 'ratio' for percentage-based sampling."
|
|
88
|
+
}]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
parameters: [{
|
|
92
|
+
name: "rate",
|
|
93
|
+
type: "number",
|
|
94
|
+
isOptional: true,
|
|
95
|
+
description: "Sampling rate (0-1). Required when type is 'ratio'."
|
|
96
|
+
}]
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}]
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "tracingContext",
|
|
105
|
+
type: "TracingContext",
|
|
106
|
+
isOptional: true,
|
|
107
|
+
description: "AI tracing context for span hierarchy and metadata.",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "returnScorerData",
|
|
111
|
+
type: "boolean",
|
|
112
|
+
isOptional: true,
|
|
113
|
+
description: "Whether to return detailed scoring data in the response.",
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: "onChunk",
|
|
117
|
+
type: "(chunk: ChunkType) => Promise<void> | void",
|
|
118
|
+
isOptional: true,
|
|
119
|
+
description: "Callback function called for each chunk during generation.",
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: "onError",
|
|
123
|
+
type: "({ error }: { error: Error | string }) => Promise<void> | void",
|
|
124
|
+
isOptional: true,
|
|
125
|
+
description: "Callback function called when an error occurs during generation.",
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "onAbort",
|
|
129
|
+
type: "(event: any) => Promise<void> | void",
|
|
130
|
+
isOptional: true,
|
|
131
|
+
description: "Callback function called when the generation is aborted.",
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "activeTools",
|
|
135
|
+
type: "Array<keyof ToolSet> | undefined",
|
|
136
|
+
isOptional: true,
|
|
137
|
+
description: "Array of tool names that should be active during execution. If undefined, all available tools are active.",
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: "abortSignal",
|
|
141
|
+
type: "AbortSignal",
|
|
142
|
+
isOptional: true,
|
|
143
|
+
description: "Signal object that allows you to abort the agent's execution. When the signal is aborted, all ongoing operations will be terminated.",
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "prepareStep",
|
|
147
|
+
type: "PrepareStepFunction<any>",
|
|
148
|
+
isOptional: true,
|
|
149
|
+
description: "Callback function called before each step of multi-step execution.",
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: "context",
|
|
153
|
+
type: "ModelMessage[]",
|
|
154
|
+
isOptional: true,
|
|
155
|
+
description: "Additional context messages to provide to the agent.",
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: "structuredOutput",
|
|
159
|
+
type: "StructuredOutputOptions<S extends ZodTypeAny = ZodTypeAny>",
|
|
160
|
+
isOptional: true,
|
|
161
|
+
description: "Enables structured output generation with better developer experience. Automatically creates and uses a StructuredOutputProcessor internally.",
|
|
162
|
+
properties: [
|
|
163
|
+
{
|
|
164
|
+
parameters: [{
|
|
165
|
+
name: "schema",
|
|
166
|
+
type: "z.ZodSchema<S>",
|
|
167
|
+
isOptional: false,
|
|
168
|
+
description: "Zod schema defining the expected output structure."
|
|
169
|
+
}]
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
parameters: [{
|
|
173
|
+
name: "model",
|
|
174
|
+
type: "MastraLanguageModel",
|
|
175
|
+
isOptional: true,
|
|
176
|
+
description: "Language model to use for structured output generation. If not provided, uses the agent's default model."
|
|
177
|
+
}]
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
parameters: [{
|
|
181
|
+
name: "errorStrategy",
|
|
182
|
+
type: "'strict' | 'warn' | 'fallback'",
|
|
183
|
+
isOptional: true,
|
|
184
|
+
description: "Strategy for handling schema validation errors. 'strict' throws errors, 'warn' logs warnings, 'fallback' uses fallback values."
|
|
185
|
+
}]
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
parameters: [{
|
|
189
|
+
name: "fallbackValue",
|
|
190
|
+
type: "<S extends ZodTypeAny>",
|
|
191
|
+
isOptional: true,
|
|
192
|
+
description: "Fallback value to use when schema validation fails and errorStrategy is 'fallback'."
|
|
193
|
+
}]
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
parameters: [{
|
|
197
|
+
name: "instructions",
|
|
198
|
+
type: "string",
|
|
199
|
+
isOptional: true,
|
|
200
|
+
description: "Additional instructions for structured output generation."
|
|
201
|
+
}]
|
|
202
|
+
}
|
|
203
|
+
]
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
name: "outputProcessors",
|
|
207
|
+
type: "Processor[]",
|
|
208
|
+
isOptional: true,
|
|
209
|
+
description: "Output processors to use for this execution (overrides agent's default).",
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
name: "inputProcessors",
|
|
213
|
+
type: "Processor[]",
|
|
214
|
+
isOptional: true,
|
|
215
|
+
description: "Input processors to use for this execution (overrides agent's default).",
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
name: "instructions",
|
|
219
|
+
type: "string",
|
|
220
|
+
isOptional: true,
|
|
221
|
+
description: "Custom instructions that override the agent's default instructions for this execution.",
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: "output",
|
|
225
|
+
type: "Zod schema | JsonSchema7",
|
|
226
|
+
isOptional: true,
|
|
227
|
+
description: "Schema for structured output generation (Zod schema or JSON Schema).",
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
name: "memory",
|
|
231
|
+
type: "object",
|
|
232
|
+
isOptional: true,
|
|
233
|
+
description: "Memory configuration for conversation persistence and retrieval.",
|
|
234
|
+
properties: [
|
|
235
|
+
{
|
|
236
|
+
parameters: [{
|
|
237
|
+
name: "thread",
|
|
238
|
+
type: "string | { id: string; metadata?: Record<string, any>, title?: string }",
|
|
239
|
+
isOptional: false,
|
|
240
|
+
description: "Thread identifier for conversation continuity. Can be a string ID or an object with ID and optional metadata/title."
|
|
241
|
+
}]
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
parameters: [{
|
|
245
|
+
name: "resource",
|
|
246
|
+
type: "string",
|
|
247
|
+
isOptional: false,
|
|
248
|
+
description: "Resource identifier for organizing conversations by user, session, or context."
|
|
249
|
+
}]
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
parameters: [{
|
|
253
|
+
name: "options",
|
|
254
|
+
type: "MemoryConfig",
|
|
255
|
+
isOptional: true,
|
|
256
|
+
description: "Additional memory configuration options for conversation management."
|
|
257
|
+
}]
|
|
258
|
+
}
|
|
259
|
+
]
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
name: "onFinish",
|
|
263
|
+
type: "StreamTextOnFinishCallback<any> | StreamObjectOnFinishCallback<OUTPUT>",
|
|
264
|
+
isOptional: true,
|
|
265
|
+
description: "Callback fired when generation completes. Type varies by format.",
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
name: "onStepFinish",
|
|
269
|
+
type: "StreamTextOnStepFinishCallback<any> | never",
|
|
270
|
+
isOptional: true,
|
|
271
|
+
description: "Callback fired after each generation step. Type varies by format.",
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
name: "resourceId",
|
|
275
|
+
type: "string",
|
|
276
|
+
isOptional: true,
|
|
277
|
+
description: "Deprecated. Use memory.resource instead. Identifier for the resource/user.",
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
name: "telemetry",
|
|
281
|
+
type: "TelemetrySettings",
|
|
282
|
+
isOptional: true,
|
|
283
|
+
description: "Telemetry collection settings for observability.",
|
|
284
|
+
properties: [
|
|
285
|
+
{
|
|
286
|
+
parameters: [{
|
|
287
|
+
name: "isEnabled",
|
|
288
|
+
type: "boolean",
|
|
289
|
+
isOptional: true,
|
|
290
|
+
description: "Whether telemetry collection is enabled."
|
|
291
|
+
}]
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
parameters: [{
|
|
295
|
+
name: "recordInputs",
|
|
296
|
+
type: "boolean",
|
|
297
|
+
isOptional: true,
|
|
298
|
+
description: "Whether to record input data in telemetry."
|
|
299
|
+
}]
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
parameters: [{
|
|
303
|
+
name: "recordOutputs",
|
|
304
|
+
type: "boolean",
|
|
305
|
+
isOptional: true,
|
|
306
|
+
description: "Whether to record output data in telemetry."
|
|
307
|
+
}]
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
parameters: [{
|
|
311
|
+
name: "functionId",
|
|
312
|
+
type: "string",
|
|
313
|
+
isOptional: true,
|
|
314
|
+
description: "Identifier for the function being executed."
|
|
315
|
+
}]
|
|
316
|
+
}
|
|
317
|
+
]
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
name: "modelSettings",
|
|
321
|
+
type: "CallSettings",
|
|
322
|
+
isOptional: true,
|
|
323
|
+
description: "Model-specific settings like temperature, topP, etc.",
|
|
324
|
+
properties: [
|
|
325
|
+
{
|
|
326
|
+
parameters: [{
|
|
327
|
+
name: "temperature",
|
|
328
|
+
type: "number",
|
|
329
|
+
isOptional: true,
|
|
330
|
+
description: "Controls randomness in generation (0-2). Higher values make output more random."
|
|
331
|
+
}]
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
parameters: [{
|
|
335
|
+
name: "maxRetries",
|
|
336
|
+
type: "number",
|
|
337
|
+
isOptional: true,
|
|
338
|
+
description: "Maximum number of retry attempts for failed requests."
|
|
339
|
+
}]
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
parameters: [{
|
|
343
|
+
name: "topP",
|
|
344
|
+
type: "number",
|
|
345
|
+
isOptional: true,
|
|
346
|
+
description: "Nucleus sampling parameter (0-1). Controls diversity of generated text."
|
|
347
|
+
}]
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
parameters: [{
|
|
351
|
+
name: "topK",
|
|
352
|
+
type: "number",
|
|
353
|
+
isOptional: true,
|
|
354
|
+
description: "Top-k sampling parameter. Limits vocabulary to k most likely tokens."
|
|
355
|
+
}]
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
parameters: [{
|
|
359
|
+
name: "presencePenalty",
|
|
360
|
+
type: "number",
|
|
361
|
+
isOptional: true,
|
|
362
|
+
description: "Penalty for token presence (-2 to 2). Reduces repetition."
|
|
363
|
+
}]
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
parameters: [{
|
|
367
|
+
name: "frequencyPenalty",
|
|
368
|
+
type: "number",
|
|
369
|
+
isOptional: true,
|
|
370
|
+
description: "Penalty for token frequency (-2 to 2). Reduces repetition of frequent tokens."
|
|
371
|
+
}]
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
parameters: [{
|
|
375
|
+
name: "stopSequences",
|
|
376
|
+
type: "string[]",
|
|
377
|
+
isOptional: true,
|
|
378
|
+
description: "Array of strings that will stop generation when encountered."
|
|
379
|
+
}]
|
|
380
|
+
}
|
|
381
|
+
]
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
name: "threadId",
|
|
385
|
+
type: "string",
|
|
386
|
+
isOptional: true,
|
|
387
|
+
description: "Deprecated. Use memory.thread instead. Thread identifier for conversation continuity.",
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
name: "toolChoice",
|
|
391
|
+
type: "'auto' | 'none' | 'required' | { type: 'tool'; toolName: string }",
|
|
392
|
+
isOptional: true,
|
|
393
|
+
description: "Controls how tools are selected during generation.",
|
|
394
|
+
properties: [
|
|
395
|
+
{
|
|
396
|
+
parameters: [{
|
|
397
|
+
name: "'auto'",
|
|
398
|
+
type: "string",
|
|
399
|
+
isOptional: false,
|
|
400
|
+
description: "Let the model decide when to use tools (default)."
|
|
401
|
+
}]
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
parameters: [{
|
|
405
|
+
name: "'none'",
|
|
406
|
+
type: "string",
|
|
407
|
+
isOptional: false,
|
|
408
|
+
description: "Disable tool usage entirely."
|
|
409
|
+
}]
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
parameters: [{
|
|
413
|
+
name: "'required'",
|
|
414
|
+
type: "string",
|
|
415
|
+
isOptional: false,
|
|
416
|
+
description: "Force the model to use at least one tool."
|
|
417
|
+
}]
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
parameters: [{
|
|
421
|
+
name: "{ type: 'tool'; toolName: string }",
|
|
422
|
+
type: "object",
|
|
423
|
+
isOptional: false,
|
|
424
|
+
description: "Force the model to use a specific tool."
|
|
425
|
+
}]
|
|
426
|
+
}
|
|
427
|
+
]
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
name: "toolsets",
|
|
431
|
+
type: "ToolsetsInput",
|
|
432
|
+
isOptional: true,
|
|
433
|
+
description: "Additional tool sets that can be used for this execution.",
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
name: "clientTools",
|
|
437
|
+
type: "ToolsInput",
|
|
438
|
+
isOptional: true,
|
|
439
|
+
description: "Client-side tools available during execution.",
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
name: "savePerStep",
|
|
443
|
+
type: "boolean",
|
|
444
|
+
isOptional: true,
|
|
445
|
+
description: "Save messages incrementally after each generation step completes (default: false).",
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
name: "providerOptions",
|
|
449
|
+
type: "Record<string, Record<string, JSONValue>>",
|
|
450
|
+
isOptional: true,
|
|
451
|
+
description: "Provider-specific options passed to the language model.",
|
|
452
|
+
properties: [
|
|
453
|
+
{
|
|
454
|
+
parameters: [{
|
|
455
|
+
name: "openai",
|
|
456
|
+
type: "Record<string, JSONValue>",
|
|
457
|
+
isOptional: true,
|
|
458
|
+
description: "OpenAI-specific options like reasoningEffort, responseFormat, etc."
|
|
459
|
+
}]
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
parameters: [{
|
|
463
|
+
name: "anthropic",
|
|
464
|
+
type: "Record<string, JSONValue>",
|
|
465
|
+
isOptional: true,
|
|
466
|
+
description: "Anthropic-specific options like maxTokens, etc."
|
|
467
|
+
}]
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
parameters: [{
|
|
471
|
+
name: "google",
|
|
472
|
+
type: "Record<string, JSONValue>",
|
|
473
|
+
isOptional: true,
|
|
474
|
+
description: "Google-specific options."
|
|
475
|
+
}]
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
parameters: [{
|
|
479
|
+
name: "[providerName]",
|
|
480
|
+
type: "Record<string, JSONValue>",
|
|
481
|
+
isOptional: true,
|
|
482
|
+
description: "Any provider-specific options."
|
|
483
|
+
}]
|
|
484
|
+
}
|
|
485
|
+
]
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
name: "runId",
|
|
489
|
+
type: "string",
|
|
490
|
+
isOptional: true,
|
|
491
|
+
description: "Unique identifier for this execution run.",
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
name: "runtimeContext",
|
|
495
|
+
type: "RuntimeContext",
|
|
496
|
+
isOptional: true,
|
|
497
|
+
description: "Runtime context containing dynamic configuration and state.",
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
name: "stopWhen",
|
|
501
|
+
type: "StopCondition | StopCondition[]",
|
|
502
|
+
isOptional: true,
|
|
503
|
+
description: "Conditions for stopping execution (e.g., step count, token limit).",
|
|
504
|
+
},
|
|
505
|
+
]}
|
|
506
|
+
/>
|
|
507
|
+
|
|
508
|
+
## Returns
|
|
509
|
+
|
|
510
|
+
<PropertiesTable
|
|
511
|
+
content={[
|
|
512
|
+
{
|
|
513
|
+
name: "result",
|
|
514
|
+
type: "Awaited<ReturnType<MastraModelOutput<Output>['getFullOutput']>> | Awaited<ReturnType<AISDKV5OutputStream<Output>['getFullOutput']>>",
|
|
515
|
+
description: "Returns the full output of the generation process. When format is 'mastra' (default), returns MastraModelOutput result. When format is 'aisdk', returns AISDKV5OutputStream result for AI SDK v5 compatibility.",
|
|
516
|
+
},
|
|
517
|
+
]}
|
|
518
|
+
/>
|
|
519
|
+
|
|
@@ -142,6 +142,12 @@ const aiSdkStream = await agent.streamVNext("message for agent", {
|
|
|
142
142
|
isOptional: true,
|
|
143
143
|
description: "Array of active tool names that can be used during execution."
|
|
144
144
|
},
|
|
145
|
+
{
|
|
146
|
+
name: "prepareStep",
|
|
147
|
+
type: "PrepareStepFunction<any>",
|
|
148
|
+
isOptional: true,
|
|
149
|
+
description: "Callback function called before each step of multi-step execution.",
|
|
150
|
+
},
|
|
145
151
|
{
|
|
146
152
|
name: "context",
|
|
147
153
|
type: "ModelMessage[]",
|
|
@@ -208,13 +214,6 @@ const aiSdkStream = await agent.streamVNext("message for agent", {
|
|
|
208
214
|
isOptional: true,
|
|
209
215
|
description: "Overrides the input processors set on the agent. Input processors that can modify or validate messages before they are processed by the agent. Must implement the `processInput` function.",
|
|
210
216
|
},
|
|
211
|
-
{
|
|
212
|
-
name: "experimental_output",
|
|
213
|
-
type: "Zod schema | JsonSchema7",
|
|
214
|
-
isOptional: true,
|
|
215
|
-
description:
|
|
216
|
-
"Note, the preferred route is to use the `structuredOutput` property. Enables structured output generation alongside text generation and tool calls. The model will generate responses that conform to the provided schema.",
|
|
217
|
-
},
|
|
218
217
|
{
|
|
219
218
|
name: "instructions",
|
|
220
219
|
type: "string",
|
|
@@ -261,13 +260,6 @@ const aiSdkStream = await agent.streamVNext("message for agent", {
|
|
|
261
260
|
}
|
|
262
261
|
]
|
|
263
262
|
},
|
|
264
|
-
{
|
|
265
|
-
name: "memoryOptions",
|
|
266
|
-
type: "MemoryConfig",
|
|
267
|
-
isOptional: true,
|
|
268
|
-
description:
|
|
269
|
-
"**Deprecated.** Use `memory.options` instead. Configuration options for memory management.",
|
|
270
|
-
},
|
|
271
263
|
{
|
|
272
264
|
name: "onFinish",
|
|
273
265
|
type: "StreamTextOnFinishCallback<any> | StreamObjectOnFinishCallback<OUTPUT>",
|
|
@@ -517,12 +509,6 @@ const aiSdkStream = await agent.streamVNext("message for agent", {
|
|
|
517
509
|
isOptional: true,
|
|
518
510
|
description: "Condition(s) that determine when to stop the agent's execution. Can be a single condition or array of conditions.",
|
|
519
511
|
},
|
|
520
|
-
{
|
|
521
|
-
name: "headers",
|
|
522
|
-
type: "Record<string, string | undefined>",
|
|
523
|
-
isOptional: true,
|
|
524
|
-
description: "Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.",
|
|
525
|
-
}
|
|
526
512
|
]}
|
|
527
513
|
/>
|
|
528
514
|
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "MastraAuthClerk Class"
|
|
3
|
+
description: "API reference for the MastraAuthClerk class, which authenticates Mastra applications using Clerk authentication."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# MastraAuthClerk Class
|
|
7
|
+
|
|
8
|
+
The `MastraAuthClerk` class provides authentication for Mastra applications using Clerk. It verifies incoming requests with Clerk-issued JWT tokens and integrates with the Mastra server using the `experimental_auth` option.
|
|
9
|
+
|
|
10
|
+
## Usage example
|
|
11
|
+
|
|
12
|
+
```typescript filename="src/mastra/index.ts" showLineNumbers copy
|
|
13
|
+
import { Mastra } from "@mastra/core/mastra";
|
|
14
|
+
import { MastraAuthClerk } from '@mastra/clerk-auth';
|
|
15
|
+
|
|
16
|
+
export const mastra = new Mastra({
|
|
17
|
+
// ..
|
|
18
|
+
server: {
|
|
19
|
+
experimental_auth: new MastraAuthClerk({
|
|
20
|
+
jwksUri: process.env.CLERK_JWKS_URI,
|
|
21
|
+
publishableKey: process.env.CLERK_PUBLISHABLE_KEY,
|
|
22
|
+
secretKey: process.env.CLERK_SECRET_KEY,
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Constructor parameters
|
|
29
|
+
|
|
30
|
+
<PropertiesTable
|
|
31
|
+
content={[
|
|
32
|
+
{
|
|
33
|
+
name: "publishableKey",
|
|
34
|
+
type: "string",
|
|
35
|
+
description: "Your Clerk publishable key. Can be found in your Clerk Dashboard under API Keys.",
|
|
36
|
+
isOptional: true,
|
|
37
|
+
defaultValue: "process.env.CLERK_PUBLISHABLE_KEY"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "secretKey",
|
|
41
|
+
type: "string",
|
|
42
|
+
description: "Your Clerk secret key. Used for server-side authentication and token verification.",
|
|
43
|
+
isOptional: true,
|
|
44
|
+
defaultValue: "process.env.CLERK_SECRET_KEY"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "jwksUri",
|
|
48
|
+
type: "string",
|
|
49
|
+
description: "The JWKS URI from your Clerk application. Used to verify JWT signatures.",
|
|
50
|
+
isOptional: true,
|
|
51
|
+
defaultValue: "process.env.CLERK_JWKS_URI"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "name",
|
|
55
|
+
type: "string",
|
|
56
|
+
description: "Custom name for the auth provider instance.",
|
|
57
|
+
isOptional: true,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "authorizeUser",
|
|
61
|
+
type: "(user: User, request: HonoRequest) => Promise<boolean> | boolean",
|
|
62
|
+
description: "Custom authorization function to determine if a user should be granted access. Called after token verification. By default, allows all authenticated users.",
|
|
63
|
+
isOptional: true,
|
|
64
|
+
},
|
|
65
|
+
]}
|
|
66
|
+
/>
|
|
67
|
+
|
|
68
|
+
## Related
|
|
69
|
+
|
|
70
|
+
[MastraAuthClerk Class](/docs/auth/clerk.mdx)
|
|
71
|
+
|