@mastra/mcp-docs-server 1.1.35-alpha.6 → 1.1.35
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/course/03-agent-memory/18-advanced-configuration-semantic-recall.md +48 -4
- package/.docs/docs/agents/background-tasks.md +62 -2
- package/.docs/docs/agents/processors.md +9 -1
- package/.docs/docs/agents/response-caching.md +148 -0
- package/.docs/docs/agents/signals.md +151 -0
- package/.docs/docs/agents/using-tools.md +8 -0
- package/.docs/docs/browser/agent-browser.md +15 -0
- package/.docs/docs/browser/stagehand.md +25 -1
- package/.docs/docs/editor/tools.md +1 -1
- package/.docs/docs/index.md +2 -2
- package/.docs/docs/mastra-platform/configuration.md +1 -1
- package/.docs/docs/mastra-platform/overview.md +1 -1
- package/.docs/docs/memory/observational-memory.md +61 -13
- package/.docs/docs/memory/semantic-recall.md +68 -6
- package/.docs/docs/observability/logging.md +2 -2
- package/.docs/docs/observability/metrics/overview.md +4 -4
- package/.docs/docs/observability/overview.md +6 -6
- package/.docs/docs/observability/tracing/bridges/otel.md +25 -0
- package/.docs/docs/observability/tracing/exporters/arize.md +5 -5
- package/.docs/docs/observability/tracing/exporters/braintrust.md +37 -0
- package/.docs/docs/observability/tracing/exporters/langfuse.md +21 -0
- package/.docs/docs/observability/tracing/exporters/{cloud.md → mastra-platform.md} +28 -26
- package/.docs/docs/observability/tracing/exporters/{default.md → mastra-storage.md} +56 -19
- package/.docs/docs/observability/tracing/exporters/otel.md +79 -2
- package/.docs/docs/observability/tracing/overview.md +30 -29
- package/.docs/docs/observability/tracing/processors/sensitive-data-filter.md +6 -6
- package/.docs/docs/server/mastra-server.md +30 -19
- package/.docs/docs/studio/observability.md +4 -4
- package/.docs/docs/studio/overview.md +6 -0
- package/.docs/docs/voice/overview.md +84 -0
- package/.docs/docs/workflows/suspend-and-resume.md +28 -1
- package/.docs/guides/deployment/inngest.md +23 -0
- package/.docs/guides/guide/web-search.md +7 -7
- package/.docs/guides/migrations/mastra-cloud.md +6 -6
- package/.docs/guides/migrations/upgrade-to-v1/tracing.md +19 -17
- package/.docs/models/gateways/azure-openai.md +94 -23
- package/.docs/models/gateways/netlify.md +2 -1
- package/.docs/models/gateways/openrouter.md +4 -1
- package/.docs/models/gateways/vercel.md +2 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/chutes.md +23 -54
- package/.docs/models/providers/databricks.md +96 -0
- package/.docs/models/providers/deepseek.md +3 -1
- package/.docs/models/providers/digitalocean.md +9 -2
- package/.docs/models/providers/firepass.md +71 -0
- package/.docs/models/providers/google.md +3 -2
- package/.docs/models/providers/kilo.md +5 -3
- package/.docs/models/providers/llmgateway.md +7 -1
- package/.docs/models/providers/nebius.md +37 -55
- package/.docs/models/providers/novita-ai.md +5 -5
- package/.docs/models/providers/nvidia.md +59 -49
- package/.docs/models/providers/ollama-cloud.md +1 -1
- package/.docs/models/providers/openai.md +2 -0
- package/.docs/models/providers/opencode.md +44 -43
- package/.docs/models/providers/poe.md +4 -1
- package/.docs/models/providers/sarvam.md +72 -0
- package/.docs/models/providers/wafer.ai.md +2 -1
- package/.docs/models/providers/xiaomi-token-plan-ams.md +6 -5
- package/.docs/models/providers/xiaomi-token-plan-cn.md +6 -5
- package/.docs/models/providers/xiaomi-token-plan-sgp.md +6 -5
- package/.docs/models/providers.md +3 -1
- package/.docs/reference/agents/agent.md +85 -0
- package/.docs/reference/browser/agent-browser.md +37 -11
- package/.docs/reference/browser/stagehand-browser.md +35 -9
- package/.docs/reference/cli/mastra.md +497 -1
- package/.docs/reference/client-js/agents.md +115 -1
- package/.docs/reference/client-js/responses.md +4 -0
- package/.docs/reference/configuration.md +6 -6
- package/.docs/reference/editor/tool-provider.md +3 -3
- package/.docs/reference/harness/harness-class.md +21 -8
- package/.docs/reference/index.md +5 -0
- package/.docs/reference/memory/observational-memory.md +11 -1
- package/.docs/reference/observability/metrics/automatic-metrics.md +2 -4
- package/.docs/reference/observability/tracing/bridges/datadog.md +2 -2
- package/.docs/reference/observability/tracing/bridges/otel.md +26 -4
- package/.docs/reference/observability/tracing/configuration.md +6 -3
- package/.docs/reference/observability/tracing/exporters/arize.md +1 -1
- package/.docs/reference/observability/tracing/exporters/braintrust.md +2 -0
- package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +3 -1
- package/.docs/reference/observability/tracing/exporters/console-exporter.md +2 -2
- package/.docs/reference/observability/tracing/exporters/default-exporter.md +7 -1
- package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +263 -0
- package/.docs/reference/observability/tracing/exporters/mastra-storage-exporter.md +194 -0
- package/.docs/reference/observability/tracing/exporters/otel.md +12 -8
- package/.docs/reference/observability/tracing/instances.md +2 -2
- package/.docs/reference/observability/tracing/interfaces.md +37 -2
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +22 -0
- package/.docs/reference/observability/tracing/span-filtering.md +2 -2
- package/.docs/reference/processors/prefill-error-handler.md +3 -3
- package/.docs/reference/processors/response-cache.md +114 -0
- package/.docs/reference/processors/tool-call-filter.md +28 -0
- package/.docs/reference/storage/clickhouse.md +8 -8
- package/.docs/reference/storage/cloudflare-d1.md +1 -1
- package/.docs/reference/storage/cloudflare.md +1 -1
- package/.docs/reference/storage/composite.md +1 -1
- package/.docs/reference/storage/convex.md +1 -1
- package/.docs/reference/storage/dsql.md +428 -0
- package/.docs/reference/storage/duckdb.md +3 -3
- package/.docs/reference/storage/dynamodb.md +1 -1
- package/.docs/reference/storage/lance.md +1 -1
- package/.docs/reference/storage/libsql.md +1 -1
- package/.docs/reference/storage/postgresql.md +1 -1
- package/.docs/reference/storage/upstash.md +1 -1
- package/.docs/reference/streaming/ChunkType.md +44 -0
- package/.docs/reference/streaming/agents/stream.md +18 -2
- package/.docs/reference/tools/brightdata.md +167 -0
- package/.docs/reference/tools/create-tool.md +46 -0
- package/.docs/reference/voice/inworld.md +133 -0
- package/.docs/reference/workflows/workflow-state-reader.md +113 -0
- package/CHANGELOG.md +113 -0
- package/package.json +6 -6
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
# Aurora DSQL Storage
|
|
2
|
+
|
|
3
|
+
The Aurora DSQL storage implementation provides storage using Amazon Aurora DSQL with IAM authentication.
|
|
4
|
+
|
|
5
|
+
Aurora DSQL does not support PostgreSQL extensions (`CREATE EXTENSION`), including `pgvector`. For vector storage, use a separate vector store such as `@mastra/s3vectors`.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @mastra/dsql@beta
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Prerequisites
|
|
14
|
+
|
|
15
|
+
- Amazon Aurora DSQL cluster
|
|
16
|
+
- AWS credentials with access to the DSQL cluster (IAM authentication)
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { DSQLStore } from '@mastra/dsql'
|
|
22
|
+
|
|
23
|
+
const storage = new DSQLStore({
|
|
24
|
+
id: 'my-dsql-store',
|
|
25
|
+
host: 'abc123.dsql.us-east-1.on.aws',
|
|
26
|
+
// region is auto-detected from host, or specify explicitly:
|
|
27
|
+
// region: 'us-east-1',
|
|
28
|
+
// user: 'admin', // default
|
|
29
|
+
// database: 'postgres', // default
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
// Initialize the store (creates tables if needed)
|
|
33
|
+
await storage.init()
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Parameters
|
|
37
|
+
|
|
38
|
+
**id** (`string`): Unique identifier for this store instance
|
|
39
|
+
|
|
40
|
+
**host** (`string`): DSQL cluster endpoint (e.g., abc123.dsql.us-east-1.on.aws)
|
|
41
|
+
|
|
42
|
+
**pool** (`pg.Pool`): Pre-configured pg.Pool instance. Use this for direct control over the connection pool. Cannot be used with host configuration.
|
|
43
|
+
|
|
44
|
+
**user** (`string`): Database user. Aurora DSQL's admin role is 'admin'.
|
|
45
|
+
|
|
46
|
+
**database** (`string`): Database name. Aurora DSQL exposes a single database named 'postgres' per cluster.
|
|
47
|
+
|
|
48
|
+
**region** (`string`): AWS region. Extracted from host if not provided.
|
|
49
|
+
|
|
50
|
+
**schemaName** (`string`): PostgreSQL schema name where Mastra tables and indexes are created.
|
|
51
|
+
|
|
52
|
+
**customCredentialsProvider** (`AwsCredentialIdentityProvider`): Custom AWS credentials provider for IAM authentication.
|
|
53
|
+
|
|
54
|
+
**max** (`number`): Maximum connections in the pool.
|
|
55
|
+
|
|
56
|
+
**min** (`number`): Minimum connections in the pool.
|
|
57
|
+
|
|
58
|
+
**idleTimeoutMillis** (`number`): Close idle connections after this many milliseconds.
|
|
59
|
+
|
|
60
|
+
**maxLifetimeSeconds** (`number`): Maximum connection lifetime in seconds. Must be less than 3600 due to Aurora DSQL's 60-minute connection limit.
|
|
61
|
+
|
|
62
|
+
**connectionTimeoutMillis** (`number`): Connection acquisition timeout in milliseconds.
|
|
63
|
+
|
|
64
|
+
**allowExitOnIdle** (`boolean`): Allow the process to exit when all connections are idle.
|
|
65
|
+
|
|
66
|
+
## Constructor Examples
|
|
67
|
+
|
|
68
|
+
You can instantiate `DSQLStore` in the following ways:
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { DSQLStore } from '@mastra/dsql'
|
|
72
|
+
|
|
73
|
+
// Basic configuration (region auto-detected from host)
|
|
74
|
+
const store1 = new DSQLStore({
|
|
75
|
+
id: 'my-dsql-store',
|
|
76
|
+
host: 'abc123.dsql.us-east-1.on.aws',
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
// With explicit region and schema
|
|
80
|
+
const store2 = new DSQLStore({
|
|
81
|
+
id: 'my-dsql-store',
|
|
82
|
+
host: 'abc123.dsql.us-east-1.on.aws',
|
|
83
|
+
region: 'us-east-1',
|
|
84
|
+
schemaName: 'my_app',
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
// With custom credentials provider
|
|
88
|
+
import { fromNodeProviderChain } from '@aws-sdk/credential-providers'
|
|
89
|
+
|
|
90
|
+
const store3 = new DSQLStore({
|
|
91
|
+
id: 'my-dsql-store',
|
|
92
|
+
host: 'abc123.dsql.us-east-1.on.aws',
|
|
93
|
+
customCredentialsProvider: fromNodeProviderChain(),
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
// With connection pool settings
|
|
97
|
+
const store4 = new DSQLStore({
|
|
98
|
+
id: 'my-dsql-store',
|
|
99
|
+
host: 'abc123.dsql.us-east-1.on.aws',
|
|
100
|
+
max: 20,
|
|
101
|
+
min: 2,
|
|
102
|
+
idleTimeoutMillis: 300000,
|
|
103
|
+
maxLifetimeSeconds: 3000,
|
|
104
|
+
connectionTimeoutMillis: 10000,
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
// Using a pre-configured pg.Pool
|
|
108
|
+
import { Pool } from 'pg'
|
|
109
|
+
import { AuroraDSQLClient } from '@aws/aurora-dsql-node-postgres-connector'
|
|
110
|
+
|
|
111
|
+
const pool = new Pool({
|
|
112
|
+
host: 'abc123.dsql.us-east-1.on.aws',
|
|
113
|
+
Client: AuroraDSQLClient,
|
|
114
|
+
region: 'us-east-1',
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
const store5 = new DSQLStore({
|
|
118
|
+
id: 'my-dsql-store',
|
|
119
|
+
pool,
|
|
120
|
+
})
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Additional Notes
|
|
124
|
+
|
|
125
|
+
### Schema Management
|
|
126
|
+
|
|
127
|
+
The storage implementation handles schema creation and updates automatically. It creates the following tables:
|
|
128
|
+
|
|
129
|
+
- `mastra_workflow_snapshot`: Stores workflow state and execution data
|
|
130
|
+
- `mastra_threads`: Stores conversation threads
|
|
131
|
+
- `mastra_messages`: Stores individual messages
|
|
132
|
+
- `mastra_ai_spans`: Stores span data for observability
|
|
133
|
+
- `mastra_scorers`: Stores scoring and evaluation data
|
|
134
|
+
- `mastra_resources`: Stores resource working memory data
|
|
135
|
+
- `mastra_agents`: Stores agent data
|
|
136
|
+
|
|
137
|
+
### Initialization
|
|
138
|
+
|
|
139
|
+
When you pass storage to the Mastra class, `init()` is called automatically before any storage operation:
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
import { Mastra } from '@mastra/core'
|
|
143
|
+
import { DSQLStore } from '@mastra/dsql'
|
|
144
|
+
|
|
145
|
+
const storage = new DSQLStore({
|
|
146
|
+
id: 'my-dsql-store',
|
|
147
|
+
host: 'abc123.dsql.us-east-1.on.aws',
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
const mastra = new Mastra({
|
|
151
|
+
storage, // init() is called automatically
|
|
152
|
+
})
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
If you're using storage directly without Mastra, you must call `init()` explicitly to create the tables:
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
import { DSQLStore } from '@mastra/dsql'
|
|
159
|
+
|
|
160
|
+
const storage = new DSQLStore({
|
|
161
|
+
id: 'my-dsql-store',
|
|
162
|
+
host: 'abc123.dsql.us-east-1.on.aws',
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
// Required when using storage directly
|
|
166
|
+
await storage.init()
|
|
167
|
+
|
|
168
|
+
// Access domain-specific stores via getStore()
|
|
169
|
+
const memoryStore = await storage.getStore('memory')
|
|
170
|
+
const thread = await memoryStore?.getThreadById({ threadId: '...' })
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
> **Warning:** If `init()` is not called, tables won't be created and storage operations will fail silently or throw errors.
|
|
174
|
+
|
|
175
|
+
### Direct Database and Pool Access
|
|
176
|
+
|
|
177
|
+
`DSQLStore` exposes both the underlying database client and the pg.Pool instance as public fields:
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
storage.db // Database client for executing queries
|
|
181
|
+
storage.pool // Underlying pg.Pool instance
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
This enables direct queries and custom transaction management. When using these fields:
|
|
185
|
+
|
|
186
|
+
- You are responsible for proper connection and transaction handling.
|
|
187
|
+
- Closing the store (`storage.close()`) will destroy the connection pool if it was created by the store.
|
|
188
|
+
- Direct access bypasses any additional logic or validation provided by DSQLStore methods.
|
|
189
|
+
|
|
190
|
+
This approach is intended for advanced scenarios where low-level access is required.
|
|
191
|
+
|
|
192
|
+
### Aurora DSQL Specifics
|
|
193
|
+
|
|
194
|
+
#### IAM-only authentication
|
|
195
|
+
|
|
196
|
+
Connections are authenticated with IAM. There are no database passwords. `@mastra/dsql` uses `@aws/aurora-dsql-node-postgres-connector` to generate short-lived auth tokens. You can provide a custom credentials provider via `customCredentialsProvider`.
|
|
197
|
+
|
|
198
|
+
#### Single database, schema-based isolation
|
|
199
|
+
|
|
200
|
+
Each cluster exposes a single database named `postgres`. Logical separation is done via schemas. The `schemaName` option controls where Mastra tables are created.
|
|
201
|
+
|
|
202
|
+
#### No PostgreSQL extensions
|
|
203
|
+
|
|
204
|
+
`CREATE EXTENSION` is not supported. This includes `pgvector`, `PostGIS`, and others. For vector storage, use a separate store such as `@mastra/s3vectors` alongside `DSQLStore`.
|
|
205
|
+
|
|
206
|
+
#### JSON stored as text
|
|
207
|
+
|
|
208
|
+
JSON/JSONB are available as query types but not as column types. `@mastra/dsql` stores structured fields (metadata, content, etc.) in `TEXT` columns and casts to JSON at query time.
|
|
209
|
+
|
|
210
|
+
#### Schema and DDL constraints
|
|
211
|
+
|
|
212
|
+
Some PostgreSQL features are not available:
|
|
213
|
+
|
|
214
|
+
- Foreign key constraints
|
|
215
|
+
- `TRUNCATE`
|
|
216
|
+
- Synchronous `CREATE INDEX`
|
|
217
|
+
|
|
218
|
+
Indexes are created asynchronously using `CREATE INDEX ASYNC`. The store's `init()` and index helper APIs respect these constraints.
|
|
219
|
+
|
|
220
|
+
#### Transactions and optimistic concurrency
|
|
221
|
+
|
|
222
|
+
Aurora DSQL uses optimistic concurrency control (OCC) and may return retriable OCC errors under contention. There are limits on transaction duration and size. Large bulk operations should be split into smaller batches at the application level.
|
|
223
|
+
|
|
224
|
+
#### Connection lifetime
|
|
225
|
+
|
|
226
|
+
Individual connections are limited to about 60 minutes. The default `maxLifetimeSeconds: 3300` ensures connections are recycled before hitting this limit.
|
|
227
|
+
|
|
228
|
+
## Usage Example
|
|
229
|
+
|
|
230
|
+
### Adding memory to an agent
|
|
231
|
+
|
|
232
|
+
To add Aurora DSQL memory to an agent use the `Memory` class and create a new `storage` key using `DSQLStore`. The `host` should point to your Aurora DSQL cluster endpoint.
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
import { Memory } from '@mastra/memory'
|
|
236
|
+
import { Agent } from '@mastra/core/agent'
|
|
237
|
+
import { DSQLStore } from '@mastra/dsql'
|
|
238
|
+
|
|
239
|
+
export const dsqlAgent = new Agent({
|
|
240
|
+
id: 'dsql-agent',
|
|
241
|
+
name: 'DSQL Agent',
|
|
242
|
+
instructions:
|
|
243
|
+
'You are an AI agent with the ability to automatically recall memories from previous interactions.',
|
|
244
|
+
model: 'openai/gpt-5.1',
|
|
245
|
+
memory: new Memory({
|
|
246
|
+
storage: new DSQLStore({
|
|
247
|
+
id: 'dsql-agent-storage',
|
|
248
|
+
host: process.env.DSQL_HOST!,
|
|
249
|
+
}),
|
|
250
|
+
options: {
|
|
251
|
+
generateTitle: true, // Explicitly enable automatic title generation
|
|
252
|
+
},
|
|
253
|
+
}),
|
|
254
|
+
})
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Using the agent
|
|
258
|
+
|
|
259
|
+
Use `memoryOptions` to scope recall for this request. Set `lastMessages: 5` to limit recency-based recall, and use `semanticRecall` to fetch the `topK: 3` most relevant messages, including `messageRange: 2` neighboring messages for context around each match.
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
import 'dotenv/config'
|
|
263
|
+
|
|
264
|
+
import { mastra } from './mastra'
|
|
265
|
+
|
|
266
|
+
const threadId = '123'
|
|
267
|
+
const resourceId = 'user-456'
|
|
268
|
+
|
|
269
|
+
const agent = mastra.getAgent('dsql-agent')
|
|
270
|
+
|
|
271
|
+
const message = await agent.stream('My name is Mastra', {
|
|
272
|
+
memory: {
|
|
273
|
+
thread: threadId,
|
|
274
|
+
resource: resourceId,
|
|
275
|
+
},
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
await message.textStream.pipeTo(new WritableStream())
|
|
279
|
+
|
|
280
|
+
const stream = await agent.stream("What's my name?", {
|
|
281
|
+
memory: {
|
|
282
|
+
thread: threadId,
|
|
283
|
+
resource: resourceId,
|
|
284
|
+
},
|
|
285
|
+
memoryOptions: {
|
|
286
|
+
lastMessages: 5,
|
|
287
|
+
semanticRecall: {
|
|
288
|
+
topK: 3,
|
|
289
|
+
messageRange: 2,
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
for await (const chunk of stream.textStream) {
|
|
295
|
+
process.stdout.write(chunk)
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## Index Management
|
|
300
|
+
|
|
301
|
+
Aurora DSQL storage provides index management capabilities to optimize query performance.
|
|
302
|
+
|
|
303
|
+
### Automatic Performance Indexes
|
|
304
|
+
|
|
305
|
+
Aurora DSQL storage automatically creates composite indexes during initialization for common query patterns:
|
|
306
|
+
|
|
307
|
+
- `mastra_threads_resourceid_createdat_idx`: (resourceId, createdAt)
|
|
308
|
+
- `mastra_messages_thread_id_createdat_idx`: (thread\_id, createdAt)
|
|
309
|
+
- `mastra_ai_spans_traceid_startedat_idx`: (traceId, startedAt)
|
|
310
|
+
- `mastra_ai_spans_parentspanid_startedat_idx`: (parentSpanId, startedAt)
|
|
311
|
+
- `mastra_ai_spans_name_idx`: (name)
|
|
312
|
+
- `mastra_ai_spans_spantype_startedat_idx`: (spanType, startedAt)
|
|
313
|
+
- `mastra_scores_trace_id_span_id_created_at_idx`: (traceId, spanId, createdAt)
|
|
314
|
+
|
|
315
|
+
Aurora DSQL creates these indexes asynchronously using `CREATE INDEX ASYNC`. Because index creation is asynchronous, new indexes may not be immediately available after `init()`. The store will continue to function without them, but queries may be slower until index creation completes.
|
|
316
|
+
|
|
317
|
+
### Creating Custom Indexes
|
|
318
|
+
|
|
319
|
+
Create additional indexes to optimize specific query patterns:
|
|
320
|
+
|
|
321
|
+
```typescript
|
|
322
|
+
await storage.createIndex({
|
|
323
|
+
name: 'idx_threads_resource',
|
|
324
|
+
table: 'mastra_threads',
|
|
325
|
+
columns: ['resourceId'],
|
|
326
|
+
})
|
|
327
|
+
|
|
328
|
+
await storage.createIndex({
|
|
329
|
+
name: 'idx_messages_composite',
|
|
330
|
+
table: 'mastra_messages',
|
|
331
|
+
columns: ['thread_id', 'createdAt'],
|
|
332
|
+
})
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Aurora DSQL does not allow `ASC`/`DESC` in `CREATE INDEX ASYNC`. If you include them, they will be automatically stripped.
|
|
336
|
+
|
|
337
|
+
### Index Options
|
|
338
|
+
|
|
339
|
+
**name** (`string`): Unique name for the index
|
|
340
|
+
|
|
341
|
+
**table** (`string`): Table name (e.g., 'mastra\_threads')
|
|
342
|
+
|
|
343
|
+
**columns** (`string[]`): Array of column names. ASC/DESC modifiers are automatically stripped for Aurora DSQL compatibility.
|
|
344
|
+
|
|
345
|
+
**unique** (`boolean`): Create a unique index.
|
|
346
|
+
|
|
347
|
+
**concurrent** (`boolean`): Ignored in Aurora DSQL. Indexes are always created asynchronously.
|
|
348
|
+
|
|
349
|
+
**where** (`string`): Partial index condition.
|
|
350
|
+
|
|
351
|
+
**method** (`string`): Ignored in Aurora DSQL. Only btree indexes are supported.
|
|
352
|
+
|
|
353
|
+
**opclass** (`string`): Ignored in Aurora DSQL.
|
|
354
|
+
|
|
355
|
+
**storage** (`Record<string, any>`): Ignored in Aurora DSQL.
|
|
356
|
+
|
|
357
|
+
**tablespace** (`string`): Ignored in Aurora DSQL. Tablespaces are not supported.
|
|
358
|
+
|
|
359
|
+
### Managing Indexes
|
|
360
|
+
|
|
361
|
+
List and monitor existing indexes:
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
// List all indexes
|
|
365
|
+
const allIndexes = await storage.listIndexes()
|
|
366
|
+
console.log(allIndexes)
|
|
367
|
+
// [
|
|
368
|
+
// {
|
|
369
|
+
// name: 'mastra_threads_pkey',
|
|
370
|
+
// table: 'mastra_threads',
|
|
371
|
+
// columns: ['id'],
|
|
372
|
+
// unique: true,
|
|
373
|
+
// size: '16 KB',
|
|
374
|
+
// definition: 'CREATE UNIQUE INDEX...'
|
|
375
|
+
// },
|
|
376
|
+
// ...
|
|
377
|
+
// ]
|
|
378
|
+
|
|
379
|
+
// List indexes for a specific table
|
|
380
|
+
const threadIndexes = await storage.listIndexes('mastra_threads')
|
|
381
|
+
|
|
382
|
+
// Get detailed statistics for an index
|
|
383
|
+
const stats = await storage.describeIndex('idx_threads_resource')
|
|
384
|
+
console.log(stats)
|
|
385
|
+
// {
|
|
386
|
+
// name: 'idx_threads_resource',
|
|
387
|
+
// table: 'mastra_threads',
|
|
388
|
+
// columns: ['resourceId'],
|
|
389
|
+
// unique: false,
|
|
390
|
+
// size: '128 KB',
|
|
391
|
+
// definition: 'CREATE INDEX idx_threads_resource...',
|
|
392
|
+
// method: 'btree',
|
|
393
|
+
// scans: 1542,
|
|
394
|
+
// tuples_read: 45230,
|
|
395
|
+
// tuples_fetched: 12050
|
|
396
|
+
// }
|
|
397
|
+
|
|
398
|
+
// Drop an index
|
|
399
|
+
await storage.dropIndex('idx_threads_status')
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### Schema-Specific Indexes
|
|
403
|
+
|
|
404
|
+
When using custom schemas, indexes are created with schema prefixes:
|
|
405
|
+
|
|
406
|
+
```typescript
|
|
407
|
+
const storage = new DSQLStore({
|
|
408
|
+
id: 'my-dsql-store',
|
|
409
|
+
host: 'abc123.dsql.us-east-1.on.aws',
|
|
410
|
+
schemaName: 'custom_schema',
|
|
411
|
+
})
|
|
412
|
+
|
|
413
|
+
// Creates index as: custom_schema_idx_threads_status
|
|
414
|
+
await storage.createIndex({
|
|
415
|
+
name: 'idx_threads_status',
|
|
416
|
+
table: 'mastra_threads',
|
|
417
|
+
columns: ['status'],
|
|
418
|
+
})
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
## Related Resources
|
|
422
|
+
|
|
423
|
+
- [Aurora DSQL Documentation](https://docs.aws.amazon.com/aurora-dsql/)
|
|
424
|
+
- [SQL Reference](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/working-with-aurora-dsql-sql.html)
|
|
425
|
+
- [Supported SQL Features](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/working-with-postgresql-compatibility-supported-sql-features.html)
|
|
426
|
+
- [Unsupported PostgreSQL Features](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/working-with-postgresql-compatibility-unsupported-features.html)
|
|
427
|
+
- [Supported Data Types](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/working-with-postgresql-compatibility-supported-data-types.html)
|
|
428
|
+
- [Asynchronous Indexes](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/working-with-create-index-async.html)
|
|
@@ -49,7 +49,7 @@ import { Mastra } from '@mastra/core'
|
|
|
49
49
|
import { MastraCompositeStore } from '@mastra/core/storage'
|
|
50
50
|
import { LibSQLStore } from '@mastra/libsql'
|
|
51
51
|
import { DuckDBStore } from '@mastra/duckdb'
|
|
52
|
-
import { Observability,
|
|
52
|
+
import { Observability, MastraStorageExporter } from '@mastra/observability'
|
|
53
53
|
|
|
54
54
|
export const mastra = new Mastra({
|
|
55
55
|
storage: new MastraCompositeStore({
|
|
@@ -66,7 +66,7 @@ export const mastra = new Mastra({
|
|
|
66
66
|
configs: {
|
|
67
67
|
default: {
|
|
68
68
|
serviceName: 'mastra',
|
|
69
|
-
exporters: [new
|
|
69
|
+
exporters: [new MastraStorageExporter()],
|
|
70
70
|
},
|
|
71
71
|
},
|
|
72
72
|
}),
|
|
@@ -139,7 +139,7 @@ await duckdb.observability.init()
|
|
|
139
139
|
|
|
140
140
|
## Observability strategy
|
|
141
141
|
|
|
142
|
-
DuckDB supports the `event-sourced` strategy used by `
|
|
142
|
+
DuckDB supports the `event-sourced` strategy used by `MastraStorageExporter`, which buffers spans in memory and writes completed events in batches. This is appropriate for development-scale traffic. For high-volume production workloads, see [`MastraStorageExporter` storage provider support](https://mastra.ai/docs/observability/tracing/exporters/mastra-storage).
|
|
143
143
|
|
|
144
144
|
## Related
|
|
145
145
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The DynamoDB storage implementation provides a scalable and performant NoSQL database solution for Mastra, leveraging a single-table design pattern with [ElectroDB](https://electrodb.dev/).
|
|
4
4
|
|
|
5
|
-
> **Observability Not Supported:** DynamoDB storage **doesn't support the observability domain**. Traces from the `
|
|
5
|
+
> **Observability Not Supported:** DynamoDB storage **doesn't support the observability domain**. Traces from the `MastraStorageExporter` can't be persisted to DynamoDB, and [Studio's](https://mastra.ai/docs/studio/overview) observability features won't work with DynamoDB as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to a supported provider like ClickHouse.
|
|
6
6
|
|
|
7
7
|
> **Item Size Limit:** DynamoDB enforces a **400 KB maximum item size**. This limit can be exceeded when storing messages with base64-encoded attachments such as images. See [Handling large attachments](https://mastra.ai/docs/memory/storage) for workarounds including uploading attachments to external storage.
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The LanceDB storage implementation provides a high-performance storage solution using the LanceDB database system, which excels at handling both traditional data storage and vector operations.
|
|
4
4
|
|
|
5
|
-
> **Observability Not Supported:** LanceDB storage **doesn't support the observability domain**. Traces from the `
|
|
5
|
+
> **Observability Not Supported:** LanceDB storage **doesn't support the observability domain**. Traces from the `MastraStorageExporter` can't be persisted to LanceDB, and [Studio's](https://mastra.ai/docs/studio/overview) observability features won't work with LanceDB as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to a supported provider like ClickHouse.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -130,6 +130,6 @@ const thread = await memoryStore?.getThreadById({ threadId: '...' })
|
|
|
130
130
|
|
|
131
131
|
## Observability
|
|
132
132
|
|
|
133
|
-
libSQL supports observability and is ideal for local development. Use the `realtime` [tracing strategy](https://mastra.ai/docs/observability/tracing/exporters/
|
|
133
|
+
libSQL supports observability and is ideal for local development. Use the `realtime` [tracing strategy](https://mastra.ai/docs/observability/tracing/exporters/mastra-storage) for immediate visibility while debugging.
|
|
134
134
|
|
|
135
135
|
For production environments with higher trace volumes, consider using [PostgreSQL](https://mastra.ai/reference/storage/postgresql) or [ClickHouse via composite storage](https://mastra.ai/reference/storage/composite).
|
|
@@ -137,7 +137,7 @@ The storage implementation handles schema creation and updates automatically. It
|
|
|
137
137
|
|
|
138
138
|
PostgreSQL supports observability and can handle low trace volumes. Throughput capacity depends on deployment factors such as hardware, schema design, indexing, and retention policies, and should be validated for your specific environment. For high-volume production environments, consider:
|
|
139
139
|
|
|
140
|
-
- Using the `insert-only` [tracing strategy](https://mastra.ai/docs/observability/tracing/exporters/
|
|
140
|
+
- Using the `insert-only` [tracing strategy](https://mastra.ai/docs/observability/tracing/exporters/mastra-storage) to reduce database write operations
|
|
141
141
|
- Setting up table partitioning for efficient data retention
|
|
142
142
|
- Migrating observability to [ClickHouse via composite storage](https://mastra.ai/reference/storage/composite) if you need to scale further
|
|
143
143
|
|
|
@@ -4,7 +4,7 @@ The Upstash storage implementation provides a serverless-friendly storage soluti
|
|
|
4
4
|
|
|
5
5
|
> **Pricing:** When using Mastra with Upstash, the pay-as-you-go model can result in unexpectedly high costs due to the high volume of Redis commands generated during agent conversations. We strongly recommend using a **fixed pricing plan** for predictable costs. See [Upstash pricing](https://upstash.com/pricing/redis) for details and [GitHub issue #5850](https://github.com/mastra-ai/mastra/issues/5850) for context.
|
|
6
6
|
|
|
7
|
-
> **Observability Not Supported:** Upstash storage **doesn't support the observability domain**. Traces from the `
|
|
7
|
+
> **Observability Not Supported:** Upstash storage **doesn't support the observability domain**. Traces from the `MastraStorageExporter` can't be persisted to Upstash, and [Studio's](https://mastra.ai/docs/studio/overview) observability features won't work with Upstash as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to a supported provider like ClickHouse.
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
@@ -518,6 +518,50 @@ Emitted when the task throws or times out. Triggers a continuation turn when con
|
|
|
518
518
|
|
|
519
519
|
**payload.completedAt** (`Date`): Timestamp at which the task failed
|
|
520
520
|
|
|
521
|
+
### background-task-suspended
|
|
522
|
+
|
|
523
|
+
Emitted when a tool calls `suspend()` from inside its background execution. Pauses the task's workflow run with its snapshot persisted; resume with `mastra.backgroundTaskManager.resume(taskId, resumeData)`.
|
|
524
|
+
|
|
525
|
+
When consumed by [`Agent.streamUntilIdle()`](https://mastra.ai/reference/streaming/agents/streamUntilIdle), this chunk drops the task from the loop's wait set without queuing a continuation — the agent's response ends, and the resumed task's eventual completion injects into the message list for the next user turn.
|
|
526
|
+
|
|
527
|
+
**type** (`"background-task-suspended"`): Chunk type identifier
|
|
528
|
+
|
|
529
|
+
**payload** (`BackgroundTaskSuspendedPayload`): Suspension details for the task
|
|
530
|
+
|
|
531
|
+
**payload.taskId** (`string`): Unique identifier for the background task
|
|
532
|
+
|
|
533
|
+
**payload.toolName** (`string`): Name of the tool that was executed
|
|
534
|
+
|
|
535
|
+
**payload.toolCallId** (`string`): Tool-call ID from the originating LLM tool call
|
|
536
|
+
|
|
537
|
+
**payload.runId** (`string`): Run ID of the agent that dispatched the task
|
|
538
|
+
|
|
539
|
+
**payload.agentId** (`string`): ID of the agent that dispatched the task
|
|
540
|
+
|
|
541
|
+
**payload.suspendData** (`unknown`): Whatever the tool passed to \`suspend(data)\`
|
|
542
|
+
|
|
543
|
+
### background-task-resumed
|
|
544
|
+
|
|
545
|
+
Emitted when a suspended task is resumed via `mastra.backgroundTaskManager.resume(taskId, resumeData)`. The task transitions back to `running` and the tool's `execute` is restarted with `resumeData` populated.
|
|
546
|
+
|
|
547
|
+
**type** (`"background-task-resumed"`): Chunk type identifier
|
|
548
|
+
|
|
549
|
+
**payload** (`BackgroundTaskResumedPayload`): Resume details for the task
|
|
550
|
+
|
|
551
|
+
**payload.taskId** (`string`): Unique identifier for the background task
|
|
552
|
+
|
|
553
|
+
**payload.toolName** (`string`): Name of the tool that was executed
|
|
554
|
+
|
|
555
|
+
**payload.toolCallId** (`string`): Tool-call ID from the originating LLM tool call
|
|
556
|
+
|
|
557
|
+
**payload.runId** (`string`): Run ID of the agent that dispatched the task
|
|
558
|
+
|
|
559
|
+
**payload.agentId** (`string`): ID of the agent that dispatched the task
|
|
560
|
+
|
|
561
|
+
**payload.startedAt** (`Date`): Timestamp at which the task resumed
|
|
562
|
+
|
|
563
|
+
**payload.args** (`Record<string, unknown>`): Original tool arguments
|
|
564
|
+
|
|
521
565
|
### background-task-cancelled
|
|
522
566
|
|
|
523
567
|
Emitted when the task is cancelled before completing. Triggers a continuation turn when consumed by [`Agent.streamUntilIdle()`](https://mastra.ai/reference/streaming/agents/streamUntilIdle).
|
|
@@ -333,9 +333,9 @@ await agent.stream('message for agent', {
|
|
|
333
333
|
})
|
|
334
334
|
```
|
|
335
335
|
|
|
336
|
-
##
|
|
336
|
+
## Responses WebSocket transport
|
|
337
337
|
|
|
338
|
-
Opt into
|
|
338
|
+
Opt into Responses WebSocket streaming with provider options. This only applies to streaming calls and is supported for direct OpenAI models and Azure OpenAI Responses deployments. If WebSocket streaming is unavailable, Mastra falls back to HTTP streaming. By default, Mastra closes the WebSocket when the stream finishes.
|
|
339
339
|
|
|
340
340
|
```ts
|
|
341
341
|
const stream = await agent.stream('Hello', {
|
|
@@ -351,6 +351,20 @@ const stream = await agent.stream('Hello', {
|
|
|
351
351
|
})
|
|
352
352
|
```
|
|
353
353
|
|
|
354
|
+
For Azure OpenAI, configure the gateway with `useResponsesAPI: true`, then use `providerOptions.azure.transport`.
|
|
355
|
+
|
|
356
|
+
```ts
|
|
357
|
+
const stream = await agent.stream('Hello', {
|
|
358
|
+
providerOptions: {
|
|
359
|
+
azure: {
|
|
360
|
+
transport: 'websocket',
|
|
361
|
+
store: false,
|
|
362
|
+
websocket: { closeOnFinish: true },
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
})
|
|
366
|
+
```
|
|
367
|
+
|
|
354
368
|
To keep the connection open after the stream finishes, set `closeOnFinish: false` and close it manually.
|
|
355
369
|
|
|
356
370
|
```ts
|
|
@@ -367,6 +381,8 @@ const stream = await agent.stream('Hello', {
|
|
|
367
381
|
stream.transport?.close()
|
|
368
382
|
```
|
|
369
383
|
|
|
384
|
+
Responses WebSocket connections run one response at a time. Mastra rejects overlapping continuation requests that include `previous_response_id` on the same WebSocket transport. Wait for the active stream to finish before sending the next turn in the response chain.
|
|
385
|
+
|
|
370
386
|
## Related
|
|
371
387
|
|
|
372
388
|
- [Generating responses](https://mastra.ai/docs/agents/overview)
|