@mastra/mcp-docs-server 1.2.5-alpha.3 → 1.2.5-alpha.6
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/agent-approval.md +2 -0
- package/.docs/docs/long-running-agents/schedules.md +227 -0
- package/.docs/docs/observability/feedback.md +136 -0
- package/.docs/docs/observability/overview.md +8 -4
- package/.docs/docs/workflows/scheduled-workflows.md +5 -4
- package/.docs/guides/build-your-ui/openui.md +12 -20
- package/.docs/models/environment-variables.md +1 -0
- package/.docs/models/gateways/vercel.md +1 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/anthropic.md +3 -9
- package/.docs/models/providers/deepinfra.md +17 -4
- package/.docs/models/providers/digitalocean.md +3 -1
- package/.docs/models/providers/longcat.md +73 -0
- package/.docs/models/providers/mistral.md +1 -1
- package/.docs/models/providers/nvidia.md +3 -2
- package/.docs/models/providers/stackit.md +6 -6
- package/.docs/models/providers.md +1 -0
- package/.docs/reference/client-js/observability.md +88 -1
- package/.docs/reference/index.md +1 -0
- package/.docs/reference/observability/feedback.md +391 -0
- package/.docs/reference/workflows/workflow.md +2 -0
- package/CHANGELOG.md +14 -0
- package/package.json +4 -4
- package/.docs/docs/long-running-agents/heartbeats.md +0 -213
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# DigitalOcean
|
|
4
4
|
|
|
5
|
-
Access
|
|
5
|
+
Access 77 DigitalOcean models through Mastra's model router. Authentication is handled automatically using the `DIGITALOCEAN_ACCESS_TOKEN` environment variable.
|
|
6
6
|
|
|
7
7
|
Learn more in the [DigitalOcean documentation](https://docs.digitalocean.com/products/gradient-ai-platform/details/models/).
|
|
8
8
|
|
|
@@ -65,6 +65,8 @@ for await (const chunk of stream) {
|
|
|
65
65
|
| `digitalocean/fal-ai/stable-audio-25/text-to-audio` | — | | | | | | — | — |
|
|
66
66
|
| `digitalocean/gemma-4-31B-it` | 256K | | | | | | $0.18 | $0.50 |
|
|
67
67
|
| `digitalocean/glm-5` | 203K | | | | | | $1 | $3 |
|
|
68
|
+
| `digitalocean/glm-5.1` | 200K | | | | | | $0.97 | $4 |
|
|
69
|
+
| `digitalocean/glm-5.2` | 1.0M | | | | | | $1 | $4 |
|
|
68
70
|
| `digitalocean/gte-large-en-v1.5` | 8K | | | | | | $0.09 | — |
|
|
69
71
|
| `digitalocean/kimi-k2.5` | 262K | | | | | | $0.50 | $3 |
|
|
70
72
|
| `digitalocean/kimi-k2.6` | 262K | | | | | | $0.95 | $4 |
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# LongCat
|
|
4
|
+
|
|
5
|
+
Access 1 LongCat model through Mastra's model router. Authentication is handled automatically using the `LONGCAT_API_KEY` environment variable.
|
|
6
|
+
|
|
7
|
+
Learn more in the [LongCat documentation](https://longcat.chat/platform/docs/).
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
LONGCAT_API_KEY=your-api-key
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Agent } from "@mastra/core/agent";
|
|
15
|
+
|
|
16
|
+
const agent = new Agent({
|
|
17
|
+
id: "my-agent",
|
|
18
|
+
name: "My Agent",
|
|
19
|
+
instructions: "You are a helpful assistant",
|
|
20
|
+
model: "longcat/LongCat-2.0"
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Generate a response
|
|
24
|
+
const response = await agent.generate("Hello!");
|
|
25
|
+
|
|
26
|
+
// Stream a response
|
|
27
|
+
const stream = await agent.stream("Tell me a story");
|
|
28
|
+
for await (const chunk of stream) {
|
|
29
|
+
console.log(chunk);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
> **Info:** Mastra uses the OpenAI-compatible `/chat/completions` endpoint. Some provider-specific features may not be available. Check the [LongCat documentation](https://longcat.chat/platform/docs/) for details.
|
|
34
|
+
|
|
35
|
+
## Models
|
|
36
|
+
|
|
37
|
+
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
38
|
+
| --------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
39
|
+
| `longcat/LongCat-2.0` | 1.0M | | | | | | $0.75 | $3 |
|
|
40
|
+
|
|
41
|
+
## Advanced configuration
|
|
42
|
+
|
|
43
|
+
### Custom headers
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
const agent = new Agent({
|
|
47
|
+
id: "custom-agent",
|
|
48
|
+
name: "custom-agent",
|
|
49
|
+
model: {
|
|
50
|
+
url: "https://api.longcat.chat/openai",
|
|
51
|
+
id: "longcat/LongCat-2.0",
|
|
52
|
+
apiKey: process.env.LONGCAT_API_KEY,
|
|
53
|
+
headers: {
|
|
54
|
+
"X-Custom-Header": "value"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Dynamic model selection
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
const agent = new Agent({
|
|
64
|
+
id: "dynamic-agent",
|
|
65
|
+
name: "Dynamic Agent",
|
|
66
|
+
model: ({ requestContext }) => {
|
|
67
|
+
const useAdvanced = requestContext.task === "complex";
|
|
68
|
+
return useAdvanced
|
|
69
|
+
? "longcat/LongCat-2.0"
|
|
70
|
+
: "longcat/LongCat-2.0";
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
```
|
|
@@ -46,7 +46,7 @@ for await (const chunk of stream) {
|
|
|
46
46
|
| `mistral/mistral-medium-2505` | 131K | | | | | | $0.40 | $2 |
|
|
47
47
|
| `mistral/mistral-medium-2508` | 262K | | | | | | $0.40 | $2 |
|
|
48
48
|
| `mistral/mistral-medium-2604` | 262K | | | | | | $2 | $8 |
|
|
49
|
-
| `mistral/mistral-medium-latest` | 262K | | | | | | $
|
|
49
|
+
| `mistral/mistral-medium-latest` | 262K | | | | | | $2 | $8 |
|
|
50
50
|
| `mistral/mistral-nemo` | 128K | | | | | | $0.15 | $0.15 |
|
|
51
51
|
| `mistral/mistral-small-2506` | 128K | | | | | | $0.10 | $0.30 |
|
|
52
52
|
| `mistral/mistral-small-2603` | 256K | | | | | | $0.15 | $0.60 |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Nvidia
|
|
4
4
|
|
|
5
|
-
Access
|
|
5
|
+
Access 84 Nvidia models through Mastra's model router. Authentication is handled automatically using the `NVIDIA_API_KEY` environment variable.
|
|
6
6
|
|
|
7
7
|
Learn more in the [Nvidia documentation](https://docs.api.nvidia.com/nim/).
|
|
8
8
|
|
|
@@ -119,6 +119,7 @@ for await (const chunk of stream) {
|
|
|
119
119
|
| `nvidia/stepfun-ai/step-3.5-flash` | 256K | | | | | | — | — |
|
|
120
120
|
| `nvidia/stepfun-ai/step-3.7-flash` | 256K | | | | | | — | — |
|
|
121
121
|
| `nvidia/upstage/solar-10_7b-instruct` | 128K | | | | | | — | — |
|
|
122
|
+
| `nvidia/z-ai/glm-5.2` | 1.0M | | | | | | — | — |
|
|
122
123
|
|
|
123
124
|
## Advanced configuration
|
|
124
125
|
|
|
@@ -148,7 +149,7 @@ const agent = new Agent({
|
|
|
148
149
|
model: ({ requestContext }) => {
|
|
149
150
|
const useAdvanced = requestContext.task === "complex";
|
|
150
151
|
return useAdvanced
|
|
151
|
-
? "nvidia/
|
|
152
|
+
? "nvidia/z-ai/glm-5.2"
|
|
152
153
|
: "nvidia/abacusai/dracarys-llama-3_1-70b-instruct";
|
|
153
154
|
}
|
|
154
155
|
});
|
|
@@ -36,14 +36,14 @@ for await (const chunk of stream) {
|
|
|
36
36
|
|
|
37
37
|
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|
|
38
38
|
| ---------------------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
39
|
-
| `stackit/cortecs/Llama-3.3-70B-Instruct-FP8-Dynamic` | 128K | | | | | | $0.
|
|
40
|
-
| `stackit/google/gemma-3-27b-it` | 37K | | | | | | $0.
|
|
39
|
+
| `stackit/cortecs/Llama-3.3-70B-Instruct-FP8-Dynamic` | 128K | | | | | | $0.53 | $0.76 |
|
|
40
|
+
| `stackit/google/gemma-3-27b-it` | 37K | | | | | | $0.53 | $0.76 |
|
|
41
41
|
| `stackit/intfloat/e5-mistral-7b-instruct` | 4K | | | | | | $0.02 | $0.02 |
|
|
42
|
-
| `stackit/
|
|
43
|
-
| `stackit/
|
|
44
|
-
| `stackit/openai/gpt-oss-120b` | 131K | | | | | | $0.49 | $0.71 |
|
|
42
|
+
| `stackit/openai/gpt-oss-120b` | 131K | | | | | | $0.53 | $0.76 |
|
|
43
|
+
| `stackit/openai/gpt-oss-20b` | 131K | | | | | | $0.18 | $0.29 |
|
|
45
44
|
| `stackit/Qwen/Qwen3-VL-235B-A22B-Instruct-FP8` | 218K | | | | | | $2 | $2 |
|
|
46
45
|
| `stackit/Qwen/Qwen3-VL-Embedding-8B` | 32K | | | | | | $0.09 | $0.09 |
|
|
46
|
+
| `stackit/Qwen/Qwen3.6-27B` | 262K | | | | | | $0.53 | $0.76 |
|
|
47
47
|
|
|
48
48
|
## Advanced configuration
|
|
49
49
|
|
|
@@ -73,7 +73,7 @@ const agent = new Agent({
|
|
|
73
73
|
model: ({ requestContext }) => {
|
|
74
74
|
const useAdvanced = requestContext.task === "complex";
|
|
75
75
|
return useAdvanced
|
|
76
|
-
? "stackit/openai/gpt-oss-
|
|
76
|
+
? "stackit/openai/gpt-oss-20b"
|
|
77
77
|
: "stackit/Qwen/Qwen3-VL-235B-A22B-Instruct-FP8";
|
|
78
78
|
}
|
|
79
79
|
});
|
|
@@ -66,6 +66,7 @@ Direct access to individual AI model providers. Each provider offers unique mode
|
|
|
66
66
|
- [LLM Gateway](https://mastra.ai/models/providers/llmgateway)
|
|
67
67
|
- [LLMTR](https://mastra.ai/models/providers/llmtr)
|
|
68
68
|
- [LMStudio](https://mastra.ai/models/providers/lmstudio)
|
|
69
|
+
- [LongCat](https://mastra.ai/models/providers/longcat)
|
|
69
70
|
- [LucidQuery](https://mastra.ai/models/providers/lucidquery)
|
|
70
71
|
- [Meganova](https://mastra.ai/models/providers/meganova)
|
|
71
72
|
- [MiniMax (minimax.io)](https://mastra.ai/models/providers/minimax)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Observability API
|
|
4
4
|
|
|
5
|
-
The Observability API provides methods to retrieve traces, monitor
|
|
5
|
+
The Observability API provides methods to retrieve traces, monitor application performance, score traces for evaluation, and record feedback linked to traces and spans.
|
|
6
6
|
|
|
7
7
|
## Getting a specific trace
|
|
8
8
|
|
|
@@ -68,7 +68,94 @@ const scores = await mastraClient.listScoresBySpan({
|
|
|
68
68
|
})
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
+
## Feedback
|
|
72
|
+
|
|
73
|
+
Feedback methods create, list, and query human-in-the-loop signals such as ratings, thumbs, comments, and corrections. See the [feedback guide](https://mastra.ai/docs/observability/feedback) for examples and the [feedback reference](https://mastra.ai/reference/observability/feedback) for full schemas.
|
|
74
|
+
|
|
75
|
+
### Creating feedback
|
|
76
|
+
|
|
77
|
+
Create a feedback record linked to a trace or span:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
const response = await mastraClient.createFeedback({
|
|
81
|
+
feedback: {
|
|
82
|
+
traceId: 'trace-123',
|
|
83
|
+
spanId: 'span-456',
|
|
84
|
+
feedbackSource: 'user',
|
|
85
|
+
feedbackType: 'rating',
|
|
86
|
+
value: 1,
|
|
87
|
+
comment: 'Helpful answer.',
|
|
88
|
+
},
|
|
89
|
+
})
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Listing feedback
|
|
93
|
+
|
|
94
|
+
Retrieve paginated feedback records with optional filters:
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
const feedback = await mastraClient.listFeedback({
|
|
98
|
+
filters: {
|
|
99
|
+
feedbackType: 'rating',
|
|
100
|
+
feedbackSource: 'studio',
|
|
101
|
+
},
|
|
102
|
+
pagination: { page: 0, perPage: 20 },
|
|
103
|
+
orderBy: { field: 'timestamp', direction: 'DESC' },
|
|
104
|
+
})
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Aggregating feedback
|
|
108
|
+
|
|
109
|
+
Aggregate numeric feedback values, such as ratings or thumbs encoded as `1` and `-1`:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
const averageRating = await mastraClient.getFeedbackAggregate({
|
|
113
|
+
feedbackType: 'rating',
|
|
114
|
+
aggregation: 'avg',
|
|
115
|
+
comparePeriod: 'previous_day',
|
|
116
|
+
})
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Grouping feedback
|
|
120
|
+
|
|
121
|
+
Group numeric feedback by observability dimensions:
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
const ratingsByAgent = await mastraClient.getFeedbackBreakdown({
|
|
125
|
+
feedbackType: 'rating',
|
|
126
|
+
groupBy: ['entityName'],
|
|
127
|
+
aggregation: 'avg',
|
|
128
|
+
})
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Querying feedback over time
|
|
132
|
+
|
|
133
|
+
Bucket numeric feedback by interval:
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
const ratingsOverTime = await mastraClient.getFeedbackTimeSeries({
|
|
137
|
+
feedbackType: 'rating',
|
|
138
|
+
interval: '1h',
|
|
139
|
+
aggregation: 'avg',
|
|
140
|
+
groupBy: ['feedbackSource'],
|
|
141
|
+
})
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Querying feedback percentiles
|
|
145
|
+
|
|
146
|
+
Return percentile series for numeric feedback values:
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
const ratingPercentiles = await mastraClient.getFeedbackPercentiles({
|
|
150
|
+
feedbackType: 'rating',
|
|
151
|
+
percentiles: [0.5, 0.95],
|
|
152
|
+
interval: '1d',
|
|
153
|
+
})
|
|
154
|
+
```
|
|
155
|
+
|
|
71
156
|
## Related
|
|
72
157
|
|
|
158
|
+
- [Feedback guide](https://mastra.ai/docs/observability/feedback): Learn how to create, list, and query feedback
|
|
159
|
+
- [Feedback reference](https://mastra.ai/reference/observability/feedback): Review feedback schemas and HTTP routes
|
|
73
160
|
- [Agents API](https://mastra.ai/reference/client-js/agents): Learn about agent interactions that generate traces
|
|
74
161
|
- [Workflows API](https://mastra.ai/reference/client-js/workflows): Understand workflow execution monitoring
|
package/.docs/reference/index.md
CHANGED
|
@@ -185,6 +185,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
185
185
|
- [.getThreadById()](https://mastra.ai/reference/memory/getThreadById)
|
|
186
186
|
- [.listThreads()](https://mastra.ai/reference/memory/listThreads)
|
|
187
187
|
- [.recall()](https://mastra.ai/reference/memory/recall)
|
|
188
|
+
- [Feedback](https://mastra.ai/reference/observability/feedback)
|
|
188
189
|
- [PinoLogger](https://mastra.ai/reference/logging/pino-logger)
|
|
189
190
|
- [Automatic Metrics](https://mastra.ai/reference/observability/metrics/automatic-metrics)
|
|
190
191
|
- [Configuration](https://mastra.ai/reference/observability/tracing/configuration)
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Feedback
|
|
4
|
+
|
|
5
|
+
**Added in:** `@mastra/core@1.18.0`
|
|
6
|
+
|
|
7
|
+
Feedback APIs store and query human-in-the-loop observability signals such as ratings, thumbs, comments, and corrections. Use the [feedback guide](https://mastra.ai/docs/observability/feedback) for usage patterns.
|
|
8
|
+
|
|
9
|
+
## Usage example
|
|
10
|
+
|
|
11
|
+
The following example records a rating for a persisted trace through the observability entrypoint. `addFeedback()` is optional on the entrypoint, so check that the active observability implementation supports it before calling it.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
if (!mastra.observability.addFeedback) {
|
|
15
|
+
throw new Error('Feedback is not supported by the active observability implementation')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
await mastra.observability.addFeedback({
|
|
19
|
+
traceId: 'trace-123',
|
|
20
|
+
spanId: 'span-456',
|
|
21
|
+
feedback: {
|
|
22
|
+
feedbackSource: 'user',
|
|
23
|
+
feedbackType: 'rating',
|
|
24
|
+
value: 1,
|
|
25
|
+
comment: 'Helpful answer.',
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Create feedback
|
|
31
|
+
|
|
32
|
+
### `addFeedback(args)`
|
|
33
|
+
|
|
34
|
+
Adds feedback to a persisted trace or span through the observability entrypoint.
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
await mastra.observability.addFeedback?.({
|
|
38
|
+
traceId: 'trace-123',
|
|
39
|
+
spanId: 'span-456',
|
|
40
|
+
feedback: {
|
|
41
|
+
feedbackSource: 'user',
|
|
42
|
+
feedbackType: 'rating',
|
|
43
|
+
value: 1,
|
|
44
|
+
comment: 'Helpful answer.',
|
|
45
|
+
},
|
|
46
|
+
})
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**traceId** (`string`): Trace that anchors the feedback target.
|
|
50
|
+
|
|
51
|
+
**spanId** (`string`): Span that anchors the feedback target.
|
|
52
|
+
|
|
53
|
+
**correlationContext** (`CorrelationContext`): Live span or trace context to emit from without rehydrating the target from storage.
|
|
54
|
+
|
|
55
|
+
**feedback** (`FeedbackInput`): Feedback payload to add.
|
|
56
|
+
|
|
57
|
+
### `createFeedback(args)`
|
|
58
|
+
|
|
59
|
+
Creates one feedback record through the observability storage domain. Storage-level calls write directly to the store, so include `timestamp`.
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
await observability.createFeedback({
|
|
63
|
+
feedback: {
|
|
64
|
+
feedbackId: 'feedback-1',
|
|
65
|
+
timestamp: new Date(),
|
|
66
|
+
traceId: 'trace-123',
|
|
67
|
+
spanId: 'span-456',
|
|
68
|
+
feedbackSource: 'user',
|
|
69
|
+
feedbackType: 'rating',
|
|
70
|
+
value: 1,
|
|
71
|
+
comment: 'Helpful answer.',
|
|
72
|
+
},
|
|
73
|
+
})
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The HTTP and client SDK create route accepts `CreateFeedbackBody`, sets `timestamp` server-side, and generates `feedbackId` when omitted:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
await mastraClient.createFeedback({
|
|
80
|
+
feedback: {
|
|
81
|
+
traceId: 'trace-123',
|
|
82
|
+
spanId: 'span-456',
|
|
83
|
+
feedbackSource: 'user',
|
|
84
|
+
feedbackType: 'rating',
|
|
85
|
+
value: 1,
|
|
86
|
+
},
|
|
87
|
+
})
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### `batchCreateFeedback(args)`
|
|
91
|
+
|
|
92
|
+
Creates multiple feedback records through the observability storage domain. This method isn't exposed by the HTTP routes or `@mastra/client-js`.
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
await observability.batchCreateFeedback({
|
|
96
|
+
feedbacks: [
|
|
97
|
+
{
|
|
98
|
+
feedbackId: 'feedback-1',
|
|
99
|
+
timestamp: new Date(),
|
|
100
|
+
traceId: 'trace-123',
|
|
101
|
+
feedbackSource: 'user',
|
|
102
|
+
feedbackType: 'rating',
|
|
103
|
+
value: 1,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
feedbackId: 'feedback-2',
|
|
107
|
+
timestamp: new Date(),
|
|
108
|
+
traceId: 'trace-123',
|
|
109
|
+
feedbackSource: 'qa',
|
|
110
|
+
feedbackType: 'comment',
|
|
111
|
+
value: 'Needs a citation before shipping.',
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
})
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## List feedback
|
|
118
|
+
|
|
119
|
+
### `listFeedback(args?)`
|
|
120
|
+
|
|
121
|
+
Returns feedback records in page mode or delta mode.
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
const response = await mastraClient.listFeedback({
|
|
125
|
+
filters: {
|
|
126
|
+
feedbackType: 'rating',
|
|
127
|
+
feedbackSource: 'studio',
|
|
128
|
+
},
|
|
129
|
+
pagination: { page: 0, perPage: 20 },
|
|
130
|
+
orderBy: { field: 'timestamp', direction: 'DESC' },
|
|
131
|
+
})
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**mode** (`'page' | 'delta'`): List mode. Defaults to 'page'.
|
|
135
|
+
|
|
136
|
+
**filters** (`FeedbackFilter`): Filters for the feedback records.
|
|
137
|
+
|
|
138
|
+
**pagination** (`{ page?: number; perPage?: number }`): Page-mode pagination. page is zero-indexed.
|
|
139
|
+
|
|
140
|
+
**orderBy** (`{ field?: 'timestamp'; direction?: 'ASC' | 'DESC' }`): Page-mode sort configuration.
|
|
141
|
+
|
|
142
|
+
**after** (`string`): Delta cursor for incremental polling. Only valid in delta mode.
|
|
143
|
+
|
|
144
|
+
**limit** (`number`): Maximum number of updates to return in delta mode.
|
|
145
|
+
|
|
146
|
+
## OLAP queries
|
|
147
|
+
|
|
148
|
+
OLAP feedback queries operate on numeric `value` fields.
|
|
149
|
+
|
|
150
|
+
### `getFeedbackAggregate(args)`
|
|
151
|
+
|
|
152
|
+
Returns one aggregate feedback value.
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
const response = await mastraClient.getFeedbackAggregate({
|
|
156
|
+
feedbackType: 'rating',
|
|
157
|
+
feedbackSource: 'user',
|
|
158
|
+
aggregation: 'avg',
|
|
159
|
+
comparePeriod: 'previous_day',
|
|
160
|
+
})
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**feedbackType** (`string`): Feedback type to aggregate.
|
|
164
|
+
|
|
165
|
+
**feedbackSource** (`string`): Feedback source to aggregate.
|
|
166
|
+
|
|
167
|
+
**aggregation** (`'sum' | 'avg' | 'min' | 'max' | 'count' | 'count_distinct' | 'last'`): Aggregation to apply.
|
|
168
|
+
|
|
169
|
+
**filters** (`FeedbackFilter`): Additional filters.
|
|
170
|
+
|
|
171
|
+
**comparePeriod** (`'previous_period' | 'previous_day' | 'previous_week'`): Optional period-over-period comparison.
|
|
172
|
+
|
|
173
|
+
### `getFeedbackBreakdown(args)`
|
|
174
|
+
|
|
175
|
+
Returns feedback values grouped by dimensions.
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
const response = await mastraClient.getFeedbackBreakdown({
|
|
179
|
+
feedbackType: 'rating',
|
|
180
|
+
groupBy: ['entityName'],
|
|
181
|
+
aggregation: 'avg',
|
|
182
|
+
})
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### `getFeedbackTimeSeries(args)`
|
|
186
|
+
|
|
187
|
+
Returns feedback values bucketed by interval.
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
const response = await mastraClient.getFeedbackTimeSeries({
|
|
191
|
+
feedbackType: 'rating',
|
|
192
|
+
interval: '1h',
|
|
193
|
+
aggregation: 'avg',
|
|
194
|
+
groupBy: ['feedbackSource'],
|
|
195
|
+
})
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### `getFeedbackPercentiles(args)`
|
|
199
|
+
|
|
200
|
+
Returns percentile values bucketed by interval.
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
const response = await mastraClient.getFeedbackPercentiles({
|
|
204
|
+
feedbackType: 'rating',
|
|
205
|
+
percentiles: [0.5, 0.95],
|
|
206
|
+
interval: '1d',
|
|
207
|
+
})
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Types
|
|
211
|
+
|
|
212
|
+
### `FeedbackRecord`
|
|
213
|
+
|
|
214
|
+
**feedbackId** (`string | null`): Unique ID for this feedback event. The server route generates one when omitted.
|
|
215
|
+
|
|
216
|
+
**timestamp** (`Date`): Time when the feedback was recorded.
|
|
217
|
+
|
|
218
|
+
**traceId** (`string | null`): Trace that anchors the feedback target when available.
|
|
219
|
+
|
|
220
|
+
**spanId** (`string | null`): Span that anchors the feedback target when available.
|
|
221
|
+
|
|
222
|
+
**feedbackSource** (`string | null`): Optional source metadata, such as 'user', 'qa', 'studio', or 'system'.
|
|
223
|
+
|
|
224
|
+
**source** (`string | null`): Deprecated alias for feedbackSource.
|
|
225
|
+
|
|
226
|
+
**feedbackType** (`string`): Type of feedback, such as 'rating', 'thumbs', 'comment', or 'correction'.
|
|
227
|
+
|
|
228
|
+
**value** (`number | string`): Feedback value. Numeric values support aggregate, breakdown, time series, and percentile queries.
|
|
229
|
+
|
|
230
|
+
**comment** (`string | null`): Additional comment or context for the feedback.
|
|
231
|
+
|
|
232
|
+
**feedbackUserId** (`string | null`): User who provided the feedback.
|
|
233
|
+
|
|
234
|
+
**sourceId** (`string | null`): ID of the source record this feedback is linked to, such as an experiment result ID.
|
|
235
|
+
|
|
236
|
+
**metadata** (`Record<string, unknown> | null`): User-defined metadata for the feedback record.
|
|
237
|
+
|
|
238
|
+
### Shared context fields
|
|
239
|
+
|
|
240
|
+
Feedback records can include shared observability context fields for filtering, grouping, and correlation with traces, logs, metrics, and scores.
|
|
241
|
+
|
|
242
|
+
**entityType** (`EntityType | null`): Entity type that produced the signal.
|
|
243
|
+
|
|
244
|
+
**entityId** (`string | null`): ID of the entity that produced the signal.
|
|
245
|
+
|
|
246
|
+
**entityName** (`string | null`): Name of the entity that produced the signal.
|
|
247
|
+
|
|
248
|
+
**parentEntityType** (`EntityType | null`): Entity type of the parent entity.
|
|
249
|
+
|
|
250
|
+
**parentEntityId** (`string | null`): ID of the parent entity.
|
|
251
|
+
|
|
252
|
+
**parentEntityName** (`string | null`): Name of the parent entity.
|
|
253
|
+
|
|
254
|
+
**rootEntityType** (`EntityType | null`): Entity type of the root entity.
|
|
255
|
+
|
|
256
|
+
**rootEntityId** (`string | null`): ID of the root entity.
|
|
257
|
+
|
|
258
|
+
**rootEntityName** (`string | null`): Name of the root entity.
|
|
259
|
+
|
|
260
|
+
**userId** (`string | null`): Human end user who triggered execution.
|
|
261
|
+
|
|
262
|
+
**organizationId** (`string | null`): Multi-tenant organization or account.
|
|
263
|
+
|
|
264
|
+
**resourceId** (`string | null`): Broader resource context.
|
|
265
|
+
|
|
266
|
+
**runId** (`string | null`): Execution run identifier.
|
|
267
|
+
|
|
268
|
+
**sessionId** (`string | null`): Session identifier for grouping traces.
|
|
269
|
+
|
|
270
|
+
**threadId** (`string | null`): Conversation thread identifier.
|
|
271
|
+
|
|
272
|
+
**requestId** (`string | null`): HTTP request ID for correlation.
|
|
273
|
+
|
|
274
|
+
**environment** (`string | null`): Deployment environment.
|
|
275
|
+
|
|
276
|
+
**serviceName** (`string | null`): Name of the service.
|
|
277
|
+
|
|
278
|
+
**scope** (`Record<string, unknown> | null`): Package, app version, or deployment metadata.
|
|
279
|
+
|
|
280
|
+
**entityVersionId** (`string | null`): Version ID of the entity that produced the signal.
|
|
281
|
+
|
|
282
|
+
**parentEntityVersionId** (`string | null`): Version ID of the parent entity.
|
|
283
|
+
|
|
284
|
+
**rootEntityVersionId** (`string | null`): Version ID of the root entity.
|
|
285
|
+
|
|
286
|
+
**experimentId** (`string | null`): Experiment or eval run identifier.
|
|
287
|
+
|
|
288
|
+
**executionSource** (`string | null`): Source of execution, such as local, cloud, or CI.
|
|
289
|
+
|
|
290
|
+
**tags** (`string[] | null`): Labels for filtering.
|
|
291
|
+
|
|
292
|
+
### `FeedbackInput`
|
|
293
|
+
|
|
294
|
+
Use `FeedbackInput` with `mastra.observability.addFeedback()`, `recordedTrace.addFeedback()`, and `recordedSpan.addFeedback()`.
|
|
295
|
+
|
|
296
|
+
**feedbackSource** (`string`): Optional source metadata for the feedback.
|
|
297
|
+
|
|
298
|
+
**source** (`string`): Deprecated alias for feedbackSource.
|
|
299
|
+
|
|
300
|
+
**feedbackType** (`string`): Type of feedback to record.
|
|
301
|
+
|
|
302
|
+
**value** (`number | string`): Feedback value to record.
|
|
303
|
+
|
|
304
|
+
**comment** (`string`): Additional comment or context.
|
|
305
|
+
|
|
306
|
+
**feedbackUserId** (`string`): User who provided the feedback.
|
|
307
|
+
|
|
308
|
+
**userId** (`string`): Deprecated alias for feedbackUserId.
|
|
309
|
+
|
|
310
|
+
**metadata** (`Record<string, unknown>`): Additional feedback-specific metadata.
|
|
311
|
+
|
|
312
|
+
**experimentId** (`string`): Experiment or eval run identifier.
|
|
313
|
+
|
|
314
|
+
**sourceId** (`string`): ID of the source record this feedback is linked to.
|
|
315
|
+
|
|
316
|
+
### `FeedbackFilter`
|
|
317
|
+
|
|
318
|
+
Use `FeedbackFilter` in `listFeedback()` and OLAP query `filters`.
|
|
319
|
+
|
|
320
|
+
**timestamp** (`{ start?: Date; end?: Date; startExclusive?: boolean; endExclusive?: boolean }`): Filter by timestamp range.
|
|
321
|
+
|
|
322
|
+
**traceId** (`string`): Filter by trace ID.
|
|
323
|
+
|
|
324
|
+
**spanId** (`string`): Filter by span ID.
|
|
325
|
+
|
|
326
|
+
**feedbackType** (`string | string[]`): Filter by one or more feedback types.
|
|
327
|
+
|
|
328
|
+
**feedbackSource** (`string`): Filter by feedback source.
|
|
329
|
+
|
|
330
|
+
**source** (`string`): Deprecated alias for feedbackSource.
|
|
331
|
+
|
|
332
|
+
**feedbackUserId** (`string`): Filter by the user who provided the feedback.
|
|
333
|
+
|
|
334
|
+
**entityType** (`EntityType`): Filter by entity type.
|
|
335
|
+
|
|
336
|
+
**entityName** (`string`): Filter by entity name.
|
|
337
|
+
|
|
338
|
+
**entityVersionId** (`string`): Filter by entity version ID.
|
|
339
|
+
|
|
340
|
+
**parentEntityType** (`EntityType`): Filter by parent entity type.
|
|
341
|
+
|
|
342
|
+
**parentEntityName** (`string`): Filter by parent entity name.
|
|
343
|
+
|
|
344
|
+
**parentEntityVersionId** (`string`): Filter by parent entity version ID.
|
|
345
|
+
|
|
346
|
+
**rootEntityType** (`EntityType`): Filter by root entity type.
|
|
347
|
+
|
|
348
|
+
**rootEntityName** (`string`): Filter by root entity name.
|
|
349
|
+
|
|
350
|
+
**rootEntityVersionId** (`string`): Filter by root entity version ID.
|
|
351
|
+
|
|
352
|
+
**userId** (`string`): Filter by human end-user ID.
|
|
353
|
+
|
|
354
|
+
**organizationId** (`string`): Filter by organization ID.
|
|
355
|
+
|
|
356
|
+
**resourceId** (`string`): Filter by resource ID.
|
|
357
|
+
|
|
358
|
+
**runId** (`string`): Filter by run ID.
|
|
359
|
+
|
|
360
|
+
**sessionId** (`string`): Filter by session ID.
|
|
361
|
+
|
|
362
|
+
**threadId** (`string`): Filter by thread ID.
|
|
363
|
+
|
|
364
|
+
**requestId** (`string`): Filter by request ID.
|
|
365
|
+
|
|
366
|
+
**serviceName** (`string`): Filter by service name.
|
|
367
|
+
|
|
368
|
+
**environment** (`string`): Filter by environment.
|
|
369
|
+
|
|
370
|
+
**executionSource** (`string`): Filter by execution source.
|
|
371
|
+
|
|
372
|
+
**experimentId** (`string`): Filter by experiment or eval run identifier.
|
|
373
|
+
|
|
374
|
+
**tags** (`string[]`): Filter by tags. Matching records must have all specified tags.
|
|
375
|
+
|
|
376
|
+
## HTTP routes
|
|
377
|
+
|
|
378
|
+
| Method | Path | Purpose | Permission |
|
|
379
|
+
| ------ | ----------------------------------------- | ---------------------------- | -------------------- |
|
|
380
|
+
| `GET` | `/api/observability/feedback` | List feedback records | None derived |
|
|
381
|
+
| `POST` | `/api/observability/feedback` | Create a feedback record | None derived |
|
|
382
|
+
| `POST` | `/api/observability/feedback/aggregate` | Return one aggregate value | `observability:read` |
|
|
383
|
+
| `POST` | `/api/observability/feedback/breakdown` | Group feedback by dimensions | `observability:read` |
|
|
384
|
+
| `POST` | `/api/observability/feedback/timeseries` | Bucket feedback by interval | `observability:read` |
|
|
385
|
+
| `POST` | `/api/observability/feedback/percentiles` | Return percentile series | `observability:read` |
|
|
386
|
+
|
|
387
|
+
## Related
|
|
388
|
+
|
|
389
|
+
- [Feedback guide](https://mastra.ai/docs/observability/feedback)
|
|
390
|
+
- [Client SDK observability reference](https://mastra.ai/reference/client-js/observability)
|
|
391
|
+
- [Observability configuration](https://mastra.ai/reference/observability/tracing/configuration)
|
|
@@ -125,6 +125,8 @@ export const testWorkflow = createWorkflow({
|
|
|
125
125
|
|
|
126
126
|
**options.shouldPersistSnapshot** (`(params: { stepResults: Record<string, StepResult<any, any, any, any>>; workflowStatus: WorkflowRunStatus }) => boolean`): Optional flag to determine whether to persist the workflow snapshot
|
|
127
127
|
|
|
128
|
+
**options.pruneSnapshot** (`(params: { snapshot: WorkflowRunState; workflowStatus: WorkflowRunStatus }) => WorkflowRunState`): Optional hook to transform the workflow snapshot immediately before it is persisted. Must return JSON-serializable data and preserve everything the workflow needs to resume (suspended step suspendPayloads, suspendedPaths, executionPath, etc.). Used internally by agent runs to keep snapshots minimal; user workflows persist full snapshots by default.
|
|
129
|
+
|
|
128
130
|
**options.onFinish** (`(result: WorkflowFinishCallbackResult) => void | Promise<void>`): Callback invoked when workflow completes with any status (success, failed, suspended, tripwire). Receives the workflow result including status, output, error, and step results. Errors thrown in this callback are caught and logged, not propagated.
|
|
129
131
|
|
|
130
132
|
**options.onFinish.status** (`WorkflowRunStatus`): The workflow status: 'success', 'failed', 'suspended', or 'tripwire'
|