@mastra/server 1.66.0-alpha.0 → 1.66.0-alpha.1

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 (29) hide show
  1. package/dist/{datasets-D0C0V2kk.js → datasets-B4qPHzEy.js} +8 -2
  2. package/dist/datasets-B4qPHzEy.js.map +1 -0
  3. package/dist/{datasets-BVbtevHd.cjs → datasets-C-_ZWnxR.cjs} +13 -1
  4. package/dist/datasets-C-_ZWnxR.cjs.map +1 -0
  5. package/dist/{dist-CX9x93MJ.js → dist-4Qm6OSPJ.js} +58 -21
  6. package/dist/dist-4Qm6OSPJ.js.map +1 -0
  7. package/dist/{dist-BnPncT17.cjs → dist-BmrsK_KX.cjs} +58 -21
  8. package/dist/{dist-BnPncT17.cjs.map → dist-BmrsK_KX.cjs.map} +1 -1
  9. package/dist/docs/SKILL.md +1 -1
  10. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  11. package/dist/docs/references/reference-observability-tracing-trace-query.md +169 -9
  12. package/dist/server/handlers/agent-builder.cjs +1 -1
  13. package/dist/server/handlers/agent-builder.js +1 -1
  14. package/dist/server/handlers/datasets.cjs +5 -4
  15. package/dist/server/handlers/datasets.cjs.map +1 -1
  16. package/dist/server/handlers/datasets.d.ts +2 -0
  17. package/dist/server/handlers/datasets.d.ts.map +1 -1
  18. package/dist/server/handlers/datasets.js +5 -4
  19. package/dist/server/handlers/datasets.js.map +1 -1
  20. package/dist/server/schemas/datasets.d.ts +5 -0
  21. package/dist/server/schemas/datasets.d.ts.map +1 -1
  22. package/dist/server/schemas/index.cjs +2 -1
  23. package/dist/server/schemas/index.js +2 -2
  24. package/dist/server/server-adapter/routes/datasets.d.ts +2 -0
  25. package/dist/server/server-adapter/routes/datasets.d.ts.map +1 -1
  26. package/package.json +5 -5
  27. package/dist/datasets-BVbtevHd.cjs.map +0 -1
  28. package/dist/datasets-D0C0V2kk.js.map +0 -1
  29. package/dist/dist-CX9x93MJ.js.map +0 -1
@@ -3,7 +3,7 @@ name: mastra-server
3
3
  description: Documentation for @mastra/server. Use when working with @mastra/server APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/server"
6
- version: "1.66.0-alpha.0"
6
+ version: "1.66.0-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.66.0-alpha.0",
2
+ "version": "1.66.0-alpha.1",
3
3
  "package": "@mastra/server",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -24,6 +24,7 @@ const result = await mastraClient.queryTraces({
24
24
  op: 'and',
25
25
  args: [
26
26
  { op: 'eq', left: { path: 'scorerId' }, right: { literal: 'factuality' } },
27
+ { op: 'eq', left: { path: 'scorerVersion' }, right: { literal: '2.1.0' } },
27
28
  { op: 'lt', left: { path: 'score' }, right: { literal: 0.6 } },
28
29
  ],
29
30
  },
@@ -34,7 +35,7 @@ const result = await mastraClient.queryTraces({
34
35
  })
35
36
  ```
36
37
 
37
- A `some` clause matches when one related record satisfies its complete nested predicate. In this example, `scorerId` and `score` must match on the same score record. A `none` clause matches when no related record satisfies its complete nested predicate.
38
+ A `some` clause matches when one related record satisfies its complete nested predicate. In this example, `scorerId`, `scorerVersion`, and `score` must match on the same score record. A `none` clause uses anti-existence semantics: it matches when no related record satisfies its complete nested predicate. A trace with no related scores therefore matches `scores.none`.
38
39
 
39
40
  Span clauses examine the current root span and current child spans. The root `timeRange` applies only to the selected current root's `startedAt`. Related spans and scores can participate even when their own timestamps are outside that range. Related records correlate only through a matching non-null `traceId`.
40
41
 
@@ -99,17 +100,176 @@ Hono and Fastify enforce the request-body limit before JSON parsing. Express and
99
100
 
100
101
  ## Fields and operators
101
102
 
102
- | Predicate context | Fields | Operators |
103
- | ----------------- | ---------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
104
- | Trace | `traceId`, `threadId`, `resourceId`, `entityName`, `entityType`, `environment`, `status` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
105
- | Trace | `startedAt`, `endedAt` | `eq`, `ne`, `in`, `notIn`, `lt`, `lte`, `gt`, `gte`, `exists`, `notExists` |
106
- | Span | `spanType` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
107
- | Span | `error` | `exists`, `notExists` |
108
- | Score | `scorerId` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
109
- | Score | `score` | `eq`, `ne`, `in`, `notIn`, `lt`, `lte`, `gt`, `gte`, `exists`, `notExists` |
103
+ | Predicate context | Fields | Operators |
104
+ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
105
+ | Trace | `traceId`, `threadId`, `resourceId`, `entityName`, `entityType`, `environment`, `status` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
106
+ | Trace metadata | `metadata.<key>` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
107
+ | Trace | `startedAt`, `endedAt` | `eq`, `ne`, `in`, `notIn`, `lt`, `lte`, `gt`, `gte`, `exists`, `notExists` |
108
+ | Span | `name`, `spanType`, `model`, `provider`, `status`, `entityType`, `entityId`, `entityName`, `entityVersionId`, `parentEntityVersionId`, `rootEntityVersionId` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
109
+ | Span | `startedAt`, `endedAt`, `durationMs` | `eq`, `ne`, `in`, `notIn`, `lt`, `lte`, `gt`, `gte`, `exists`, `notExists` |
110
+ | Span | `error` | `exists`, `notExists` |
111
+ | Score | `scorerId`, `scorerVersion`, `scoreSource`, `entityVersionId`, `parentEntityVersionId`, `rootEntityVersionId` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
112
+ | Score | `score`, `timestamp` | `eq`, `ne`, `in`, `notIn`, `lt`, `lte`, `gt`, `gte`, `exists`, `notExists` |
113
+ | Score | `spanId` | `exists`, `notExists` |
110
114
 
111
115
  Compose predicates with `{ op: 'and', args: [...] }`, `{ op: 'or', args: [...] }`, and `{ op: 'not', arg: ... }`. Comparison predicates place a field reference on the left and a literal on the right. Membership predicates use a field reference in `value` and a homogeneous literal array in `set`.
112
116
 
117
+ String comparisons are case-sensitive, and literals are never coerced. Canonical string fields compare exact stored values. Metadata string values are trimmed before comparison, as described below. Numeric predicates, including `score` and `durationMs`, require numbers, while timestamp predicates require ISO timestamp strings. A missing value satisfies neither positive nor ordered predicates, although it does satisfy the negative operators `ne` and `notIn`. Combine a negative predicate with `exists` when the field must also be present.
118
+
119
+ ### Filter by span properties
120
+
121
+ Every condition inside one `spans.some` or `spans.none` clause applies to the same current span. For example, this predicate finds a failed tool span whose name is `medication_lookup`; a matching name on one span and an error on another don't satisfy it:
122
+
123
+ ```typescript
124
+ const failedMedicationLookup = {
125
+ spans: {
126
+ some: {
127
+ op: 'and',
128
+ args: [
129
+ { op: 'eq', left: { path: 'name' }, right: { literal: 'medication_lookup' } },
130
+ { op: 'eq', left: { path: 'spanType' }, right: { literal: 'tool_call' } },
131
+ { op: 'exists', path: 'error' },
132
+ ],
133
+ },
134
+ },
135
+ }
136
+ ```
137
+
138
+ Use `status` for the derived `success` or `error` outcome. Use `error` when you only need to test whether error details are present.
139
+
140
+ `durationMs` is the span's elapsed time in milliseconds. Span `startedAt` and `endedAt` conditions filter related spans independently of the top-level root `timeRange`:
141
+
142
+ ```typescript
143
+ const slowModelCalls = {
144
+ spans: {
145
+ some: {
146
+ op: 'and',
147
+ args: [
148
+ { op: 'eq', left: { path: 'spanType' }, right: { literal: 'model_generation' } },
149
+ { op: 'gt', left: { path: 'durationMs' }, right: { literal: 5000 } },
150
+ {
151
+ op: 'gte',
152
+ left: { path: 'startedAt' },
153
+ right: { literal: '2026-07-15T00:00:00.000Z' },
154
+ },
155
+ ],
156
+ },
157
+ },
158
+ }
159
+ ```
160
+
161
+ `model` and `provider` read the canonical `attributes.model` and `attributes.provider` span attributes. Only stored string values are queryable; missing, null, and non-string values count as missing.
162
+
163
+ ```typescript
164
+ const selectedModel = {
165
+ spans: {
166
+ some: {
167
+ op: 'and',
168
+ args: [
169
+ {
170
+ op: 'eq',
171
+ left: { path: 'model' },
172
+ right: { literal: 'claude-sonnet-4-6' },
173
+ },
174
+ { op: 'eq', left: { path: 'provider' }, right: { literal: 'anthropic' } },
175
+ ],
176
+ },
177
+ },
178
+ }
179
+ ```
180
+
181
+ Use generic entity fields for tool and retrieval identity. The version fields let one clause qualify the same span by its entity lineage:
182
+
183
+ ```typescript
184
+ const versionedRetrieval = {
185
+ spans: {
186
+ some: {
187
+ op: 'and',
188
+ args: [
189
+ { op: 'eq', left: { path: 'entityType' }, right: { literal: 'rag_ingestion' } },
190
+ { op: 'eq', left: { path: 'entityId' }, right: { literal: 'medication-index' } },
191
+ { op: 'eq', left: { path: 'entityVersionId' }, right: { literal: 'index-v3' } },
192
+ { op: 'eq', left: { path: 'rootEntityVersionId' }, right: { literal: 'agent-v2' } },
193
+ ],
194
+ },
195
+ },
196
+ }
197
+ ```
198
+
199
+ ### Filter by score time
200
+
201
+ Score timestamps are independent of the required top-level trace `timeRange`. The top-level range selects trace candidates by trace start time. A nested `timestamp` predicate limits related score records:
202
+
203
+ ```typescript
204
+ const query = {
205
+ timeRange: {
206
+ from: '2026-08-01T00:00:00.000Z',
207
+ to: '2026-08-08T00:00:00.000Z',
208
+ },
209
+ where: {
210
+ scores: {
211
+ some: {
212
+ op: 'and',
213
+ args: [
214
+ { op: 'eq', left: { path: 'scoreSource' }, right: { literal: 'automated' } },
215
+ {
216
+ op: 'gte',
217
+ left: { path: 'timestamp' },
218
+ right: { literal: '2026-07-15T00:00:00.000Z' },
219
+ },
220
+ {
221
+ op: 'lt',
222
+ left: { path: 'timestamp' },
223
+ right: { literal: '2026-08-01T00:00:00.000Z' },
224
+ },
225
+ ],
226
+ },
227
+ },
228
+ },
229
+ }
230
+ ```
231
+
232
+ ### Filter by span anchoring
233
+
234
+ Use `spanId` only to test whether a score targets a span. The predicate doesn't join the score to a matching span predicate:
235
+
236
+ ```typescript
237
+ // At least one score targets a span.
238
+ const anchoredToSpanWhere = { scores: { some: { op: 'exists', path: 'spanId' } } }
239
+
240
+ // At least one score applies to the trace rather than a span.
241
+ const traceLevelScoreWhere = { scores: { some: { op: 'notExists', path: 'spanId' } } }
242
+ ```
243
+
244
+ The deprecated `source` field and `scorerName` aren't available as score predicate fields. Use the canonical `scoreSource` and `scorerId` fields.
245
+
246
+ ### Filter by metadata
247
+
248
+ Use `metadata.<key>` paths for custom dimensions stored on the current root span. Metadata predicates compare trimmed, non-empty string values exactly and case-sensitively. Leading and trailing whitespace in a stored string value is ignored. Values empty after trimming count as missing. Null, numeric, boolean, object, and array values also count as missing.
249
+
250
+ ```typescript
251
+ const messageTrace = {
252
+ op: 'and',
253
+ args: [
254
+ { op: 'eq', left: { path: 'metadata.messageId' }, right: { literal: 'message-123' } },
255
+ { op: 'in', value: { path: 'metadata.actorRole' }, set: ['assistant', 'tool'] },
256
+ { op: 'exists', path: 'metadata.protocolVersion' },
257
+ {
258
+ op: 'or',
259
+ args: [
260
+ { op: 'eq', left: { path: 'metadata.temporalRunId' }, right: { literal: 'run-456' } },
261
+ { op: 'eq', left: { path: 'metadata.externalTraceId' }, right: { literal: 'trace-789' } },
262
+ ],
263
+ },
264
+ { op: 'not', arg: { op: 'exists', path: 'metadata.parentMessageId' } },
265
+ ],
266
+ }
267
+ ```
268
+
269
+ The key must name one top-level property. Empty keys and nested paths are rejected. Metadata keys aren't trimmed, so leading and trailing whitespace remains part of the exact key identity. When metadata duplicates a canonical trace field, such as `resourceId`, `threadId`, or `environment`, prefer the canonical field because it uses the dedicated storage column. The `metadata.<key>` form remains available when you specifically need the value from the metadata object. Metadata and canonical values may differ.
270
+
271
+ Metadata fields aren't available for grouping or field discovery.
272
+
113
273
  ## Responses
114
274
 
115
275
  An ungrouped query returns only lightweight completed traces:
@@ -30,7 +30,7 @@ var agent_builder_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll
30
30
  });
31
31
  let agentBuilderWorkflowsPromise;
32
32
  async function loadAgentBuilderWorkflows() {
33
- agentBuilderWorkflowsPromise ??= Promise.resolve().then(() => require("../../dist-BnPncT17.cjs")).then((mod) => mod.agentBuilderWorkflows);
33
+ agentBuilderWorkflowsPromise ??= Promise.resolve().then(() => require("../../dist-BmrsK_KX.cjs")).then((mod) => mod.agentBuilderWorkflows);
34
34
  return agentBuilderWorkflowsPromise;
35
35
  }
36
36
  async function registerAgentBuilderWorkflows(mastra) {
@@ -29,7 +29,7 @@ var agent_builder_exports = /* @__PURE__ */ __exportAll({
29
29
  });
30
30
  let agentBuilderWorkflowsPromise;
31
31
  async function loadAgentBuilderWorkflows() {
32
- agentBuilderWorkflowsPromise ??= import("../../dist-CX9x93MJ.js").then((mod) => mod.agentBuilderWorkflows);
32
+ agentBuilderWorkflowsPromise ??= import("../../dist-4Qm6OSPJ.js").then((mod) => mod.agentBuilderWorkflows);
33
33
  return agentBuilderWorkflowsPromise;
34
34
  }
35
35
  async function registerAgentBuilderWorkflows(mastra) {
@@ -5,7 +5,7 @@ const require_common = require("../../common-DQn8jX5T.cjs");
5
5
  const require_route_builder = require("../../route-builder-C8n4ugUf.cjs");
6
6
  const require_constants = require("../../constants-4IJp_uzj.cjs");
7
7
  const require_server_handlers_error = require("./error.cjs");
8
- const require_datasets = require("../../datasets-BVbtevHd.cjs");
8
+ const require_datasets = require("../../datasets-C-_ZWnxR.cjs");
9
9
  let zod = require("zod");
10
10
  let _mastra_core_agent = require("@mastra/core/agent");
11
11
  let _mastra_core_error = require("@mastra/core/error");
@@ -797,7 +797,7 @@ const LIST_EXPERIMENT_RESULTS_ROUTE = require_route_builder.createRoute({
797
797
  path: "/datasets/:datasetId/experiments/:experimentId/results",
798
798
  responseType: "json",
799
799
  pathParamSchema: require_datasets.datasetAndExperimentIdPathParams,
800
- queryParamSchema: require_datasets.paginationQuerySchema,
800
+ queryParamSchema: require_datasets.listExperimentResultsQuerySchema,
801
801
  responseSchema: require_datasets.listExperimentResultsResponseSchema,
802
802
  summary: "List experiment results",
803
803
  description: "Returns a paginated list of results for the experiment",
@@ -806,14 +806,15 @@ const LIST_EXPERIMENT_RESULTS_ROUTE = require_route_builder.createRoute({
806
806
  handler: async ({ mastra, datasetId, experimentId, ...params }) => {
807
807
  assertDatasetsAvailable();
808
808
  try {
809
- const { page, perPage } = params;
809
+ const { page, perPage, tags } = params;
810
810
  const ds = await mastra.datasets.get({ id: datasetId });
811
811
  const run = await ds.getExperiment({ experimentId });
812
812
  if (!run || run.datasetId !== datasetId) throw new require_http_exception.HTTPException(404, { message: `Experiment not found: ${experimentId}` });
813
813
  const result = await ds.listExperimentResults({
814
814
  experimentId,
815
815
  page: page ?? 0,
816
- perPage: perPage ?? 10
816
+ perPage: perPage ?? 10,
817
+ ...tags !== void 0 ? { tags } : {}
817
818
  });
818
819
  return {
819
820
  results: result.results.map(({ experimentId: _eid, ...rest }) => ({