@mastra/libsql 1.6.1-alpha.0 → 1.6.2-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.
Files changed (33) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/docs/SKILL.md +50 -0
  3. package/dist/docs/assets/SOURCE_MAP.json +6 -0
  4. package/dist/docs/references/docs-agents-agent-approval.md +558 -0
  5. package/dist/docs/references/docs-agents-agent-memory.md +209 -0
  6. package/dist/docs/references/docs-agents-network-approval.md +275 -0
  7. package/dist/docs/references/docs-agents-networks.md +299 -0
  8. package/dist/docs/references/docs-memory-memory-processors.md +314 -0
  9. package/dist/docs/references/docs-memory-message-history.md +260 -0
  10. package/dist/docs/references/docs-memory-overview.md +45 -0
  11. package/dist/docs/references/docs-memory-semantic-recall.md +272 -0
  12. package/dist/docs/references/docs-memory-storage.md +261 -0
  13. package/dist/docs/references/docs-memory-working-memory.md +400 -0
  14. package/dist/docs/references/docs-observability-overview.md +70 -0
  15. package/dist/docs/references/docs-observability-tracing-exporters-default.md +209 -0
  16. package/dist/docs/references/docs-rag-retrieval.md +515 -0
  17. package/dist/docs/references/docs-workflows-snapshots.md +238 -0
  18. package/dist/docs/references/guides-agent-frameworks-ai-sdk.md +140 -0
  19. package/dist/docs/references/reference-core-getMemory.md +50 -0
  20. package/dist/docs/references/reference-core-listMemory.md +56 -0
  21. package/dist/docs/references/reference-core-mastra-class.md +66 -0
  22. package/dist/docs/references/reference-memory-memory-class.md +147 -0
  23. package/dist/docs/references/reference-storage-composite.md +235 -0
  24. package/dist/docs/references/reference-storage-dynamodb.md +282 -0
  25. package/dist/docs/references/reference-storage-libsql.md +135 -0
  26. package/dist/docs/references/reference-vectors-libsql.md +305 -0
  27. package/dist/index.cjs +14 -3
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.js +14 -3
  30. package/dist/index.js.map +1 -1
  31. package/dist/storage/domains/memory/index.d.ts.map +1 -1
  32. package/dist/vector/index.d.ts.map +1 -1
  33. package/package.json +5 -5
@@ -0,0 +1,70 @@
1
+ # Observability Overview
2
+
3
+ Mastra provides observability features for AI applications. Monitor LLM operations, trace agent decisions, and debug complex workflows with tools that understand AI-specific patterns.
4
+
5
+ ## Key Features
6
+
7
+ ### Tracing
8
+
9
+ Specialized tracing for AI operations that captures:
10
+
11
+ - **Model interactions**: Token usage, latency, prompts, and completions
12
+ - **Agent execution**: Decision paths, tool calls, and memory operations
13
+ - **Workflow steps**: Branching logic, parallel execution, and step outputs
14
+ - **Automatic instrumentation**: Tracing with decorators
15
+
16
+ ## Storage Requirements
17
+
18
+ The `DefaultExporter` persists traces to your configured storage backend. Not all storage providers support observability—for the full list, see [Storage Provider Support](https://mastra.ai/docs/observability/tracing/exporters/default).
19
+
20
+ For production environments with high traffic, we recommend using **ClickHouse** for the observability domain via [composite storage](https://mastra.ai/reference/storage/composite). See [Production Recommendations](https://mastra.ai/docs/observability/tracing/exporters/default) for details.
21
+
22
+ ## Quick Start
23
+
24
+ Configure Observability in your Mastra instance:
25
+
26
+ ```typescript
27
+ import { Mastra } from '@mastra/core'
28
+ import { PinoLogger } from '@mastra/loggers'
29
+ import { LibSQLStore } from '@mastra/libsql'
30
+ import {
31
+ Observability,
32
+ DefaultExporter,
33
+ CloudExporter,
34
+ SensitiveDataFilter,
35
+ } from '@mastra/observability'
36
+
37
+ export const mastra = new Mastra({
38
+ logger: new PinoLogger(),
39
+ storage: new LibSQLStore({
40
+ id: 'mastra-storage',
41
+ url: 'file:./mastra.db', // Storage is required for tracing
42
+ }),
43
+ observability: new Observability({
44
+ configs: {
45
+ default: {
46
+ serviceName: 'mastra',
47
+ exporters: [
48
+ new DefaultExporter(), // Persists traces to storage for Mastra Studio
49
+ new CloudExporter(), // Sends traces to Mastra Cloud (if MASTRA_CLOUD_ACCESS_TOKEN is set)
50
+ ],
51
+ spanOutputProcessors: [
52
+ new SensitiveDataFilter(), // Redacts sensitive data like passwords, tokens, keys
53
+ ],
54
+ },
55
+ },
56
+ }),
57
+ })
58
+ ```
59
+
60
+ > **Serverless environments:** The `file:./mastra.db` storage URL uses the local filesystem, which doesn't work in serverless environments like Vercel, AWS Lambda, or Cloudflare Workers. For serverless deployments, use external storage. See the [Vercel deployment guide](https://mastra.ai/guides/deployment/vercel) for a complete example.
61
+
62
+ With this basic setup, you will see Traces and Logs in both Studio and in Mastra Cloud.
63
+
64
+ We also support various external tracing providers like MLflow, Langfuse, Braintrust, and any OpenTelemetry-compatible platform (Datadog, New Relic, SigNoz, etc.). See more about this in the [Tracing](https://mastra.ai/docs/observability/tracing/overview) documentation.
65
+
66
+ ## What's Next?
67
+
68
+ - **[Set up Tracing](https://mastra.ai/docs/observability/tracing/overview)**: Configure tracing for your application
69
+ - **[Configure Logging](https://mastra.ai/docs/observability/logging)**: Add structured logging
70
+ - **[API Reference](https://mastra.ai/reference/observability/tracing/instances)**: Detailed configuration options
@@ -0,0 +1,209 @@
1
+ # Default Exporter
2
+
3
+ The `DefaultExporter` persists traces to your configured storage backend, making them accessible through Studio. It's automatically enabled when using the default observability configuration and requires no external services.
4
+
5
+ > **Production Observability:** Observability data can quickly overwhelm general-purpose databases in production. For high-traffic applications, we recommend using **ClickHouse** for the observability storage domain via [composite storage](https://mastra.ai/reference/storage/composite). See [Production Recommendations](#production-recommendations) for details.
6
+
7
+ ## Configuration
8
+
9
+ ### Prerequisites
10
+
11
+ 1. **Storage Backend**: Configure a storage provider (libSQL, PostgreSQL, etc.)
12
+ 2. **Studio**: Install for viewing traces locally
13
+
14
+ ### Basic Setup
15
+
16
+ ```typescript
17
+ import { Mastra } from '@mastra/core'
18
+ import { Observability, DefaultExporter } from '@mastra/observability'
19
+ import { LibSQLStore } from '@mastra/libsql'
20
+
21
+ export const mastra = new Mastra({
22
+ storage: new LibSQLStore({
23
+ id: 'mastra-storage',
24
+ url: 'file:./mastra.db', // Required for trace persistence
25
+ }),
26
+ observability: new Observability({
27
+ configs: {
28
+ local: {
29
+ serviceName: 'my-service',
30
+ exporters: [new DefaultExporter()],
31
+ },
32
+ },
33
+ }),
34
+ })
35
+ ```
36
+
37
+ ### Recommended Configuration
38
+
39
+ Include DefaultExporter in your observability configuration:
40
+
41
+ ```typescript
42
+ import { Mastra } from '@mastra/core'
43
+ import {
44
+ Observability,
45
+ DefaultExporter,
46
+ CloudExporter,
47
+ SensitiveDataFilter,
48
+ } from '@mastra/observability'
49
+ import { LibSQLStore } from '@mastra/libsql'
50
+
51
+ export const mastra = new Mastra({
52
+ storage: new LibSQLStore({
53
+ id: 'mastra-storage',
54
+ url: 'file:./mastra.db',
55
+ }),
56
+ observability: new Observability({
57
+ configs: {
58
+ default: {
59
+ serviceName: 'mastra',
60
+ exporters: [
61
+ new DefaultExporter(), // Persists traces to storage for Mastra Studio
62
+ new CloudExporter(), // Sends traces to Mastra Cloud (requires MASTRA_CLOUD_ACCESS_TOKEN)
63
+ ],
64
+ spanOutputProcessors: [new SensitiveDataFilter()],
65
+ },
66
+ },
67
+ }),
68
+ })
69
+ ```
70
+
71
+ ## Viewing Traces
72
+
73
+ ### Studio
74
+
75
+ Access your traces through Studio:
76
+
77
+ 1. Start Studio
78
+ 2. Navigate to Observability
79
+ 3. Filter and search your local traces
80
+ 4. Inspect detailed span information
81
+
82
+ ## Tracing Strategies
83
+
84
+ DefaultExporter automatically selects the optimal tracing strategy based on your storage provider. You can also override this selection if needed.
85
+
86
+ ### Available Strategies
87
+
88
+ | Strategy | Description | Use Case |
89
+ | ---------------------- | --------------------------------------------------------- | ----------------------------------- |
90
+ | **realtime** | Process each event immediately | Development, debugging, low traffic |
91
+ | **batch-with-updates** | Buffer events and batch write with full lifecycle support | Low volume Production |
92
+ | **insert-only** | Only process completed spans, ignore updates | High volume Production |
93
+
94
+ ### Strategy Configuration
95
+
96
+ ```typescript
97
+ new DefaultExporter({
98
+ strategy: 'auto', // Default - let storage provider decide
99
+ // or explicitly set:
100
+ // strategy: 'realtime' | 'batch-with-updates' | 'insert-only'
101
+
102
+ // Batching configuration (applies to both batch-with-updates and insert-only)
103
+ maxBatchSize: 1000, // Max spans per batch
104
+ maxBatchWaitMs: 5000, // Max wait before flushing
105
+ maxBufferSize: 10000, // Max spans to buffer
106
+ })
107
+ ```
108
+
109
+ ## Storage Provider Support
110
+
111
+ Different storage providers support different tracing strategies. Some providers support observability for production workloads, while others are intended primarily for local development.
112
+
113
+ If you set the strategy to `'auto'`, the `DefaultExporter` automatically selects the optimal strategy for the storage provider. If you set the strategy to a mode that the storage provider doesn't support, you will get an error message.
114
+
115
+ ### Providers with Observability Support
116
+
117
+ | Storage Provider | Preferred Strategy | Supported Strategies | Recommended Use |
118
+ | ---------------------------------------------------------------- | ------------------ | ------------------------------- | ------------------------------------- |
119
+ | **ClickHouse** (`@mastra/clickhouse`) | insert-only | insert-only | Production (high-volume) |
120
+ | **[PostgreSQL](https://mastra.ai/reference/storage/postgresql)** | batch-with-updates | batch-with-updates, insert-only | Production (low volume) |
121
+ | **[MSSQL](https://mastra.ai/reference/storage/mssql)** | batch-with-updates | batch-with-updates, insert-only | Production (low volume) |
122
+ | **[MongoDB](https://mastra.ai/reference/storage/mongodb)** | batch-with-updates | batch-with-updates, insert-only | Production (low volume) |
123
+ | **[libSQL](https://mastra.ai/reference/storage/libsql)** | batch-with-updates | batch-with-updates, insert-only | Default storage, good for development |
124
+
125
+ ### Providers without Observability Support
126
+
127
+ The following storage providers **do not support** the observability domain. If you're using one of these providers and need observability, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to a supported provider:
128
+
129
+ - [Convex](https://mastra.ai/reference/storage/convex)
130
+ - [DynamoDB](https://mastra.ai/reference/storage/dynamodb)
131
+ - [Cloudflare D1](https://mastra.ai/reference/storage/cloudflare-d1)
132
+ - [Cloudflare Durable Objects](https://mastra.ai/reference/storage/cloudflare)
133
+ - [Upstash](https://mastra.ai/reference/storage/upstash)
134
+ - [LanceDB](https://mastra.ai/reference/storage/lance)
135
+
136
+ ### Strategy Benefits
137
+
138
+ - **realtime**: Immediate visibility, best for debugging
139
+ - **batch-with-updates**: 10-100x throughput improvement, full span lifecycle
140
+ - **insert-only**: Additional 70% reduction in database operations, perfect for analytics
141
+
142
+ ## Production Recommendations
143
+
144
+ Observability data grows quickly in production environments. A single agent interaction can generate hundreds of spans, and high-traffic applications can produce thousands of traces per day. Most general-purpose databases aren't optimized for this write-heavy, append-only workload.
145
+
146
+ ### Recommended: ClickHouse for High-Volume Production
147
+
148
+ [ClickHouse](https://mastra.ai/reference/storage/composite) is a columnar database designed for high-volume analytics workloads. It's the recommended choice for production observability because:
149
+
150
+ - **Optimized for writes**: Handles millions of inserts per second
151
+ - **Efficient compression**: Reduces storage costs for trace data
152
+ - **Fast queries**: Columnar storage enables quick trace lookups and aggregations
153
+ - **Time-series native**: Built-in support for time-based data retention and partitioning
154
+
155
+ ### Using Composite Storage
156
+
157
+ If you're using a provider without observability support (like Convex or DynamoDB) or want to optimize performance, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to ClickHouse while keeping other data in your primary database.
158
+
159
+ ## Batching Behavior
160
+
161
+ ### Flush Triggers
162
+
163
+ For both batch strategies (`batch-with-updates` and `insert-only`), traces are flushed to storage when any of these conditions are met:
164
+
165
+ 1. **Size trigger**: Buffer reaches `maxBatchSize` spans
166
+ 2. **Time trigger**: `maxBatchWaitMs` elapsed since first event
167
+ 3. **Emergency flush**: Buffer approaches `maxBufferSize` limit
168
+ 4. **Shutdown**: Force flush all pending events
169
+
170
+ ### Error Handling
171
+
172
+ The DefaultExporter includes robust error handling for production use:
173
+
174
+ - **Retry Logic**: Exponential backoff (500ms, 1s, 2s, 4s)
175
+ - **Transient Failures**: Automatic retry with backoff
176
+ - **Persistent Failures**: Drop batch after 4 failed attempts
177
+ - **Buffer Overflow**: Prevent memory issues during storage outages
178
+
179
+ ### Configuration Examples
180
+
181
+ ```typescript
182
+ // Zero config - recommended for most users
183
+ new DefaultExporter()
184
+
185
+ // Development override
186
+ new DefaultExporter({
187
+ strategy: 'realtime', // Immediate visibility for debugging
188
+ })
189
+
190
+ // High-throughput production
191
+ new DefaultExporter({
192
+ maxBatchSize: 2000, // Larger batches
193
+ maxBatchWaitMs: 10000, // Wait longer to fill batches
194
+ maxBufferSize: 50000, // Handle longer outages
195
+ })
196
+
197
+ // Low-latency production
198
+ new DefaultExporter({
199
+ maxBatchSize: 100, // Smaller batches
200
+ maxBatchWaitMs: 1000, // Flush quickly
201
+ })
202
+ ```
203
+
204
+ ## Related
205
+
206
+ - [Tracing Overview](https://mastra.ai/docs/observability/tracing/overview)
207
+ - [CloudExporter](https://mastra.ai/docs/observability/tracing/exporters/cloud)
208
+ - [Composite Storage](https://mastra.ai/reference/storage/composite) - Combine multiple storage providers
209
+ - [Storage Configuration](https://mastra.ai/docs/memory/storage)