@mastra/mcp-docs-server 1.3.9-alpha.1 → 1.3.9-alpha.10

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 (115) hide show
  1. package/.docs/docs/agents/guardrails.md +3 -0
  2. package/.docs/docs/agents/human-in-the-loop.md +2 -1
  3. package/.docs/docs/agents/processors.md +3 -0
  4. package/.docs/docs/harness/agent-controller.md +1 -1
  5. package/.docs/docs/harness/background-tasks.md +11 -0
  6. package/.docs/docs/harness/durable-agents.md +24 -8
  7. package/.docs/docs/harness/signals.md +3 -1
  8. package/.docs/docs/mastra-platform/connect/channels.md +14 -2
  9. package/.docs/docs/mastra-platform/connect/overview.md +1 -1
  10. package/.docs/docs/mastra-platform/connect/providers.md +1 -0
  11. package/.docs/docs/mastra-platform/connect/tools.md +25 -3
  12. package/.docs/docs/mastra-platform/observability.md +1 -1
  13. package/.docs/docs/memory/observational-memory.md +4 -2
  14. package/.docs/docs/memory/semantic-recall.md +2 -0
  15. package/.docs/docs/studio/overview.md +8 -0
  16. package/.docs/docs/workflows/control-flow.md +3 -1
  17. package/.docs/docs/workflows/overview.md +2 -0
  18. package/.docs/docs/workflows/time-travel.md +1 -1
  19. package/.docs/integrations/databases/clickhouse.md +1 -1
  20. package/.docs/integrations/voice/google.md +6 -0
  21. package/.docs/models/embeddings.md +2 -1
  22. package/.docs/models/environment-variables.md +2 -0
  23. package/.docs/models/gateways/merge-gateway.md +3 -1
  24. package/.docs/models/gateways/netlify.md +8 -4
  25. package/.docs/models/gateways/openrouter.md +8 -4
  26. package/.docs/models/gateways/vercel.md +9 -4
  27. package/.docs/models/index.md +3 -1
  28. package/.docs/models/providers/302ai.md +2 -1
  29. package/.docs/models/providers/aimlapi.md +3 -3
  30. package/.docs/models/providers/alibaba-token-plan-cn.md +31 -30
  31. package/.docs/models/providers/baseten.md +27 -25
  32. package/.docs/models/providers/cloudflare-workers-ai.md +2 -1
  33. package/.docs/models/providers/commandcode.md +147 -0
  34. package/.docs/models/providers/coralbricks.md +5 -8
  35. package/.docs/models/providers/cortecs.md +5 -6
  36. package/.docs/models/providers/databricks.md +2 -1
  37. package/.docs/models/providers/deepinfra.md +2 -1
  38. package/.docs/models/providers/edenai.md +11 -3
  39. package/.docs/models/providers/empiriolabs.md +3 -1
  40. package/.docs/models/providers/engy.md +12 -11
  41. package/.docs/models/providers/fireworks-ai.md +2 -1
  42. package/.docs/models/providers/huggingface.md +2 -1
  43. package/.docs/models/providers/hyper.md +26 -25
  44. package/.docs/models/providers/kenari.md +1 -1
  45. package/.docs/models/providers/kilo.md +29 -24
  46. package/.docs/models/providers/llmgateway-providers.md +9 -12
  47. package/.docs/models/providers/llmgateway.md +3 -4
  48. package/.docs/models/providers/melious.md +16 -15
  49. package/.docs/models/providers/minimax-cn-coding-plan.md +2 -1
  50. package/.docs/models/providers/minimax-cn.md +3 -2
  51. package/.docs/models/providers/minimax-coding-plan.md +2 -1
  52. package/.docs/models/providers/minimax.md +3 -2
  53. package/.docs/models/providers/nano-gpt.md +61 -55
  54. package/.docs/models/providers/nearai.md +1 -1
  55. package/.docs/models/providers/nebius.md +2 -1
  56. package/.docs/models/providers/novita-ai.md +2 -1
  57. package/.docs/models/providers/nvidia.md +2 -1
  58. package/.docs/models/providers/ofox.md +26 -25
  59. package/.docs/models/providers/ollama-cloud.md +31 -29
  60. package/.docs/models/providers/openai.md +1 -1
  61. package/.docs/models/providers/opencode-go.md +7 -7
  62. package/.docs/models/providers/opencode.md +91 -91
  63. package/.docs/models/providers/pioneer.md +120 -119
  64. package/.docs/models/providers/prime.md +4 -1
  65. package/.docs/models/providers/reflection.md +77 -0
  66. package/.docs/models/providers/requesty.md +6 -2
  67. package/.docs/models/providers/scaleway.md +2 -1
  68. package/.docs/models/providers/standardcompute.md +47 -8
  69. package/.docs/models/providers/togetherai.md +4 -1
  70. package/.docs/models/providers/upstage.md +8 -7
  71. package/.docs/models/providers/wandb.md +4 -2
  72. package/.docs/models/providers/xai.md +0 -1
  73. package/.docs/models/providers/zenmux.md +2 -1
  74. package/.docs/models/providers.md +2 -0
  75. package/.docs/reference/agent-controller/session.md +3 -2
  76. package/.docs/reference/agents/channels.md +5 -1
  77. package/.docs/reference/agents/durable-agent.md +16 -7
  78. package/.docs/reference/agents/inngest-agent.md +4 -4
  79. package/.docs/reference/classifier/classifier.md +31 -7
  80. package/.docs/reference/cli/mastra.md +43 -6
  81. package/.docs/reference/client-js/agent-controller.md +2 -0
  82. package/.docs/reference/client-js/agents.md +20 -0
  83. package/.docs/reference/client-js/observability.md +165 -6
  84. package/.docs/reference/configuration.md +30 -0
  85. package/.docs/reference/connect/channels.md +2 -2
  86. package/.docs/reference/connect/providers.md +38 -3
  87. package/.docs/reference/connect/tools.md +21 -2
  88. package/.docs/reference/core/mastra-class.md +7 -1
  89. package/.docs/reference/datasets/list.md +9 -1
  90. package/.docs/reference/evals/create-classifier-scorer.md +1 -0
  91. package/.docs/reference/index.md +1 -1
  92. package/.docs/reference/memory/observational-memory.md +2 -2
  93. package/.docs/reference/memory/settled.md +13 -5
  94. package/.docs/reference/observability/metrics/automatic-metrics.md +3 -3
  95. package/.docs/reference/observability/metrics/queries.md +1 -0
  96. package/.docs/reference/observability/tracing/{trace-query.md → advanced-queries.md} +477 -158
  97. package/.docs/reference/observability/tracing/interfaces.md +6 -0
  98. package/.docs/reference/processors/classifier-processor.md +8 -6
  99. package/.docs/reference/processors/model-selection-processor.md +2 -2
  100. package/.docs/reference/processors/moderation-processor.md +5 -1
  101. package/.docs/reference/processors/system-prompt-scrubber.md +4 -0
  102. package/.docs/reference/rag/embeddings.md +18 -0
  103. package/.docs/reference/signals/create-notification-inbox-tool.md +11 -9
  104. package/.docs/reference/streaming/agents/stream.md +19 -1
  105. package/.docs/reference/tools/create-tool.md +2 -2
  106. package/.docs/reference/tools/mcp-client.md +2 -2
  107. package/.docs/reference/workflows/dynamic-workflow-definition.md +1 -1
  108. package/.docs/reference/workflows/run-methods/resume.md +1 -1
  109. package/.docs/reference/workflows/run-methods/timeTravel.md +15 -16
  110. package/.docs/reference/workflows/step.md +1 -0
  111. package/.docs/reference/workflows/workflow-methods/classifier.md +1 -0
  112. package/.docs/reference/workspace/factory-sandbox.md +2 -0
  113. package/.docs/reference/workspace/filesystem.md +4 -0
  114. package/.docs/reference/workspace/workspace-class.md +10 -10
  115. package/package.json +7 -8
@@ -1661,13 +1661,13 @@ Inspect the command with:
1661
1661
  mastra api trace query --help
1662
1662
  ```
1663
1663
 
1664
- For supported fields, operators, and request options, see [Trace queries](https://mastra.ai/reference/observability/tracing/trace-query). For a local Mastra server, you can also inspect its request and response schemas:
1664
+ For supported fields, operators, and request options, see [Query traces](https://mastra.ai/reference/observability/tracing/advanced-queries). For a local Mastra server, you can also inspect its request and response schemas:
1665
1665
 
1666
1666
  ```bash
1667
1667
  mastra api --url http://localhost:4111 trace query --schema
1668
1668
  ```
1669
1669
 
1670
- Mastra Platform doesn't currently expose the schema endpoint used by `--schema`. To find fields and values recorded in your project, use [field and value discovery](https://mastra.ai/reference/observability/tracing/trace-query).
1670
+ Mastra Platform doesn't currently expose the schema endpoint used by `--schema`. To find fields and values recorded in your project, use [field and value discovery](https://mastra.ai/reference/observability/tracing/advanced-queries).
1671
1671
 
1672
1672
  The response remains nested under `data` to preserve cursor pagination:
1673
1673
 
@@ -1680,7 +1680,7 @@ The response remains nested under `data` to preserve cursor pagination:
1680
1680
  }
1681
1681
  ```
1682
1682
 
1683
- Each invocation makes one query. Pass a non-null `data.page.next` value back as `page.after` in the next query. See [Pagination and errors](https://mastra.ai/reference/observability/tracing/trace-query) for pagination modes, cursor handling, and errors.
1683
+ Each invocation makes one query. Pass a non-null `data.page.next` value back as `page.after` in the next query. See [Pagination and errors](https://mastra.ai/reference/observability/tracing/advanced-queries) for pagination modes, cursor handling, and errors.
1684
1684
 
1685
1685
  To load a numbered page and then poll, keep the same time range and predicate in both requests:
1686
1686
 
@@ -1691,7 +1691,42 @@ mastra api trace query '{"timeRange":{"from":"2026-08-01T00:00:00.000Z","to":"20
1691
1691
 
1692
1692
  Replace `CURSOR_FROM_NUMBERED_RESPONSE` with `data.deltaCursor` from the first response. Delta results remain under `data`, with `traces`, `delta: { limit, hasMore }`, and `deltaCursor`. Merge traces by `traceId`, retain each returned cursor, and continue immediately while `data.delta.hasMore` is `true`. Don't combine delta mode with `page`, `pagination`, or `orderBy`.
1693
1693
 
1694
- Omitting `after` establishes a cursor and returns no historical traces. Changing the time range or predicate requires a fresh numbered request. See [Delta polling limitations](https://mastra.ai/reference/observability/tracing/trace-query) before using this workflow to maintain a local trace list.
1694
+ Omitting `after` establishes a cursor and returns no historical traces. Changing the time range or predicate requires a fresh numbered request. See [Delta polling limitations](https://mastra.ai/reference/observability/tracing/advanced-queries) before using this workflow to maintain a local trace list.
1695
+
1696
+ #### `mastra api trace aggregate`
1697
+
1698
+ Groups the traces selected by a time range and optional `where` predicate, and returns one row of measures per group. The inline JSON input is required and accepts the same predicates as `trace query`. Like other observability commands, it targets `https://observability.mastra.ai` by default.
1699
+
1700
+ ```bash
1701
+ mastra api trace aggregate <input>
1702
+ mastra api trace aggregate '{"timeRange":{"from":"2026-08-01T00:00:00.000Z","to":"2026-08-08T00:00:00.000Z"},"groupBy":["entityName"],"measures":["count","errorRate"]}'
1703
+ ```
1704
+
1705
+ Set `interval` to `1m`, `5m`, `15m`, `1h`, or `1d` to split each group into time buckets:
1706
+
1707
+ ```bash
1708
+ mastra api trace aggregate '{"timeRange":{"from":"2026-08-01T00:00:00.000Z","to":"2026-08-08T00:00:00.000Z"},"where":{"op":"eq","left":{"path":"entityName"},"right":{"literal":"weather-agent"}},"interval":"1d","measures":["count","duration.p95"]}'
1709
+ ```
1710
+
1711
+ For dimensions, measures, and request options, see [Aggregate traces](https://mastra.ai/reference/client-js/observability). Run `mastra api trace aggregate --help` for more examples.
1712
+
1713
+ The response stays nested under `data` so `truncated` is preserved. `truncated` is `true` when more groups matched than `limit`:
1714
+
1715
+ ```json
1716
+ {
1717
+ "data": {
1718
+ "rows": [
1719
+ {
1720
+ "dimensions": { "entityName": "weather-agent" },
1721
+ "measures": { "count": 42, "errorRate": 0.05 }
1722
+ }
1723
+ ],
1724
+ "truncated": false
1725
+ }
1726
+ }
1727
+ ```
1728
+
1729
+ Servers whose observability store doesn't support trace aggregation return `501`. The CLI prints it like other request failures, as an `HTTP_ERROR` with the server response in `error.details.body`.
1695
1730
 
1696
1731
  #### `mastra api trace get`
1697
1732
 
@@ -2016,11 +2051,13 @@ Prints help message and exits.
2016
2051
 
2017
2052
  By default, Mastra collects telemetry about your project, including your OS, Mastra version, and Node.js version. Server events also include the project identifiers described below. You can read the [CLI telemetry source code](https://github.com/mastra-ai/mastra/blob/main/packages/cli/src/analytics/index.ts) to check what's collected by the CLI.
2018
2053
 
2019
- When a server started with `mastra dev` or `mastra start` has observability metrics enabled, Mastra sends aggregated model usage at startup: input and output token counts per provider and model, plus the command (`dev` or `start`) and `NODE_ENV`. No prompts, responses, or other message content is sent. You can read the [model usage telemetry source code](https://github.com/mastra-ai/mastra/blob/main/packages/core/src/telemetry/usage-telemetry.ts) to check what's collected.
2054
+ When a server started with `mastra dev`, `mastra start`, or a `mastra build` output has observability configured, Mastra counts the input and output tokens each model call uses in that server process. Every 15 minutes, and once more when the server shuts down, it sends a `mastra_model_token_usage_v2` event per provider and model used since the previous report. If no model calls finished since then, nothing is sent. Each event contains the tokens used since the previous report, the report window's start and end times, the reason for the report (`interval` or `shutdown`), the command (`dev`, `start`, or `server` when the build output runs directly), and `NODE_ENV`. No prompts, responses, or other message content is sent. You can read the [model usage telemetry source code](https://github.com/mastra-ai/mastra/blob/main/packages/core/src/telemetry/model-usage-telemetry.ts) to check what's collected.
2055
+
2056
+ For compatibility with older analysis, servers also send the earlier `mastra_model_token_usage` event at startup. It reads token totals from observability storage and sends the usage added since a cursor saved in `~/.mastra/usage-telemetry.json`. You can read the [startup usage telemetry source code](https://github.com/mastra-ai/mastra/blob/main/packages/core/src/telemetry/usage-telemetry.ts) to check what's collected.
2020
2057
 
2021
2058
  At server startup, Mastra sends a project-surface snapshot with component counts, feature flags, and the coarse storage backend category, but no component names or component identifiers. You can read the [feature telemetry source code](https://github.com/mastra-ai/mastra/blob/main/packages/core/src/telemetry/feature-telemetry.ts) to check what's collected.
2022
2059
 
2023
- The server events `mastra_feature_usage` and `mastra_model_token_usage` include:
2060
+ The server events `mastra_feature_usage`, `mastra_model_token_usage`, and `mastra_model_token_usage_v2` include:
2024
2061
 
2025
2062
  - `project_id`: The first 16 hexadecimal characters of the SHA-256 hash of `MASTRA_PROJECT_ROOT`, or the current working directory when unset. This identifier also keys the local model-usage cursor.
2026
2063
  - `project_id2`: An optional identifier for correlation across machines and deployments. If the trimmed `MASTRA_PROJECT_ID` value has UUID format, the value is sent **unhashed**, prefixed with `mp_`. Search for `mp_<platform-project-id>` to find that project's telemetry. Names, slugs, and other non-UUID values aren't sent as Platform identifiers.
@@ -111,6 +111,8 @@ Subscribes to the session's event stream over SSE. The promise resolves once the
111
111
 
112
112
  **reconnect** (`boolean | { maxRetries?: number; delayMs?: number; maxDelayMs?: number }`): Re-establishes the stream after an established stream drops. Retries back off exponentially from delayMs (default 1000) up to maxDelayMs (default 30000). maxRetries (default Infinity) bounds the attempts per outage and resets once a connection is re-established. When retries are exhausted, onError fires. A reconnect request that fails with a 4xx (other than 408 and 429) or 501 stops reconnecting immediately and passes that MastraClientError to onError.
113
113
 
114
+ **idleTimeoutMs** (`number`): Treats the stream as dropped after this many milliseconds without receiving any data. Server heartbeats, sent every 25 seconds, reset the timer, so only a silent connection, such as one left half-open by laptop sleep or a proxy timeout, trips it. A timeout is handled like any other drop: it triggers reconnect and onReconnect when reconnect is enabled, otherwise onError. Also bounds opening the stream: subscribe() rejects, and a reconnect attempt counts as failed, when no response arrives in time. Set to 0 to disable. (Default: `60000`)
115
+
114
116
  Returns: `Promise<AgentControllerSubscription>`, an object with an `unsubscribe()` method that stops reading and releases the stream.
115
117
 
116
118
  ### `sendMessage(message, options?)`
@@ -321,6 +321,26 @@ await subscription.processDataStream({
321
321
 
322
322
  Pass `withInitialHistory: true` (or `{ perPage }`) to receive the stored messages as a first `thread-history` chunk instead of fetching history separately. Finished runs aren't replayed after it, so completed answers don't stream again on reconnect.
323
323
 
324
+ In the React SDK, `useChat()` exposes the `hasMore` flag from that first page as `initialHistoryPagination`, so you can decide whether to offer loading older messages without another history request:
325
+
326
+ ```typescript
327
+ import { useChat } from '@mastra/react'
328
+
329
+ const { messages, initialHistoryPagination } = useChat({
330
+ agentId: 'support-agent',
331
+ resourceId: 'user-123',
332
+ threadId: 'thread-abc',
333
+ enableThreadSignals: true,
334
+ withInitialHistory: { perPage: 20 },
335
+ })
336
+
337
+ // { hasMore: true }: older messages exist
338
+ // { hasMore: false }: the page reaches the start of the thread
339
+ // undefined: history is disabled, still loading, or the subscription ended
340
+ ```
341
+
342
+ `initialHistoryPagination` only describes the initial subscription page for the current agent, resource, thread, and `withInitialHistory` value. It isn't changed by live output or `setMessages()`. After you load older pages yourself, use the `hasMore` value from those responses.
343
+
324
344
  `subscribeToThread()` returns the underlying `Response` plus a `processDataStream()` helper. The helper reads the subscription stream until the connection closes or the request is aborted. Pass `reconnect: true` to resubscribe when the transport closes or a reconnect request fails, such as after a proxy idle timeout. If a reconnect request fails with a 4xx status (for example `401` or `403`) or `501`, `processDataStream()` stops reconnecting and rejects with the original `MastraClientError`. `408` and `429` are still retried.
325
345
 
326
346
  **resourceId** (`string`): Resource ID for the memory thread.
@@ -65,6 +65,165 @@ const selected = await mastraClient.getTrace(list.spans[0].traceId)
65
65
 
66
66
  It accepts the same filtering, ordering and delta-polling arguments as `listTraces()`. Use `listTraces()` when you actually need the full span payloads.
67
67
 
68
+ ## Querying spans
69
+
70
+ `querySpans()` returns completed span summaries across traces. It requires a positive ISO timestamp range over span start time and supports cursor pagination:
71
+
72
+ ```typescript
73
+ const result = await mastraClient.querySpans({
74
+ timeRange: {
75
+ from: '2026-10-01T00:00:00.000Z',
76
+ to: '2026-10-02T00:00:00.000Z',
77
+ },
78
+ where: {
79
+ op: 'and',
80
+ args: [
81
+ { op: 'eq', left: { path: 'threadId' }, right: { literal: 'thread-123' } },
82
+ { op: 'gte', left: { path: 'durationMs' }, right: { literal: 1000 } },
83
+ ],
84
+ },
85
+ orderBy: [{ field: 'startedAt', direction: 'desc' }],
86
+ page: { limit: 100 },
87
+ })
88
+
89
+ // Pass result.page.next as page.after to continue with the same filters and ordering.
90
+ console.log(result.spans)
91
+ ```
92
+
93
+ Pages default to 100 rows and allow at most 1,000. The response is `{ spans, page: { next } }`, without a total count. Ordering accepts exactly one of `startedAt` or `endedAt`, ascending or descending, and defaults to descending start time.
94
+
95
+ | Fields | Operators |
96
+ | -------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
97
+ | `traceId`, `spanId`, `parentSpanId`, `threadId` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
98
+ | `organizationId`, `resourceId`, `runId`, `sessionId`, `userId`, `requestId`, `serviceName`, `experimentId`, `environment`, `executionSource` | Same string operators |
99
+ | Entity, parent entity and root entity `Type`, `Id`, `Name`, `VersionId` fields, such as `parentEntityId` | Same string operators |
100
+ | `name`, `spanType`, `status` | Same string operators; `name` also accepts `matches` / `notMatches` for normalized whole words and phrases |
101
+ | `startedAt`, `endedAt`, `durationMs` | Comparisons, membership and presence |
102
+ | `error` | `exists`, `notExists` |
103
+
104
+ Combine predicates with `and`, `or` and `not`. Membership uses `{ op: 'in', value: { path: 'spanType' }, set: ['agent_run', 'tool_call'] }`. A span's status is `error` when it has an error and `success` otherwise.
105
+
106
+ Each summary includes identity, context, entity lineage, status, timestamps, `durationMs`, model/provider and input/output/error previews. Model/provider are available in returned rows but aren't filterable.
107
+
108
+ The additional identity, context and parent/root entity filters require an updated storage adapter. With an older adapter, requests using these filters return a structured `422` error.
109
+
110
+ DuckDB returns `null` for parent/root entity type, ID and name, and for `executionSource`. Equality filters on these fields match no spans. Parent/root entity version IDs remain available.
111
+
112
+ ## Querying threads
113
+
114
+ `queryTraceThreads()` returns thread summaries from completed traces through `POST /observability/threads/query`. Each row includes activity timestamps, trace counts, context and previews. Traces without a thread ID aren't included.
115
+
116
+ ```typescript
117
+ const result = await mastraClient.queryTraceThreads({
118
+ timeRange: {
119
+ traces: {
120
+ from: '2026-10-01T00:00:00.000Z',
121
+ to: '2026-10-02T00:00:00.000Z',
122
+ },
123
+ },
124
+ where: { op: 'eq', left: { path: 'status' }, right: { literal: 'error' } },
125
+ orderBy: [{ field: 'endedAt', direction: 'desc' }],
126
+ page: { limit: 100 },
127
+ })
128
+
129
+ for (const thread of result.threads) {
130
+ console.log(thread.firstTraceId, thread.lastTraceId, thread.traceCount, thread.outputPreview)
131
+ }
132
+ ```
133
+
134
+ ### Thread time ranges
135
+
136
+ Choose exactly one time selector. Each range requires ISO timestamps with `from` earlier than `to`. The range includes `from` and excludes `to`.
137
+
138
+ | Selector | Matches threads with |
139
+ | ----------------------------------------------------- | --------------------------------------------- |
140
+ | `timeRange.traces: { from, to }` | At least one trace that started in the window |
141
+ | `timeRange.threads: { field: 'startedAt', from, to }` | Their first activity in the window |
142
+ | `timeRange.threads: { field: 'endedAt', from, to }` | Their last activity in the window |
143
+
144
+ For example, find threads whose most recent activity falls on October 1:
145
+
146
+ ```typescript
147
+ const result = await mastraClient.queryTraceThreads({
148
+ timeRange: {
149
+ threads: {
150
+ field: 'endedAt',
151
+ from: '2026-10-01T00:00:00.000Z',
152
+ to: '2026-10-02T00:00:00.000Z',
153
+ },
154
+ },
155
+ })
156
+ ```
157
+
158
+ Rows include the full retained history within the authorized scope, including traces before and after the window. Filters apply to these complete rows. An `environment` filter checks the first trace's environment.
159
+
160
+ ### Thread filters
161
+
162
+ Use `where` to filter thread rows. Combine predicates with `and`, `or` and `not`.
163
+
164
+ | Fields | Operators |
165
+ | -------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
166
+ | `threadId`, `organizationId`, `firstTraceId`, `lastTraceId` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
167
+ | `resourceId`, `userId`, `runId`, `sessionId`, `requestId`, `serviceName`, `experimentId`, `environment`, `executionSource` | Same string operators |
168
+ | `entityType`, `entityId`, `entityName`, `entityVersionId` | Same string operators |
169
+ | `status` | `eq`, `ne`, `in`, `notIn`, with values `success` or `error` |
170
+ | `startedAt`, `endedAt`, `timeToFirstChunkMs` | `eq`, `ne`, `lt`, `lte`, `gt`, `gte`, `in`, `notIn`, `exists`, `notExists` |
171
+ | `traceCount` | `eq`, `ne`, `lt`, `lte`, `gt`, `gte` |
172
+
173
+ For example, filter for threads from selected agents with at least three traces:
174
+
175
+ ```typescript
176
+ const result = await mastraClient.queryTraceThreads({
177
+ timeRange: {
178
+ traces: {
179
+ from: '2026-10-01T00:00:00.000Z',
180
+ to: '2026-10-02T00:00:00.000Z',
181
+ },
182
+ },
183
+ where: {
184
+ op: 'and',
185
+ args: [
186
+ { op: 'in', value: { path: 'entityId' }, set: ['support-agent', 'sales-agent'] },
187
+ { op: 'gte', left: { path: 'traceCount' }, right: { literal: 3 } },
188
+ ],
189
+ },
190
+ })
191
+ ```
192
+
193
+ Presence filters use `{ op: 'exists', path: 'userId' }` to check for a non-null value. Model/provider and previews are available in returned rows but aren't filterable.
194
+
195
+ ### Thread response
196
+
197
+ The response is `{ threads, page: { next } }`, without a total count. Each entry in `threads` contains these fields:
198
+
199
+ | Returned fields | Meaning |
200
+ | -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
201
+ | `threadId`, `organizationId` | Thread identity. Equal thread IDs in different organizations remain separate. |
202
+ | `firstTraceId`, `lastTraceId` | Earliest and latest trace by start time. Equal start times use trace ID as a deterministic tie-breaker. |
203
+ | `resourceId`, `userId`, `runId`, `sessionId`, `requestId`, `serviceName`, `experimentId`, `environment`, `executionSource` | First-trace context, or `null` when missing. |
204
+ | `entityType`, `entityId`, `entityName`, `entityVersionId` | First-trace entity. |
205
+ | `startedAt`, `endedAt` | Earliest start and maximum end time across the thread. |
206
+ | `status` | `error` when the last-started trace's root span has an error, otherwise `success`. |
207
+ | `traceCount` | Number of logical traces in the thread. |
208
+ | `inputPreview` | First trace's input preview. |
209
+ | `outputPreview`, `errorPreview` | Last-started trace's previews. |
210
+ | `timeToFirstChunkMs` | First trace's root agent time to first chunk, in milliseconds. `null` when unavailable or the root isn't an agent. |
211
+ | `model`, `provider` | Model/provider from the first completed model generation directly under the first trace's root agent. `null` when unavailable. |
212
+
213
+ An earlier-started trace can finish last. In that case, it supplies `endedAt`, while the last-started trace still supplies status and output/error previews. Missing first-trace values aren't replaced with values from a later trace.
214
+
215
+ ### Thread ordering and pagination
216
+
217
+ Ordering accepts exactly one of `startedAt` or `endedAt`, with direction `asc` or `desc`. The default is `endedAt` descending. Pages default to 100 rows and allow at most 1,000. Pass `result.page.next` as `page.after` with the same time selector, filters, scope and ordering. A `null` cursor means no more pages are available. Pagination reflects live data, so new traces can move a thread between pages.
218
+
219
+ To load the traces within a thread, use [`queryTraces()`](#querying-traces) with a `threadId` filter and a time range covering the thread's activity.
220
+
221
+ ### Thread query support
222
+
223
+ Check `capabilities.threadQueryRows` from `getObservabilityCapabilities()` before using this contract. A missing or false value means full thread rows aren't available. Older core or storage packages return a structured `501` for these requests. Legacy identity requests remain supported for mixed package versions.
224
+
225
+ ClickHouse rejects broad thread queries when the authorized history exceeds 250,000 stored trace-root rows, including duplicate copies. A narrower time range can still succeed by selecting fewer candidate threads. Rejected queries return `503 TRACE_QUERY_RESOURCE_LIMIT` without partial results.
226
+
68
227
  ## Querying traces
69
228
 
70
229
  `queryTraces()` finds completed logical traces using trace fields and conditions over related spans. Every query requires an ISO timestamp range.
@@ -89,7 +248,7 @@ const result = await mastraClient.queryTraces({
89
248
  })
90
249
  ```
91
250
 
92
- See [Trace queries](https://mastra.ai/reference/observability/tracing/trace-query) for request fields, predicates, limits, response shapes, and errors.
251
+ See [Query traces](https://mastra.ai/reference/observability/tracing/advanced-queries) for request fields, predicates, limits, response shapes, and errors.
93
252
 
94
253
  ### Load a page and poll for traces
95
254
 
@@ -116,7 +275,7 @@ const changes = await mastraClient.queryTraces({
116
275
 
117
276
  Merge `changes.traces` by `traceId`, retain `changes.deltaCursor`, and continue while `changes.delta.hasMore` is `true`. Keep the same time range and predicate across polls. Only completed traces are returned; polling doesn't guarantee notifications for related-record updates, deletions, or traces that stop matching.
118
277
 
119
- See [Delta polling](https://mastra.ai/reference/observability/tracing/trace-query) for bootstrap behavior, cursor lifetime, retention, and a complete polling loop.
278
+ See [Delta polling](https://mastra.ai/reference/observability/tracing/advanced-queries) for bootstrap behavior, cursor lifetime, retention, and a complete polling loop.
120
279
 
121
280
  ### Aggregate traces
122
281
 
@@ -141,9 +300,9 @@ if (capabilities.traceAggregate) {
141
300
  }
142
301
  ```
143
302
 
144
- Each row has `dimensions` keyed by `groupBy` field, `measures` keyed by measure name, a `bucket` timestamp when `interval` is set, and `cost` coverage when a cost measure is requested. `truncated` is `true` when more groups matched than `limit`.
303
+ Each row has `dimensions` keyed by `groupBy` field, `measures` keyed by measure name, a `bucket` timestamp when `interval` is set, and `cost` coverage when a cost measure is requested. `truncated` is `true` when more groups matched than `limit`. Check `capabilities.traceAggregate` before calling. The client retries server errors like `queryTraces()` but doesn't retry `422` validation errors.
145
304
 
146
- Check `capabilities.traceAggregate` before calling. Unlike `traceQuery`, a missing value means the server doesn't support aggregation. The client retries server errors like `queryTraces()` but doesn't retry `422` validation errors.
305
+ See [Aggregate traces](https://mastra.ai/reference/observability/tracing/advanced-queries) for dimensions, measures, token and cost semantics, time buckets, limits, and errors.
147
306
 
148
307
  ### Discover trace-query fields and values
149
308
 
@@ -163,7 +322,7 @@ const fields = await mastraClient.getTraceQueryFields({
163
322
  })
164
323
  ```
165
324
 
166
- For the `trace` scope on a server that supports aggregation, the response also includes `aggregate`: the `dimensions` you can pass to `groupBy` and the `measures` you can request. Every observed metadata field is also a dimension, and `countDistinct.<field>` accepts any dimension or `traceId`.
325
+ For the `trace` scope on a server that supports aggregation, the response also includes `aggregate`: the `dimensions` you can pass to `groupBy` and the `measures` you can request. See [Discover fields and values](https://mastra.ai/reference/observability/tracing/advanced-queries).
167
326
 
168
327
  Use the exact local path from the response with the same scope. For example, `model` belongs inside a `spans.some` or `spans.none` predicate. A field picker can fetch the `trace` and `spans` scopes in parallel.
169
328
 
@@ -341,7 +500,7 @@ const ratingPercentiles = await mastraClient.getFeedbackPercentiles({
341
500
 
342
501
  ## Related
343
502
 
344
- - [Trace queries](https://mastra.ai/reference/observability/tracing/trace-query): Query completed traces with recursive predicates
503
+ - [Advanced trace queries](https://mastra.ai/reference/observability/tracing/advanced-queries): Query and aggregate completed traces with recursive predicates
345
504
  - [Feedback guide](https://mastra.ai/docs/observability/feedback): Learn how to create, list, and query feedback
346
505
  - [Feedback reference](https://mastra.ai/reference/observability/feedback): Review feedback schemas and HTTP routes
347
506
  - [Agents API](https://mastra.ai/reference/client-js/agents): Learn about agent interactions that generate traces
@@ -99,6 +99,8 @@ export const mastra = new Mastra({
99
99
 
100
100
  **waitTimeoutMs** (`number`): How long the agentic loop waits for a background task to complete before moving on. If a task has not finished within this time, the loop proceeds without setting isContinued. Default: undefined (do not wait). Can be overridden per-agent or per-tool.
101
101
 
102
+ **untilIdleMaxIdleMs** (`number`): Default idle timeout, in milliseconds, for agent.stream(..., { untilIdle: true }) calls that do not set maxIdleMs. The stream closes when background tasks are still running but no event has arrived for this long. Set it above your longest expected background task so its completion still triggers a continuation turn. A per-call untilIdle: { maxIdleMs } takes precedence. Default: 5 minutes. (Default: `300000`)
103
+
102
104
  **onTaskComplete** (`(task: BackgroundTask) => void | Promise<void>`): Global callback invoked when any background task completes successfully. Fires in addition to per-tool and per-agent callbacks.
103
105
 
104
106
  **onTaskFailed** (`(task: BackgroundTask) => void | Promise<void>`): Global callback invoked when any background task fails. Fires in addition to per-tool and per-agent callbacks.
@@ -615,6 +617,34 @@ export const mastra = new Mastra({
615
617
  })
616
618
  ```
617
619
 
620
+ ### bundler.pnpmWorkspaceSettings
621
+
622
+ **Type:** `Record<string, JSONValue>`\
623
+ **Default:** `{}`
624
+
625
+ Explicit settings to write to the generated `pnpm-workspace.yaml` when installing deployment dependencies with pnpm. Values can be strings, numbers, booleans, null, arrays, or nested objects. Other package managers ignore this option.
626
+
627
+ Use this option for pnpm install-policy settings that your deployment install should follow:
628
+
629
+ ```typescript
630
+ import { Mastra } from '@mastra/core'
631
+
632
+ export const mastra = new Mastra({
633
+ bundler: {
634
+ pnpmWorkspaceSettings: {
635
+ blockExoticSubdeps: false,
636
+ minimumReleaseAge: 0,
637
+ },
638
+ },
639
+ })
640
+ ```
641
+
642
+ Explicit values override copied source settings. Omitting this option preserves the existing workspace-copy behavior; it doesn't copy all settings from the source workspace.
643
+
644
+ Only these keys are supported: `allowBuilds`, `onlyBuiltDependencies`, `ignoredBuiltDependencies`, `minimumReleaseAge`, `minimumReleaseAgeExclude`, `trustPolicy`, `trustPolicyExclude`, `trustPolicyIgnoreAfter`, and `blockExoticSubdeps`. Any other key throws an error before pnpm runs, including keys Mastra generates for deployment output (`packages`, `overrides`, `patchedDependencies`, `allowUnusedPatches`, `supportedArchitectures`, `nodeLinker`) and settings that change TLS verification, registries, network access, store integrity, dependency extensions, catalogs, or build-script permissions. `neverBuiltDependencies` is rejected because pnpm 10 runs every build script it doesn't list. This option doesn't accept command-line flags and isn't a place for secrets.
645
+
646
+ Explicit `allowBuilds` and `onlyBuiltDependencies` values use the same validation as copied source build approvals.
647
+
618
648
  ## Server options
619
649
 
620
650
  ### server.apiRoutes
@@ -18,9 +18,9 @@ export const mastra = new Mastra({
18
18
 
19
19
  Returns: `Promise<ChannelsResolver>`. See [The resolver](#the-resolver).
20
20
 
21
- The [documented channel setup](https://mastra.ai/docs/mastra-platform/connect/channels) covers Slack, Telegram, and Discord. Their implementations come from `@mastra/slack`, `@mastra/telegram`, and `@mastra/discord`, loaded on demand. Use those packages directly to configure a channel outside the platform connection flow.
21
+ The [documented channel setup](https://mastra.ai/docs/mastra-platform/connect/channels) covers Slack, Telegram, Discord, and Microsoft Teams. Their implementations come from `@mastra/slack`, `@mastra/telegram`, `@mastra/discord`, and `@mastra/teams`, loaded on demand. Use those packages directly to configure a channel outside the platform connection flow.
22
22
 
23
- The SDK also registers `microsoft-teams`, backed by `@mastra/teams`. SDK registration doesn't guarantee availability in the platform catalog. Constructing the Teams provider requires `MASTRA_ENCRYPTION_KEY`, a base64-encoded 32-byte value for protecting stored bot secrets. Without it, the resolver warns and skips Teams, including its routes.
23
+ The Teams provider encrypts stored bot secrets with `MASTRA_ENCRYPTION_KEY` when set. When it isn't, the key is derived from the platform access token and a warning is logged while a Teams connection is active. Rotating the platform access token makes stored bot credentials unreadable (disconnect and reconnect to re-provision). Projects without a Teams connection are unaffected.
24
24
 
25
25
  ## Parameters
26
26
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  # Provider toolsets
6
6
 
7
- This page documents generated toolsets for 21 providers (883 tools in this version of `@mastra/connect`). It isn't an exhaustive list of providers registered in the SDK or available in the platform catalog. [`tools()`](https://mastra.ai/reference/connect/tools) exposes a provider's toolset when the project has an active connection for its provider ID.
7
+ This page documents generated toolsets for 22 providers (910 tools in this version of `@mastra/connect`). It isn't an exhaustive list of providers registered in the SDK or available in the platform catalog. [`tools()`](https://mastra.ai/reference/connect/tools) exposes a provider's toolset when the project has an active connection for its provider ID.
8
8
 
9
9
  Tool keys are stable identifiers of the form `<provider>_<action>` and are the values accepted by `allowTools` and `disallowTools`. Toolsets are versioned with the package: the exact list depends on the installed `@mastra/connect` version, and this page reflects the version it was generated from.
10
10
 
@@ -18,13 +18,14 @@ MCP providers (Attio, Canva, Clay, Neon, Render, Robinhood, and Sanity) serve th
18
18
  | ![](https://cdn.simpleicons.org/github?viewbox=auto\&size=28) [GitHub](#github) | `github` | 49 |
19
19
  | ![](https://cdn.simpleicons.org/googlecalendar?viewbox=auto\&size=28) [Google Calendar](#google-calendar) | `google-calendar` | 43 |
20
20
  | ![](https://cdn.simpleicons.org/googledocs?viewbox=auto\&size=28) [Google Docs](#google-docs) | `google-docs` | 37 |
21
- | ![](https://cdn.simpleicons.org/googledrive?viewbox=auto\&size=28) [Google Drive](#google-drive) | `google-drive` | 30 |
21
+ | ![](https://cdn.simpleicons.org/googledrive?viewbox=auto\&size=28) [Google Drive](#google-drive) | `google-drive` | 32 |
22
22
  | ![](https://cdn.simpleicons.org/gmail?viewbox=auto\&size=28) [Gmail](#gmail) | `google-mail` | 52 |
23
23
  | ![](https://cdn.simpleicons.org/googlesheets?viewbox=auto\&size=28) [Google Sheets](#google-sheets) | `google-sheet` | 18 |
24
24
  | ![](https://cdn.simpleicons.org/hubspot?viewbox=auto\&size=28) [HubSpot](#hubspot) | `hubspot` | 50 |
25
25
  | ![](https://app.nango.dev/images/template-logos/incident-io.svg) [incident.io](#incidentio) | `incident-io` | 66 |
26
26
  | ![](https://cdn.simpleicons.org/jira?viewbox=auto\&size=28) [Jira](#jira) | `jira` | 38 |
27
27
  | ![](https://cdn.simpleicons.org/linear?viewbox=auto\&size=28) [Linear](#linear) | `linear` | 46 |
28
+ | ![](https://cdn.simpleicons.org/microsoftteams?viewbox=auto\&size=28) [Microsoft Teams](#microsoft-teams) | `microsoft-teams` | 25 |
28
29
  | ![](https://cdn.simpleicons.org/notion?viewbox=auto\&size=28) [Notion](#notion) | `notion` | 44 |
29
30
  | ![](https://svgl.app/library/openai.svg) [OpenAI](#openai) | `openai` | 26 |
30
31
  | ![](https://cdn.simpleicons.org/posthog?viewbox=auto\&size=28) [PostHog](#posthog) | `posthog` | 67 |
@@ -310,7 +311,7 @@ Provider ID: `google-docs` · 37 tools
310
311
 
311
312
  ## Google Drive
312
313
 
313
- Provider ID: `google-drive` · 30 tools
314
+ Provider ID: `google-drive` · 32 tools
314
315
 
315
316
  | Tool | Description |
316
317
  | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
@@ -323,6 +324,7 @@ Provider ID: `google-drive` · 30 tools
323
324
  | `google_drive_delete_permission` | Remove a permission from a file |
324
325
  | `google_drive_delete_shared_drive` | Delete a shared drive |
325
326
  | `google_drive_empty_trash` | Permanently delete all trashed files |
327
+ | `google_drive_export_file` | Export a Google Workspace file (Doc, Sheet, Slide, etc.) to the specified MIME type. |
326
328
  | `google_drive_find_file` | Search for files by name or query in Google Drive |
327
329
  | `google_drive_find_folder` | Search for a folder by name or query |
328
330
  | `google_drive_get_about` | Get the user's drive info and storage quota |
@@ -337,6 +339,7 @@ Provider ID: `google-drive` · 30 tools
337
339
  | `google_drive_list_drives` | List shared drives the user can access, with cursor pagination and drive metadata like hidden, capabilities, and restrictions. |
338
340
  | `google_drive_list_files_non_unified` | List immediate files and folders for a folder ID, or root when omitted, with cursor pagination and shared-drive support. |
339
341
  | `google_drive_list_permissions` | List permissions on a file |
342
+ | `google_drive_list_revisions` | List the revision history for a Drive file. |
340
343
  | `google_drive_move_file` | Move a file to a different folder |
341
344
  | `google_drive_unhide_shared_drive` | Restore a hidden shared drive to default view |
342
345
  | `google_drive_update_comment` | Update a comment on a file |
@@ -657,6 +660,38 @@ Provider ID: `linear` · 46 tools
657
660
  | `linear_update_issue_relation` | Update fields on an existing Linear issue relation. |
658
661
  | `linear_update_project` | Update an existing Linear project. |
659
662
 
663
+ ## Microsoft Teams
664
+
665
+ Provider ID: `microsoft-teams` · 25 tools
666
+
667
+ | Tool | Description |
668
+ | ------------------------------------------ | ------------------------------------------------ |
669
+ | `microsoft_teams_add_team_member` | Add a member to a team |
670
+ | `microsoft_teams_create_channel` | Create a channel in a team. |
671
+ | `microsoft_teams_create_channel_message` | Post a root message in a channel |
672
+ | `microsoft_teams_create_channel_tab` | Add a tab to a channel. |
673
+ | `microsoft_teams_create_chat` | Create a one-on-one or group chat. |
674
+ | `microsoft_teams_create_chat_message` | Send a message in a chat |
675
+ | `microsoft_teams_create_team` | Create a team from a template or existing group. |
676
+ | `microsoft_teams_delete_channel` | Delete a channel from a team |
677
+ | `microsoft_teams_get_channel` | Retrieve a channel by ID. |
678
+ | `microsoft_teams_get_channel_message` | Retrieve a channel message by ID. |
679
+ | `microsoft_teams_get_chat` | Retrieve a chat by ID. |
680
+ | `microsoft_teams_get_chat_message` | Retrieve a chat message by ID. |
681
+ | `microsoft_teams_get_team` | Retrieve a team by ID. |
682
+ | `microsoft_teams_list_channel_messages` | List root messages in a channel. |
683
+ | `microsoft_teams_list_channel_replies` | List replies under a channel message thread |
684
+ | `microsoft_teams_list_channel_tabs` | List tabs configured on a channel. |
685
+ | `microsoft_teams_list_channels` | List channels in a team. |
686
+ | `microsoft_teams_list_chat_members` | List members in a chat |
687
+ | `microsoft_teams_list_chat_messages` | List messages in a chat. |
688
+ | `microsoft_teams_list_chats` | List chats for a user. |
689
+ | `microsoft_teams_list_joined_teams` | List teams the user has joined |
690
+ | `microsoft_teams_list_team_members` | List members in a team. |
691
+ | `microsoft_teams_remove_team_member` | Remove a member from a team. |
692
+ | `microsoft_teams_reply_to_channel_message` | Reply to a channel message thread. |
693
+ | `microsoft_teams_update_channel` | Update mutable channel properties. |
694
+
660
695
  ## Notion
661
696
 
662
697
  Provider ID: `notion` · 44 tools
@@ -25,7 +25,7 @@ See [Connect](https://mastra.ai/docs/mastra-platform/connect/overview) to get st
25
25
 
26
26
  ## Parameters
27
27
 
28
- **options** (`ToolsOptions`): Optional discovery and client configuration.
28
+ **options** (`ToolsOptions | ((ctx?: ToolsResolverContext) => ToolsOptions | Promise<ToolsOptions>)`): Optional discovery and client configuration, or a callback returning it per request. See Per-request options below.
29
29
 
30
30
  **options.projectId** (`string`): Platform project whose connections to discover. Falls back to MASTRA\_PROJECT\_ID.
31
31
 
@@ -41,6 +41,25 @@ See [Connect](https://mastra.ai/docs/mastra-platform/connect/overview) to get st
41
41
 
42
42
  **options.ttlMs** (`number`): How long a resolved snapshot stays fresh, in milliseconds. Default 30000. 0 revalidates on every resolution.
43
43
 
44
+ ### Per-request options
45
+
46
+ Pass a callback instead of an options object to vary options per request, for example role-based filters or approval policies. The callback runs on every resolution (sync or async) and receives the same context Mastra passes the resolver (`requestContext` is populated when the resolver is an agent's `tools` option):
47
+
48
+ ```typescript
49
+ const connected = tools(ctx => ({
50
+ providers: {
51
+ linear:
52
+ ctx?.requestContext?.get('role') === 'viewer'
53
+ ? { allowTools: ['linear_list_*'] }
54
+ : { requireApproval: ['linear_delete_*'] },
55
+ },
56
+ }))
57
+ ```
58
+
59
+ The resolver memoizes snapshots per distinct options value, so requests producing the same options share one cached snapshot with the usual `ttlMs` and stale-while-revalidate semantics. Structurally equal options returned from different calls count as the same value; non-serializable values such as a custom `client.fetch` compare by identity. The resolver keeps caches for at most 32 distinct options values and evicts the least recently used one (closing its MCP transports) past that, so derive options from a small, closed set of inputs such as roles, not from unbounded per-request data.
60
+
61
+ With the callback form, option validation runs at the first resolution that produces a given options value rather than at `tools()` time, and a validation error fails that resolution. `refresh()` fetches for the options the callback returns without a context (the same variant a direct `await connected()` call uses), and `disconnect()` closes every memoized variant.
62
+
44
63
  ### Per-provider options
45
64
 
46
65
  Each value in the `providers` record form is `true`, `false`, or a `ToolsProviderOptions`:
@@ -89,7 +108,7 @@ The resolver also exposes methods for manual control:
89
108
 
90
109
  Errors fall into four groups:
91
110
 
92
- - Configuration errors (missing project ID or token, a malformed provider ID, both `allowTools` and `disallowTools` at one level, invalid `ttlMs`) throw when you call `tools()`.
111
+ - Configuration errors (missing project ID or token, a malformed provider ID, both `allowTools` and `disallowTools` at one level, invalid `ttlMs`) throw when you call `tools()`. With [the callback form](#per-request-options), they fail the first resolution that produces the invalid options instead.
93
112
  - An enabled provider ID that the platform catalog confirms is unknown fails the resolution with `invalid_options`. An unknown tool key or zero-match glob in a per-provider filter does the same. If the catalog can't be reached, an unknown ID downgrades to a warning and is skipped.
94
113
  - If a background refresh fails while a snapshot is cached, the resolver keeps serving the cached toolsets and warns. It rejects only when nothing was ever cached.
95
114
  - A problem with one provider, such as a connection that needs reauthorization, logs a warning and skips that provider. The other providers' tools still load.
@@ -147,6 +147,12 @@ Re-drives every orphaned `running` durable-agent run across all registered durab
147
147
 
148
148
  Requires persistent storage. With an in-memory store, there's nothing to recover after a process restart.
149
149
 
150
+ Agents and their runs are attempted serially. Each built-in `recoverActiveRuns()` attempt waits up to 30 seconds in total for `recover()` setup and settlement of the whole recovered workflow, then traversal can continue to later runs and agents. This isn't an overall recovery deadline: discovery and overridden custom recovery methods aren't bounded by this budget.
151
+
152
+ A timed-out attempt continues in the background. Its outcome is `status: 'skipped'` with `reason: 'recovery-timeout'` and no `retryAt`. It contributes only to `skipped`, not `recovered`, `succeeded`, or `failed`, and Mastra doesn't automatically retry it. Late settlement doesn't change the returned counts.
153
+
154
+ When shutdown begins, recovery stops dispatching new agents and runs. The recovery traversal and original attempts, including timed-out setup or execution, participate in the same shared shutdown drain as active executions. A recovery wait timeout doesn't cancel the attempt or give it a separate shutdown drain window.
155
+
150
156
  A run that another execution still drives isn't taken over. It's counted in `skipped` and checked again once that execution's claim could have lapsed, so a run whose process crashed is recovered without another call. `shutdown()` cancels pending re-checks. See [run ownership](https://mastra.ai/docs/harness/durable-agents).
151
157
 
152
158
  ```typescript
@@ -164,4 +170,4 @@ Returns:
164
170
 
165
171
  **failed** (`number`): Runs whose restart threw an error.
166
172
 
167
- **skipped** (`number`): Runs that another execution still drives. Each is checked again later.
173
+ **skipped** (`number`): Runs skipped because they are already active, recovery is already in progress, or the recovery wait timed out. Only ownership skips eligible for re-checks are checked again; recovery timeouts are not automatically retried.
@@ -32,13 +32,19 @@ const filtered = await mastra.datasets.list({
32
32
  const forAgents = await mastra.datasets.list({
33
33
  filters: { targetIds: ['agent-a', 'agent-b'] },
34
34
  })
35
+
36
+ // Fetch specific datasets by ID, all on one page
37
+ const byId = await mastra.datasets.list({
38
+ perPage: false,
39
+ filters: { datasetIds: ['dataset-1', 'dataset-2'] },
40
+ })
35
41
  ```
36
42
 
37
43
  ## Parameters
38
44
 
39
45
  **page** (`number`): Page number. Defaults to 0.
40
46
 
41
- **perPage** (`number`): Number of datasets per page. Defaults to 20.
47
+ **perPage** (`number | false`): Number of datasets per page, or false to return every match on one page. Defaults to 20.
42
48
 
43
49
  **filters** (`object`): Optional filters applied at the storage layer.
44
50
 
@@ -54,6 +60,8 @@ const forAgents = await mastra.datasets.list({
54
60
 
55
61
  **filters.targetIds** (`string[]`): Restrict to datasets whose targetIds intersect this list (any-overlap match). Empty array is treated as no filter.
56
62
 
63
+ **filters.datasetIds** (`string[]`): Restrict to datasets with these IDs. Empty array matches no datasets. Pass perPage: false to get every match on one page.
64
+
57
65
  **filters.name** (`string`): Case-insensitive substring match on dataset name. Empty string is treated as no filter.
58
66
 
59
67
  ## Returns
@@ -183,6 +183,7 @@ The factory also accepts `name` and `description` from `createScorer()`.
183
183
  Failures while the scorer runs reject `scorer.run()` with a `ScorerRunError` whose `failedStep` is `analyze`, and the original error is available as its `cause`. This covers:
184
184
 
185
185
  - Classifier evaluation fails or doesn't return an answer for the selected question.
186
+ - The decision model refuses the selected question. The error names the classifier, the question, and the scorer.
186
187
  - A classifier ID is used before the scorer is registered with Mastra, or the ID isn't present in `classifiers`.
187
188
  - A registered classifier has an invalid configuration for this scorer.
188
189
 
@@ -266,11 +266,11 @@ The Reference section provides documentation of Mastra's API, including paramete
266
266
  - [Automatic Metrics](https://mastra.ai/reference/observability/metrics/automatic-metrics)
267
267
  - [Metric queries](https://mastra.ai/reference/observability/metrics/queries)
268
268
  - [Configuration](https://mastra.ai/reference/observability/tracing/configuration)
269
+ - [Advanced trace queries](https://mastra.ai/reference/observability/tracing/advanced-queries)
269
270
  - [Instances](https://mastra.ai/reference/observability/tracing/instances)
270
271
  - [Interfaces](https://mastra.ai/reference/observability/tracing/interfaces)
271
272
  - [Span filtering](https://mastra.ai/reference/observability/tracing/span-filtering)
272
273
  - [Spans](https://mastra.ai/reference/observability/tracing/spans)
273
- - [Trace queries](https://mastra.ai/reference/observability/tracing/trace-query)
274
274
  - [AgentsMDInjector](https://mastra.ai/reference/processors/agents-md-injector)
275
275
  - [BatchPartsProcessor](https://mastra.ai/reference/processors/batch-parts-processor)
276
276
  - [ClassifierProcessor](https://mastra.ai/reference/processors/classifier-processor)