@mastra/mcp-docs-server 1.3.7-alpha.1 → 1.3.7-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.
- package/.docs/docs/agents/guardrails.md +2 -2
- package/.docs/docs/auth/fga.md +0 -1
- package/.docs/docs/deployment/workers.md +1 -1
- package/.docs/docs/evals/datasets.md +5 -6
- package/.docs/docs/evals/gates-and-verdicts.md +3 -3
- package/.docs/docs/mastra-platform/deploy.md +8 -1
- package/.docs/docs/mastra-platform/system-environment-variables.md +1 -1
- package/.docs/docs/mastra-platform/trace-intelligence.md +1 -1
- package/.docs/docs/mastra-platform/workspaces.md +2 -2
- package/.docs/docs/memory/multi-user-threads.md +1 -1
- package/.docs/docs/observability/metrics/overview.md +1 -1
- package/.docs/docs/observability/tracing/overview.md +6 -0
- package/.docs/docs/sandbox/computer.md +13 -13
- package/.docs/docs/sandbox/overview.md +5 -5
- package/.docs/docs/server/custom-adapters.md +1 -1
- package/.docs/docs/server/server-adapters.md +1 -1
- package/.docs/docs/studio/auth.md +1 -1
- package/.docs/docs/workflows/control-flow.md +28 -0
- package/.docs/docs/workflows/time-travel.md +1 -1
- package/.docs/integrations/databases/clickhouse.md +13 -0
- package/.docs/integrations/observability/langfuse.md +8 -0
- package/.docs/integrations/observability/opentelemetry.md +2 -0
- package/.docs/models/gateways/vercel.md +1 -8
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/kilo.md +8 -8
- package/.docs/models/providers/llmgateway-providers.md +1 -2
- package/.docs/models/providers/nano-gpt.md +24 -24
- package/.docs/reference/auth/better-auth.md +1 -1
- package/.docs/reference/auth/clerk.md +1 -1
- package/.docs/reference/auth/neon.md +2 -2
- package/.docs/reference/datasets/compareExperiments.md +18 -9
- package/.docs/reference/datasets/dataset.md +3 -1
- package/.docs/reference/datasets/finalizeExperiment.md +2 -2
- package/.docs/reference/datasets/listExperiments.md +2 -2
- package/.docs/reference/datasets/submitExperimentResult.md +1 -1
- package/.docs/reference/editor/tools.md +11 -3
- package/.docs/reference/evals/completeness.md +3 -3
- package/.docs/reference/evals/context-precision.md +1 -1
- package/.docs/reference/evals/create-scorer.md +3 -7
- package/.docs/reference/evals/faithfulness.md +6 -4
- package/.docs/reference/evals/filter-run.md +2 -2
- package/.docs/reference/evals/trajectory-accuracy.md +3 -2
- package/.docs/reference/index.md +0 -1
- package/.docs/reference/memory/listThreads.md +1 -1
- package/.docs/reference/migrations/mcp-v2.md +2 -2
- package/.docs/reference/migrations/upgrade-to-v1/agent.md +1 -1
- package/.docs/reference/migrations/vnext-to-standard-apis.md +1 -1
- package/.docs/reference/observability/feedback.md +1 -1
- package/.docs/reference/observability/metrics/automatic-metrics.md +11 -1
- package/.docs/reference/observability/tracing/interfaces.md +26 -0
- package/.docs/reference/observability/tracing/spans.md +2 -0
- package/.docs/reference/processors/moderation-processor.md +1 -1
- package/.docs/reference/processors/prompt-injection-detector.md +2 -2
- package/.docs/reference/processors/provider-history-compat.md +12 -8
- package/.docs/reference/processors/regex-filter-processor.md +1 -1
- package/.docs/reference/processors/system-prompt-scrubber.md +3 -3
- package/.docs/reference/processors/token-limiter-processor.md +2 -2
- package/.docs/reference/rag/graph-rag.md +1 -1
- package/.docs/reference/server/create-route.md +1 -1
- package/.docs/reference/server/elysia-adapter.md +1 -1
- package/.docs/reference/server/express-adapter.md +1 -1
- package/.docs/reference/server/fastify-adapter.md +1 -1
- package/.docs/reference/server/hono-adapter.md +2 -2
- package/.docs/reference/server/koa-adapter.md +1 -1
- package/.docs/reference/server/nestjs-adapter.md +1 -1
- package/.docs/reference/server/routes.md +1 -1
- package/.docs/reference/storage/composite.md +34 -0
- package/.docs/reference/storage/overview.md +3 -3
- package/.docs/reference/streaming/agents/MastraModelOutput.md +1 -1
- package/.docs/reference/streaming/agents/streamUntilIdle.md +1 -1
- package/.docs/reference/streaming/workflows/timeTravelStream.md +6 -4
- package/.docs/reference/tools/document-chunker-tool.md +8 -8
- package/.docs/reference/tools/mcp-client.md +1 -1
- package/.docs/reference/tools/mcp-server.md +17 -0
- package/.docs/reference/tools/submit-plan-tool.md +2 -0
- package/.docs/reference/tools/vector-query-tool.md +4 -4
- package/.docs/reference/vectors/astra.md +1 -1
- package/.docs/reference/vectors/azure-ai-search.md +1 -0
- package/.docs/reference/vectors/chroma.md +9 -5
- package/.docs/reference/vectors/convex.md +1 -3
- package/.docs/reference/vectors/couchbase.md +4 -9
- package/.docs/reference/vectors/duckdb.md +1 -1
- package/.docs/reference/vectors/libsql.md +1 -1
- package/.docs/reference/vectors/mongodb.md +2 -1
- package/.docs/reference/vectors/pg.md +16 -11
- package/.docs/reference/vectors/pinecone.md +8 -4
- package/.docs/reference/vectors/qdrant.md +8 -4
- package/.docs/reference/vectors/s3vectors.md +8 -4
- package/.docs/reference/vectors/turbopuffer.md +12 -6
- package/.docs/reference/vectors/upstash.md +10 -4
- package/.docs/reference/vectors/vectorize.md +7 -3
- package/.docs/reference/vectors/weaviate.md +1 -1
- package/.docs/reference/voice/composite-voice.md +15 -15
- package/.docs/reference/voice/mastra-voice.md +15 -11
- package/.docs/reference/voice/voice.addInstructions.md +1 -1
- package/.docs/reference/voice/voice.addTools.md +1 -1
- package/.docs/reference/voice/voice.answer.md +1 -1
- package/.docs/reference/voice/voice.close.md +1 -1
- package/.docs/reference/voice/voice.events.md +2 -2
- package/.docs/reference/voice/voice.listen.md +1 -1
- package/.docs/reference/voice/voice.off.md +1 -1
- package/.docs/reference/voice/voice.on.md +1 -1
- package/.docs/reference/voice/voice.send.md +2 -2
- package/.docs/reference/voice/voice.updateConfig.md +1 -1
- package/.docs/reference/workflows/dynamic-workflow-definition.md +3 -2
- package/.docs/reference/workflows/run-methods/cancel.md +1 -2
- package/.docs/reference/workflows/run-methods/resume.md +2 -0
- package/.docs/reference/workflows/run-methods/timeTravel.md +27 -0
- package/.docs/reference/workflows/run.md +14 -0
- package/.docs/reference/workflows/workflow-methods/agent.md +1 -1
- package/.docs/reference/workflows/workflow-methods/branch.md +4 -4
- package/.docs/reference/workflows/workflow-methods/classifier.md +1 -1
- package/.docs/reference/workflows/workflow-methods/create-run.md +2 -2
- package/.docs/reference/workflows/workflow-methods/dountil.md +1 -1
- package/.docs/reference/workflows/workflow-methods/dowhile.md +1 -1
- package/.docs/reference/workflows/workflow-methods/sleepUntil.md +1 -1
- package/.docs/reference/workspace/filesystem.md +10 -13
- package/.docs/reference/workspace/local-filesystem.md +5 -5
- package/.docs/reference/workspace/local-sandbox.md +1 -1
- package/.docs/reference/workspace/process-manager.md +2 -2
- package/.docs/reference/workspace/workspace-class.md +4 -4
- package/package.json +5 -5
- package/.docs/reference/agents/getTools.md +0 -31
|
@@ -121,7 +121,7 @@ Searches for similar vectors with optional metadata filtering.
|
|
|
121
121
|
|
|
122
122
|
**includeVector** (`boolean`): Whether to include vector data in results (Default: `false`)
|
|
123
123
|
|
|
124
|
-
**minScore** (`number`): Minimum similarity score threshold (Default: `
|
|
124
|
+
**minScore** (`number`): Minimum similarity score threshold (cosine similarity ranges from -1 to 1) (Default: `-1`)
|
|
125
125
|
|
|
126
126
|
### `describeIndex()`
|
|
127
127
|
|
|
@@ -352,6 +352,7 @@ interface QueryResult {
|
|
|
352
352
|
score: number
|
|
353
353
|
metadata: Record<string, any>
|
|
354
354
|
vector?: number[] // Only included if includeVector is true
|
|
355
|
+
document?: string // Source text stored with the vector, when available
|
|
355
356
|
}
|
|
356
357
|
```
|
|
357
358
|
|
|
@@ -429,7 +430,7 @@ const results = await store.query({
|
|
|
429
430
|
|
|
430
431
|
**similarity** (`'cosine' | 'dotProduct' | 'euclidean'`): Vector similarity function. Defaults to MongoDB's own default when omitted.
|
|
431
432
|
|
|
432
|
-
**numDimensions** (`
|
|
433
|
+
**numDimensions** (`number`): Length of the generated embeddings. Common values are 256, 512, 1024, and 2048. (Default: `1024`)
|
|
433
434
|
|
|
434
435
|
**quantization** (`'float' | 'scalar' | 'binary' | 'binaryNoRescore'`): Storage format for the generated vectors. (Default: `scalar`)
|
|
435
436
|
|
|
@@ -82,7 +82,9 @@ const vectorStore = new PgVector({
|
|
|
82
82
|
|
|
83
83
|
**dimension** (`number`): Vector dimension (must match your embedding model)
|
|
84
84
|
|
|
85
|
-
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `cosine`)
|
|
85
|
+
**metric** (`'cosine' | 'euclidean' | 'dotproduct' | 'hamming' | 'jaccard'`): Distance metric for similarity search. 'hamming' and 'jaccard' are only valid with vectorType 'bit', and 'jaccard' requires an HNSW index. (Default: `'cosine' ('hamming' when vectorType is 'bit')`)
|
|
86
|
+
|
|
87
|
+
**vectorType** (`'vector' | 'halfvec' | 'bit' | 'sparsevec'`): pgvector storage type for the embeddings (Default: `vector`)
|
|
86
88
|
|
|
87
89
|
**indexConfig** (`IndexConfig`): Index configuration (Default: `{ type: 'ivfflat' }`)
|
|
88
90
|
|
|
@@ -142,13 +144,11 @@ Higher M values or efConstruction values will increase memory requirements subst
|
|
|
142
144
|
|
|
143
145
|
**includeVector** (`boolean`): Whether to include the vector in the result (Default: `false`)
|
|
144
146
|
|
|
145
|
-
**minScore** (`number`): Minimum similarity score threshold (Default: `
|
|
146
|
-
|
|
147
|
-
**options** (`{ ef?: number; probes?: number }`): Additional options for HNSW and IVF indexes
|
|
147
|
+
**minScore** (`number`): Minimum similarity score threshold (Default: `-1`)
|
|
148
148
|
|
|
149
|
-
**
|
|
149
|
+
**ef** (`number`): HNSW search parameter. Higher values improve accuracy at the cost of speed.
|
|
150
150
|
|
|
151
|
-
**
|
|
151
|
+
**probes** (`number`): IVFFlat search parameter. Number of lists to visit during search.
|
|
152
152
|
|
|
153
153
|
### `listIndexes()`
|
|
154
154
|
|
|
@@ -164,8 +164,9 @@ Returns:
|
|
|
164
164
|
interface PGIndexStats {
|
|
165
165
|
dimension: number
|
|
166
166
|
count: number
|
|
167
|
-
metric: 'cosine' | 'euclidean' | 'dotproduct'
|
|
167
|
+
metric: 'cosine' | 'euclidean' | 'dotproduct' | 'hamming' | 'jaccard'
|
|
168
168
|
type: 'flat' | 'hnsw' | 'ivfflat'
|
|
169
|
+
vectorType: 'vector' | 'halfvec' | 'bit' | 'sparsevec'
|
|
169
170
|
config: {
|
|
170
171
|
m?: number
|
|
171
172
|
efConstruction?: number
|
|
@@ -246,7 +247,7 @@ Closes the database connection pool. Should be called when done using the store.
|
|
|
246
247
|
|
|
247
248
|
**indexName** (`string`): Name of the index to define
|
|
248
249
|
|
|
249
|
-
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `cosine`)
|
|
250
|
+
**metric** (`'cosine' | 'euclidean' | 'dotproduct' | 'hamming' | 'jaccard'`): Distance metric for similarity search (Default: `cosine`)
|
|
250
251
|
|
|
251
252
|
**indexConfig** (`IndexConfig`): Configuration for the index type and parameters
|
|
252
253
|
|
|
@@ -291,17 +292,21 @@ interface QueryResult {
|
|
|
291
292
|
|
|
292
293
|
## Error handling
|
|
293
294
|
|
|
294
|
-
The store throws
|
|
295
|
+
The store throws `MastraError` instances from `@mastra/core/error`:
|
|
295
296
|
|
|
296
297
|
```typescript
|
|
298
|
+
import { MastraError } from '@mastra/core/error'
|
|
299
|
+
|
|
297
300
|
try {
|
|
298
301
|
await store.query({
|
|
299
302
|
indexName: 'index_name',
|
|
300
303
|
queryVector: queryVector,
|
|
301
304
|
})
|
|
302
305
|
} catch (error) {
|
|
303
|
-
if (error instanceof
|
|
304
|
-
console.log(error.
|
|
306
|
+
if (error instanceof MastraError) {
|
|
307
|
+
console.log(error.id) // 'MASTRA_VECTOR_PG_QUERY_FAILED'
|
|
308
|
+
console.log(error.domain) // 'MASTRA_VECTOR'
|
|
309
|
+
console.log(error.category) // 'USER' | 'THIRD_PARTY'
|
|
305
310
|
console.log(error.details) // Additional error context
|
|
306
311
|
}
|
|
307
312
|
}
|
|
@@ -130,24 +130,28 @@ Query results are returned in this format:
|
|
|
130
130
|
interface QueryResult {
|
|
131
131
|
id: string
|
|
132
132
|
score: number
|
|
133
|
-
metadata
|
|
133
|
+
metadata?: Record<string, any>
|
|
134
134
|
vector?: number[] // Only included if includeVector is true
|
|
135
135
|
}
|
|
136
136
|
```
|
|
137
137
|
|
|
138
138
|
## Error handling
|
|
139
139
|
|
|
140
|
-
The store throws
|
|
140
|
+
The store throws `MastraError` instances from `@mastra/core/error`:
|
|
141
141
|
|
|
142
142
|
```typescript
|
|
143
|
+
import { MastraError } from '@mastra/core/error'
|
|
144
|
+
|
|
143
145
|
try {
|
|
144
146
|
await store.query({
|
|
145
147
|
indexName: 'index_name',
|
|
146
148
|
queryVector: queryVector,
|
|
147
149
|
})
|
|
148
150
|
} catch (error) {
|
|
149
|
-
if (error instanceof
|
|
150
|
-
console.log(error.
|
|
151
|
+
if (error instanceof MastraError) {
|
|
152
|
+
console.log(error.id) // 'MASTRA_VECTOR_PINECONE_QUERY_FAILED'
|
|
153
|
+
console.log(error.domain) // 'STORAGE'
|
|
154
|
+
console.log(error.category) // 'USER' | 'THIRD_PARTY'
|
|
151
155
|
console.log(error.details) // Additional error context
|
|
152
156
|
}
|
|
153
157
|
}
|
|
@@ -198,24 +198,28 @@ Query results are returned in this format:
|
|
|
198
198
|
interface QueryResult {
|
|
199
199
|
id: string
|
|
200
200
|
score: number
|
|
201
|
-
metadata
|
|
201
|
+
metadata?: Record<string, any>
|
|
202
202
|
vector?: number[] // Only included if includeVector is true
|
|
203
203
|
}
|
|
204
204
|
```
|
|
205
205
|
|
|
206
206
|
## Error handling
|
|
207
207
|
|
|
208
|
-
The store throws
|
|
208
|
+
The store throws `MastraError` instances from `@mastra/core/error`:
|
|
209
209
|
|
|
210
210
|
```typescript
|
|
211
|
+
import { MastraError } from '@mastra/core/error'
|
|
212
|
+
|
|
211
213
|
try {
|
|
212
214
|
await store.query({
|
|
213
215
|
indexName: 'index_name',
|
|
214
216
|
queryVector: queryVector,
|
|
215
217
|
})
|
|
216
218
|
} catch (error) {
|
|
217
|
-
if (error instanceof
|
|
218
|
-
console.log(error.
|
|
219
|
+
if (error instanceof MastraError) {
|
|
220
|
+
console.log(error.id) // 'MASTRA_VECTOR_QDRANT_QUERY_FAILED'
|
|
221
|
+
console.log(error.domain) // 'STORAGE'
|
|
222
|
+
console.log(error.category) // 'USER' | 'THIRD_PARTY'
|
|
219
223
|
console.log(error.details) // Additional error context
|
|
220
224
|
}
|
|
221
225
|
}
|
|
@@ -196,7 +196,7 @@ Query results are returned in this format:
|
|
|
196
196
|
interface QueryResult {
|
|
197
197
|
id: string
|
|
198
198
|
score: number // 1/(1 + distance)
|
|
199
|
-
metadata
|
|
199
|
+
metadata?: Record<string, any>
|
|
200
200
|
vector?: number[] // Only included if includeVector is true
|
|
201
201
|
}
|
|
202
202
|
```
|
|
@@ -244,17 +244,21 @@ S3 Vectors supports a strict subset of operators and value types. The Mastra fil
|
|
|
244
244
|
|
|
245
245
|
## Error handling
|
|
246
246
|
|
|
247
|
-
The store throws
|
|
247
|
+
The store throws `MastraError` instances from `@mastra/core/error`:
|
|
248
248
|
|
|
249
249
|
```typescript
|
|
250
|
+
import { MastraError } from '@mastra/core/error'
|
|
251
|
+
|
|
250
252
|
try {
|
|
251
253
|
await store.query({
|
|
252
254
|
indexName: 'index-name',
|
|
253
255
|
queryVector: queryVector,
|
|
254
256
|
})
|
|
255
257
|
} catch (error) {
|
|
256
|
-
if (error instanceof
|
|
257
|
-
console.log(error.
|
|
258
|
+
if (error instanceof MastraError) {
|
|
259
|
+
console.log(error.id) // 'MASTRA_VECTOR_S3VECTORS_QUERY_FAILED'
|
|
260
|
+
console.log(error.domain) // 'STORAGE'
|
|
261
|
+
console.log(error.category) // 'USER' | 'THIRD_PARTY'
|
|
258
262
|
console.log(error.details) // Additional error context
|
|
259
263
|
}
|
|
260
264
|
}
|
|
@@ -28,11 +28,13 @@ The TurbopufferVector class provides vector search using [Turbopuffer](https://t
|
|
|
28
28
|
|
|
29
29
|
### `createIndex()`
|
|
30
30
|
|
|
31
|
+
Turbopuffer has no explicit create-index operation. `createIndex()` validates the arguments and records the dimension and metric locally; the namespace is created in Turbopuffer on the first `upsert()`.
|
|
32
|
+
|
|
31
33
|
**indexName** (`string`): Name of the index to create
|
|
32
34
|
|
|
33
35
|
**dimension** (`number`): Vector dimension (must match your embedding model)
|
|
34
36
|
|
|
35
|
-
**metric** (`'cosine' | 'euclidean'
|
|
37
|
+
**metric** (`'cosine' | 'euclidean'`): Distance metric for similarity search. 'dotproduct' isn't supported and throws an error. (Default: `cosine`)
|
|
36
38
|
|
|
37
39
|
### `upsert()`
|
|
38
40
|
|
|
@@ -80,7 +82,7 @@ interface IndexStats {
|
|
|
80
82
|
|
|
81
83
|
### `updateVector()`
|
|
82
84
|
|
|
83
|
-
Update a single vector by ID or
|
|
85
|
+
Update a single vector by ID, or every vector that matches a metadata filter. Either `id` or `filter` must be provided, but not both.
|
|
84
86
|
|
|
85
87
|
**indexName** (`string`): Name of the index containing the vector
|
|
86
88
|
|
|
@@ -114,7 +116,7 @@ Query results are returned in this format:
|
|
|
114
116
|
interface QueryResult {
|
|
115
117
|
id: string
|
|
116
118
|
score: number
|
|
117
|
-
metadata
|
|
119
|
+
metadata?: Record<string, any>
|
|
118
120
|
vector?: number[] // Only included if includeVector is true
|
|
119
121
|
}
|
|
120
122
|
```
|
|
@@ -144,17 +146,21 @@ schemaConfigForIndex: (indexName: string) => {
|
|
|
144
146
|
|
|
145
147
|
## Error handling
|
|
146
148
|
|
|
147
|
-
The store throws
|
|
149
|
+
The store throws `MastraError` instances from `@mastra/core/error`:
|
|
148
150
|
|
|
149
151
|
```typescript
|
|
152
|
+
import { MastraError } from '@mastra/core/error'
|
|
153
|
+
|
|
150
154
|
try {
|
|
151
155
|
await store.query({
|
|
152
156
|
indexName: 'index_name',
|
|
153
157
|
queryVector: queryVector,
|
|
154
158
|
})
|
|
155
159
|
} catch (error) {
|
|
156
|
-
if (error instanceof
|
|
157
|
-
console.log(error.
|
|
160
|
+
if (error instanceof MastraError) {
|
|
161
|
+
console.log(error.id) // 'MASTRA_VECTOR_TURBOPUFFER_QUERY_FAILED'
|
|
162
|
+
console.log(error.domain) // 'STORAGE'
|
|
163
|
+
console.log(error.category) // 'USER' | 'THIRD_PARTY'
|
|
158
164
|
console.log(error.details) // Additional error context
|
|
159
165
|
}
|
|
160
166
|
}
|
|
@@ -8,6 +8,8 @@ The UpstashVector class provides vector search using [Upstash Vector](https://up
|
|
|
8
8
|
|
|
9
9
|
## Constructor options
|
|
10
10
|
|
|
11
|
+
**id** (`string`): Unique identifier for this vector store instance
|
|
12
|
+
|
|
11
13
|
**url** (`string`): Upstash Vector database URL
|
|
12
14
|
|
|
13
15
|
**token** (`string`): Upstash Vector API token
|
|
@@ -194,24 +196,28 @@ Query results are returned in this format:
|
|
|
194
196
|
interface QueryResult {
|
|
195
197
|
id: string
|
|
196
198
|
score: number
|
|
197
|
-
metadata
|
|
199
|
+
metadata?: Record<string, any>
|
|
198
200
|
vector?: number[] // Only included if includeVector is true
|
|
199
201
|
}
|
|
200
202
|
```
|
|
201
203
|
|
|
202
204
|
## Error handling
|
|
203
205
|
|
|
204
|
-
The store throws
|
|
206
|
+
The store throws `MastraError` instances from `@mastra/core/error`:
|
|
205
207
|
|
|
206
208
|
```typescript
|
|
209
|
+
import { MastraError } from '@mastra/core/error'
|
|
210
|
+
|
|
207
211
|
try {
|
|
208
212
|
await store.query({
|
|
209
213
|
indexName: 'index_name',
|
|
210
214
|
queryVector: queryVector,
|
|
211
215
|
})
|
|
212
216
|
} catch (error) {
|
|
213
|
-
if (error instanceof
|
|
214
|
-
console.log(error.
|
|
217
|
+
if (error instanceof MastraError) {
|
|
218
|
+
console.log(error.id) // 'MASTRA_VECTOR_UPSTASH_QUERY_FAILED'
|
|
219
|
+
console.log(error.domain) // 'STORAGE'
|
|
220
|
+
console.log(error.category) // 'USER' | 'THIRD_PARTY'
|
|
215
221
|
console.log(error.details) // Additional error context
|
|
216
222
|
}
|
|
217
223
|
}
|
|
@@ -133,17 +133,21 @@ interface QueryResult {
|
|
|
133
133
|
|
|
134
134
|
## Error handling
|
|
135
135
|
|
|
136
|
-
The store throws
|
|
136
|
+
The store throws `MastraError` instances from `@mastra/core/error`:
|
|
137
137
|
|
|
138
138
|
```typescript
|
|
139
|
+
import { MastraError } from '@mastra/core/error'
|
|
140
|
+
|
|
139
141
|
try {
|
|
140
142
|
await store.query({
|
|
141
143
|
indexName: 'index_name',
|
|
142
144
|
queryVector: queryVector,
|
|
143
145
|
})
|
|
144
146
|
} catch (error) {
|
|
145
|
-
if (error instanceof
|
|
146
|
-
console.log(error.
|
|
147
|
+
if (error instanceof MastraError) {
|
|
148
|
+
console.log(error.id) // 'MASTRA_VECTOR_VECTORIZE_QUERY_FAILED'
|
|
149
|
+
console.log(error.domain) // 'STORAGE'
|
|
150
|
+
console.log(error.category) // 'USER' | 'THIRD_PARTY'
|
|
147
151
|
console.log(error.details) // Additional error context
|
|
148
152
|
}
|
|
149
153
|
}
|
|
@@ -50,7 +50,7 @@ The `WeaviateVector` class provides vector search using [Weaviate](https://weavi
|
|
|
50
50
|
|
|
51
51
|
**indexName** (`string`): Name of the index to query.
|
|
52
52
|
|
|
53
|
-
**queryVector** (`number[]`): Query vector to find similar vectors for.
|
|
53
|
+
**queryVector** (`number[]`): Query vector to find similar vectors for. At least one of queryVector or filter must be provided.
|
|
54
54
|
|
|
55
55
|
**topK** (`number`): Number of results to return. (Default: `10`)
|
|
56
56
|
|
|
@@ -10,13 +10,11 @@ CompositeVoice supports both Mastra voice providers and AI SDK model providers
|
|
|
10
10
|
|
|
11
11
|
## Constructor parameters
|
|
12
12
|
|
|
13
|
-
**
|
|
13
|
+
**input** (`MastraVoice | TranscriptionModel`): Voice provider or AI SDK transcription model to use for speech-to-text operations. AI SDK models are automatically wrapped.
|
|
14
14
|
|
|
15
|
-
**
|
|
15
|
+
**output** (`MastraVoice | SpeechModel`): Voice provider or AI SDK speech model to use for text-to-speech operations. AI SDK models are automatically wrapped.
|
|
16
16
|
|
|
17
|
-
**
|
|
18
|
-
|
|
19
|
-
**config.realtime** (`MastraVoice`): Voice provider to use for real-time speech-to-speech operations
|
|
17
|
+
**realtime** (`MastraVoice`): Voice provider to use for real-time speech-to-speech operations
|
|
20
18
|
|
|
21
19
|
## Methods
|
|
22
20
|
|
|
@@ -30,9 +28,10 @@ Converts text to speech using the configured speaking provider.
|
|
|
30
28
|
|
|
31
29
|
Notes:
|
|
32
30
|
|
|
33
|
-
- If
|
|
34
|
-
-
|
|
35
|
-
-
|
|
31
|
+
- If a realtime provider is configured, it handles the call; otherwise the speaking provider is used
|
|
32
|
+
- Throws a `MastraError` only when neither a realtime nor a speaking provider is configured
|
|
33
|
+
- Options are passed through to the provider that handles the call
|
|
34
|
+
- Returns a stream of audio data, or `void` when a realtime provider handles the call
|
|
36
35
|
|
|
37
36
|
### `listen()`
|
|
38
37
|
|
|
@@ -44,13 +43,14 @@ Converts speech to text using the configured listening provider.
|
|
|
44
43
|
|
|
45
44
|
Notes:
|
|
46
45
|
|
|
47
|
-
- If
|
|
48
|
-
-
|
|
49
|
-
-
|
|
46
|
+
- If a realtime provider is configured, it handles the call; otherwise the listening provider is used
|
|
47
|
+
- Throws a `MastraError` only when neither a realtime nor a listening provider is configured
|
|
48
|
+
- Options are passed through to the provider that handles the call
|
|
49
|
+
- Returns a string or a stream of transcribed text, depending on the provider, or `void` when a realtime provider emits results through events
|
|
50
50
|
|
|
51
51
|
### `getSpeakers()`
|
|
52
52
|
|
|
53
|
-
Returns a list of available voices from the speaking provider, where each node contains:
|
|
53
|
+
Returns a list of available voices from the realtime provider, or from the speaking provider when no realtime provider is configured, where each node contains:
|
|
54
54
|
|
|
55
55
|
**voiceId** (`string`): Unique identifier for the voice
|
|
56
56
|
|
|
@@ -58,10 +58,10 @@ Returns a list of available voices from the speaking provider, where each node c
|
|
|
58
58
|
|
|
59
59
|
Notes:
|
|
60
60
|
|
|
61
|
-
- Returns voices from the speaking provider
|
|
62
|
-
-
|
|
61
|
+
- Returns voices from the realtime provider when one is configured, otherwise from the speaking provider
|
|
62
|
+
- Throws a `MastraError` when neither a realtime nor a speaking provider is configured
|
|
63
63
|
- Each voice object will have at least a voiceId property
|
|
64
|
-
- Additional voice properties depend on the
|
|
64
|
+
- Additional voice properties depend on the provider
|
|
65
65
|
|
|
66
66
|
## Usage examples
|
|
67
67
|
|
|
@@ -141,7 +141,7 @@ Converts speech to text using the configured listening model.
|
|
|
141
141
|
|
|
142
142
|
```typescript
|
|
143
143
|
abstract listen(
|
|
144
|
-
audioStream: NodeJS.ReadableStream,
|
|
144
|
+
audioStream: NodeJS.ReadableStream | unknown,
|
|
145
145
|
options?: {
|
|
146
146
|
[key: string]: unknown;
|
|
147
147
|
}
|
|
@@ -150,31 +150,32 @@ abstract listen(
|
|
|
150
150
|
|
|
151
151
|
Purpose:
|
|
152
152
|
|
|
153
|
-
- Takes an audio stream and converts it to text using the provider's speech-to-text service
|
|
153
|
+
- Takes an audio stream (or another provider-specific audio input) and converts it to text using the provider's speech-to-text service
|
|
154
154
|
- Supports provider-specific options for transcription configuration
|
|
155
155
|
- Can return either a complete text transcription or a stream of transcribed text
|
|
156
156
|
- Not all providers support this functionality (e.g., PlayAI, Speechify)
|
|
157
157
|
- May return void if the transcription is handled by emitting 'writing' event
|
|
158
158
|
|
|
159
|
+
## Optional methods
|
|
160
|
+
|
|
161
|
+
These methods have default implementations but can be overridden by voice providers that support speech-to-speech capabilities.
|
|
162
|
+
|
|
159
163
|
### `getSpeakers()`
|
|
160
164
|
|
|
161
165
|
Returns a list of available voices supported by the provider.
|
|
162
166
|
|
|
163
167
|
```typescript
|
|
164
|
-
|
|
168
|
+
getSpeakers(): Promise<Array<{ voiceId: string; [key: string]: unknown }>>
|
|
165
169
|
```
|
|
166
170
|
|
|
167
171
|
Purpose:
|
|
168
172
|
|
|
169
173
|
- Retrieves the list of available voices/speakers from the provider
|
|
174
|
+
- The default implementation returns an empty array; providers override it to list their voices
|
|
170
175
|
- Each voice must have at least a voiceId property
|
|
171
176
|
- Providers can include additional metadata about each voice
|
|
172
177
|
- Used to discover available voices for text-to-speech conversion
|
|
173
178
|
|
|
174
|
-
## Optional methods
|
|
175
|
-
|
|
176
|
-
These methods have default implementations but can be overridden by voice providers that support speech-to-speech capabilities.
|
|
177
|
-
|
|
178
179
|
### `connect()`
|
|
179
180
|
|
|
180
181
|
Establishes a WebSocket or WebRTC connection for communication.
|
|
@@ -210,12 +211,13 @@ Purpose:
|
|
|
210
211
|
Triggers the voice provider to generate a response.
|
|
211
212
|
|
|
212
213
|
```typescript
|
|
213
|
-
answer(): Promise<void>
|
|
214
|
+
answer(options?: Record<string, unknown>): Promise<void>
|
|
214
215
|
```
|
|
215
216
|
|
|
216
217
|
Purpose:
|
|
217
218
|
|
|
218
219
|
- Sends a signal to the voice provider to generate a response
|
|
220
|
+
- Accepts optional provider-specific options
|
|
219
221
|
- Used in real-time conversations to prompt the AI to respond
|
|
220
222
|
- Response will be emitted through the event system (e.g., 'speaking' event)
|
|
221
223
|
|
|
@@ -285,9 +287,11 @@ Purpose:
|
|
|
285
287
|
|
|
286
288
|
The MastraVoice class includes an event system for real-time communication. Standard event types include:
|
|
287
289
|
|
|
288
|
-
**
|
|
290
|
+
**speaker** (`NodeJS.ReadableStream`): Emitted with an audio stream for each new response the voice provider speaks
|
|
291
|
+
|
|
292
|
+
**speaking** (`{ audio?: string }`): Emitted when the voice provider is speaking, contains audio data
|
|
289
293
|
|
|
290
|
-
**writing** (`{ text: string
|
|
294
|
+
**writing** (`{ text: string; role: 'assistant' | 'user' }`): Emitted when text is transcribed from speech
|
|
291
295
|
|
|
292
296
|
**error** (`{ message: string; code?: string; details?: unknown }`): Emitted when an error occurs
|
|
293
297
|
|
|
@@ -308,7 +312,7 @@ MastraVoice includes built-in telemetry support through the `traced` method, whi
|
|
|
308
312
|
## Notes
|
|
309
313
|
|
|
310
314
|
- MastraVoice is an abstract class and can't be instantiated directly
|
|
311
|
-
- Implementations must provide concrete implementations
|
|
315
|
+
- Implementations must provide concrete implementations of the abstract `speak()` and `listen()` methods
|
|
312
316
|
- The class provides a consistent interface across different voice service providers
|
|
313
317
|
- Speech-to-speech capabilities are optional and provider-specific
|
|
314
318
|
- The event system enables asynchronous communication for real-time interactions
|
|
@@ -54,7 +54,7 @@ This method doesn't return a value.
|
|
|
54
54
|
|
|
55
55
|
- Instructions are most effective when they're clear, specific, and relevant to the voice interaction
|
|
56
56
|
- This method is primarily used with real-time voice providers that maintain conversation context
|
|
57
|
-
- If called on a voice provider that doesn't support instructions, it will
|
|
57
|
+
- If called on a voice provider that doesn't support instructions, it will do nothing
|
|
58
58
|
- Instructions added with this method are typically combined with any instructions provided by an associated Agent
|
|
59
59
|
- For best results, add instructions before starting a conversation (before calling `connect()`)
|
|
60
60
|
- Multiple calls to `addInstructions()` may either replace or append to existing instructions, depending on the provider implementation
|
|
@@ -64,7 +64,7 @@ This method doesn't return a value.
|
|
|
64
64
|
|
|
65
65
|
- Tools must follow the Mastra tool format with name, description, input schema, and execute function
|
|
66
66
|
- This method is primarily used with real-time voice providers that support function calling
|
|
67
|
-
- If called on a voice provider that doesn't support tools, it will
|
|
67
|
+
- If called on a voice provider that doesn't support tools, it will do nothing
|
|
68
68
|
- Tools added with this method are typically combined with any tools provided by an associated Agent
|
|
69
69
|
- For best results, add tools before starting a conversation (before calling `connect()`)
|
|
70
70
|
- The voice provider will automatically handle the invocation of tool handlers when the model decides to use them
|
|
@@ -52,7 +52,7 @@ Returns a `Promise<void>` that resolves when the response has been triggered.
|
|
|
52
52
|
## Notes
|
|
53
53
|
|
|
54
54
|
- This method is only implemented by real-time voice providers that support speech-to-speech capabilities
|
|
55
|
-
- If called on a voice provider that doesn't support this functionality, it will log a
|
|
55
|
+
- If called on a voice provider that doesn't support this functionality, it will log a debug message and resolve immediately
|
|
56
56
|
- The response audio will typically be emitted through the 'speaking' event rather than returned directly
|
|
57
57
|
- For providers that support it, you can use this method to send a specific response instead of having the AI generate one
|
|
58
58
|
- This method is commonly used in conjunction with `send()` to create a conversational flow
|
|
@@ -51,5 +51,5 @@ This method doesn't return a value.
|
|
|
51
51
|
- Always call `close()` when you're done with a real-time voice session to free up resources
|
|
52
52
|
- After calling `close()`, you'll need to call `connect()` again if you want to start a new session
|
|
53
53
|
- This method is primarily used with real-time voice providers that maintain persistent connections
|
|
54
|
-
- If called on a voice provider that doesn't support real-time connections, it will log a
|
|
54
|
+
- If called on a voice provider that doesn't support real-time connections, it will log a debug message and do nothing
|
|
55
55
|
- Failing to close connections can lead to resource leaks and potential billing issues with voice service providers
|
|
@@ -10,7 +10,7 @@ Voice providers emit events during real-time voice interactions. These events ca
|
|
|
10
10
|
|
|
11
11
|
These events are commonly implemented across real-time voice providers:
|
|
12
12
|
|
|
13
|
-
**error** (`
|
|
13
|
+
**error** (`{ message: string; code?: string; details?: unknown }`): Emitted when an error occurs during voice processing or when audio data format is unsupported
|
|
14
14
|
|
|
15
15
|
**session.created** (`object`): Emitted when a new session is created with the OpenAI service
|
|
16
16
|
|
|
@@ -20,7 +20,7 @@ These events are commonly implemented across real-time voice providers:
|
|
|
20
20
|
|
|
21
21
|
**response.done** (`object`): Emitted when the AI assistant has completed its response
|
|
22
22
|
|
|
23
|
-
**speaker** (`
|
|
23
|
+
**speaker** (`NodeJS.ReadableStream`): Emitted with a new audio stream that can be piped to an audio output. Some realtime providers attach an id property to the stream
|
|
24
24
|
|
|
25
25
|
**writing** (`object`): Emitted when text is being transcribed (user) or generated (assistant)
|
|
26
26
|
|
|
@@ -8,7 +8,7 @@ The `listen()` method is a core function available in all Mastra voice providers
|
|
|
8
8
|
|
|
9
9
|
## Parameters
|
|
10
10
|
|
|
11
|
-
**audioStream** (`NodeJS.ReadableStream`): Audio
|
|
11
|
+
**audioStream** (`NodeJS.ReadableStream | unknown`): Audio to transcribe. This is usually a file stream or a microphone stream; some realtime providers accept other audio input types.
|
|
12
12
|
|
|
13
13
|
**options** (`object`): Provider-specific options for speech recognition
|
|
14
14
|
|
|
@@ -54,5 +54,5 @@ This method doesn't return a value.
|
|
|
54
54
|
- The callback passed to `off()` must be the same function reference that was passed to `on()`
|
|
55
55
|
- If the callback isn't found, the method will have no effect
|
|
56
56
|
- This method is primarily used with real-time voice providers that support event-based communication
|
|
57
|
-
- If called on a voice provider that doesn't support events, it will log a
|
|
57
|
+
- If called on a voice provider that doesn't support events, it will log a debug message and do nothing
|
|
58
58
|
- Removing event listeners is important for preventing memory leaks in long-running applications
|
|
@@ -107,7 +107,7 @@ voice.on('speaker', stream => {
|
|
|
107
107
|
## Notes
|
|
108
108
|
|
|
109
109
|
- This method is primarily used with real-time voice providers that support event-based communication
|
|
110
|
-
- If called on a voice provider that doesn't support events, it will log a
|
|
110
|
+
- If called on a voice provider that doesn't support events, it will log a debug message and do nothing
|
|
111
111
|
- Event listeners should be registered before calling methods that might emit events
|
|
112
112
|
- To remove an event listener, use the [voice.off()](https://mastra.ai/reference/voice/voice.off) method with the same event name and callback function
|
|
113
113
|
- Multiple listeners can be registered for the same event
|
|
@@ -56,12 +56,12 @@ await voice.send(audioBuffer)
|
|
|
56
56
|
|
|
57
57
|
## Return value
|
|
58
58
|
|
|
59
|
-
Returns a `Promise<void
|
|
59
|
+
Returns a `Promise<void>`. For providers that support real-time audio, it resolves when the provider has accepted the audio data. The default implementation sends nothing and resolves immediately.
|
|
60
60
|
|
|
61
61
|
## Notes
|
|
62
62
|
|
|
63
63
|
- This method is only implemented by real-time voice providers that support speech-to-speech capabilities
|
|
64
|
-
- If called on a voice provider that doesn't support this functionality, it will log a
|
|
64
|
+
- If called on a voice provider that doesn't support this functionality, it will log a debug message and resolve immediately
|
|
65
65
|
- You must call `connect()` before using `send()` to establish the WebSocket connection
|
|
66
66
|
- The audio format requirements depend on the specific voice provider
|
|
67
67
|
- For continuous conversation, you typically call `send()` to transmit user audio, then `answer()` to trigger the AI response
|
|
@@ -57,7 +57,7 @@ Different voice providers support different configuration options:
|
|
|
57
57
|
|
|
58
58
|
## Notes
|
|
59
59
|
|
|
60
|
-
- The default implementation logs a
|
|
60
|
+
- The default implementation logs a debug message if the provider doesn't support this method
|
|
61
61
|
- Configuration updates are typically applied to subsequent operations, not ongoing ones
|
|
62
62
|
- Not all properties that can be set in the constructor can be updated at runtime
|
|
63
63
|
- The specific behavior depends on the voice provider implementation
|
|
@@ -128,18 +128,19 @@ Add an `outputSchema` to request structured output from the agent:
|
|
|
128
128
|
|
|
129
129
|
Use a `mapping` entry before an agent to build its `{ prompt }` input from workflow data.
|
|
130
130
|
|
|
131
|
-
Agent entries accept an
|
|
131
|
+
Agent entries accept an `options` object:
|
|
132
132
|
|
|
133
133
|
```json
|
|
134
134
|
{
|
|
135
135
|
"type": "agent",
|
|
136
136
|
"id": "summarize",
|
|
137
137
|
"agentId": "support-agent",
|
|
138
|
-
"description": "Summarize the incoming request",
|
|
139
138
|
"options": { "retries": 2, "metadata": { "team": "support" } }
|
|
140
139
|
}
|
|
141
140
|
```
|
|
142
141
|
|
|
142
|
+
The step description comes from the registered agent. A `description` set on the agent entry is ignored when the workflow is rehydrated.
|
|
143
|
+
|
|
143
144
|
Only `retries` and `metadata` persist. Function-valued options such as `onFinish` and function-valued `toolChoice` are rejected when a code-defined workflow is stored. Other agent call options don't persist.
|
|
144
145
|
|
|
145
146
|
### Classifier steps
|
|
@@ -14,7 +14,6 @@ This method aborts any running steps and updates the workflow status to 'cancele
|
|
|
14
14
|
const run = await workflow.createRun()
|
|
15
15
|
|
|
16
16
|
await run.cancel()
|
|
17
|
-
// Returns: { message: 'Workflow run canceled' }
|
|
18
17
|
```
|
|
19
18
|
|
|
20
19
|
## Parameters
|
|
@@ -23,7 +22,7 @@ await run.cancel()
|
|
|
23
22
|
|
|
24
23
|
## Returns
|
|
25
24
|
|
|
26
|
-
**result** (`Promise<
|
|
25
|
+
**result** (`Promise<void>`): A promise that resolves once cancellation is requested and, if storage is configured, the status update to canceled has been attempted. It does not wait for running steps to stop. Calling cancel() on a run that already finished leaves its status unchanged, except with the Inngest engine.
|
|
27
26
|
|
|
28
27
|
## How cancellation works
|
|
29
28
|
|