@mastra/client-js 1.56.0-alpha.7 → 1.56.0-alpha.9

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/dist/client.d.ts CHANGED
@@ -52,7 +52,7 @@ export declare class MastraClient extends BaseResource {
52
52
  listAgentControllers(): Promise<AgentControllerInfo[]>;
53
53
  /**
54
54
  * Scopes to an agent controller hosted on the connected Mastra instance. Use
55
- * `getAgentController(id).session(resourceId)` to create/resume a session,
55
+ * `getAgentController(id).session(sessionId)` to create/resume a session,
56
56
  * stream its events, and send messages.
57
57
  * @param controllerId - The id the agent controller is registered under on Mastra
58
58
  */
@@ -3,7 +3,7 @@ name: mastra-client-js
3
3
  description: Documentation for @mastra/client-js. Use when working with @mastra/client-js APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/client-js"
6
- version: "1.56.0-alpha.7"
6
+ version: "1.56.0-alpha.9"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.56.0-alpha.7",
2
+ "version": "1.56.0-alpha.9",
3
3
  "package": "@mastra/client-js",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -90,43 +90,40 @@ Use the same controller for many Sessions. Don't store a current Session on the
90
90
  The controller, Session, and thread have different lifetimes:
91
91
 
92
92
  - **Controller**: A shared host for configuration and runtime services. Initialize it once and reuse it.
93
- - **Session**: An isolated live runtime for one user, task, or concurrent work scope. It owns the active mode, model, state, event bus, run state, grants, and current thread binding.
93
+ - **Session**: An isolated live runtime for one user, task, or concurrent piece of work, addressed by its session id. It owns the active mode, model, state, event bus, run state, grants, and current thread binding.
94
94
  - **Thread**: A stored conversation containing messages and thread settings. Threads can survive controller and process recreation when you configure storage.
95
95
 
96
96
  A Session is live state. Arbitrary [`session.state`](https://mastra.ai/reference/agent-controller/session), permission grants, pending approvals, and active runs don't automatically survive process recreation. Thread messages and selected thread settings, including the active mode and the current model, can persist through storage, but switching modes doesn't change the model.
97
97
 
98
98
  ## Sessions and threads
99
99
 
100
- `createSession()` is get-or-create by `resourceId` and optional `scope`:
100
+ `createSession()` is get-or-create by session `id`. The `resourceId` names who owns the session's threads and resource-scoped memory. When you omit `id`, it defaults to `resourceId`:
101
101
 
102
102
  ```typescript
103
103
  const webSession = await controller.createSession({
104
+ id: 'user-123:web',
104
105
  resourceId: 'user-123',
105
- scope: 'web',
106
106
  })
107
107
 
108
- const sameWebSession = await controller.createSession({
109
- resourceId: 'user-123',
110
- scope: 'web',
111
- })
108
+ const sameWebSession = await controller.getSession('user-123:web')
112
109
 
113
110
  const workerSession = await controller.createSession({
111
+ id: 'user-123:background-worker',
114
112
  resourceId: 'user-123',
115
- scope: 'background-worker',
116
113
  })
117
114
 
118
115
  console.log(webSession === sameWebSession) // true
119
116
  console.log(webSession === workerSession) // false
120
117
  ```
121
118
 
122
- Sessions with different scopes have separate event buses, run loops, state, mode and model selections, and current thread bindings. Their stored threads still belong to the shared `resourceId`.
119
+ Sessions with different ids have separate event buses, run loops, state, mode and model selections, and current thread bindings. Their stored threads and resource-scoped memory still belong to the shared `resourceId`, so listing threads by resource returns both sessions' threads.
123
120
 
124
121
  Pass `threadId` when the host must bind the Session to an exact thread. The controller switches to the existing thread or creates it with that ID when it's missing. This behavior also applies when `createSession()` returns a cached Session:
125
122
 
126
123
  ```typescript
127
124
  const session = await controller.createSession({
125
+ id: 'user-123:web',
128
126
  resourceId: 'user-123',
129
- scope: 'web',
130
127
  threadId: 'support-ticket-42',
131
128
  })
132
129
  ```
@@ -430,9 +427,9 @@ channels: {
430
427
  const install = await installs.authorize(requestContext.get('teamId'))
431
428
 
432
429
  return controller.createSession({
430
+ id: `${install.id}:${thread.id}`,
433
431
  resourceId: thread.resourceId,
434
432
  threadId: thread.id,
435
- scope: install.id,
436
433
  ownerId: controller.id,
437
434
  requestContext,
438
435
  })
@@ -440,7 +437,7 @@ channels: {
440
437
  }
441
438
  ```
442
439
 
443
- Create the session under `thread.resourceId`. Because a session can bind only threads it owns, use `resolveResourceId` to assign a different owner to the mapped thread. Pass `threadId: thread.id` so the session opens on the mapped thread. Without it, a session that has tags or a `projectPath` doesn't treat the mapped thread as its own, so it creates an extra empty thread before switching to the mapped one. Sessions are get-or-create for each `resourceId` and `scope` combination. Pass `scope` when one thread needs separate sessions for each installation or principal.
440
+ Create the session under `thread.resourceId`. Because a session can bind only threads it owns, use `resolveResourceId` to assign a different owner to the mapped thread. Pass `threadId: thread.id` so the session opens on the mapped thread. Without it, a session that has tags or a `projectPath` doesn't treat the mapped thread as its own, so it creates an extra empty thread before switching to the mapped one. Sessions are get-or-create by `id`. Give each installation or principal its own `id` when one thread needs separate sessions.
444
441
 
445
442
  Failures that aren't refusals (a storage outage, a bug in your resolver's dependencies) still post an error to the thread, so a broken bot doesn't look like a silent one. If you need to tell them apart in your own code, a refusal is a `ChannelSessionRejectedError` with the original error as its `cause`.
446
443
 
@@ -490,7 +487,7 @@ Subscriptions are isolated by Session. Events from another Session on the same c
490
487
 
491
488
  ### Client-side sessions
492
489
 
493
- [`client.getAgentController(key).session(resourceId, scope?)`](https://mastra.ai/reference/client-js/agent-controller) returns a session client bound to one resource. Pass the key the controller is registered under in `new Mastra({ agentControllers })`, which can differ from the controller's `id`. Sessions are get-or-create on the server, so `create()` resumes an existing conversation instead of forking it. Pass `scope` when one resource needs independent sessions, such as one per git worktree:
490
+ [`client.getAgentController(key).session(sessionId)`](https://mastra.ai/reference/client-js/agent-controller) returns a session client addressed by its session id. Pass the key the controller is registered under in `new Mastra({ agentControllers })`, which can differ from the controller's `id`. Sessions are get-or-create on the server, so `create()` resumes an existing conversation instead of forking it. Pass `resourceId` to `create()` when several sessions share one resource; otherwise the resource defaults to the session id:
494
491
 
495
492
  ```typescript
496
493
  import { MastraClient } from '@mastra/client-js'
@@ -513,7 +510,7 @@ const subscription = await session.subscribe({
513
510
  subscription.unsubscribe()
514
511
  ```
515
512
 
516
- `subscribe()` takes an options object and is async, unlike the in-process listener. Its promise resolves once the stream is established and rejects when it can't connect. A rejected call leaves nothing running in the background. `reconnect: true` re-establishes a stream that drops after it was established, with exponential backoff. A connection that goes silent without closing, for example after the device sleeps, counts as a drop once no data, including server heartbeats, arrives for `idleTimeoutMs` (default `60000`).
513
+ `subscribe()` takes an options object and is async, unlike the in-process listener. Its promise resolves once the stream is established and rejects when it can't connect. A rejected call leaves nothing running in the background. `reconnect: true` re-establishes a stream that drops after it was established, with exponential backoff. A connection that stays open but stops delivering data, for example after the device sleeps, counts as a drop once no data, including server heartbeats, arrives for `idleTimeoutMs` (default `60000`).
517
514
 
518
515
  The server doesn't replay events missed while the stream was down, so read `session.state()` from `onReconnect` for the current mode, model, and thread. The client surface has no `session.displayState.get()`.
519
516
 
@@ -171,13 +171,13 @@ const mastra = new Mastra({
171
171
  return { prompt: `Status as of ${trigger.firedAt.toISOString()}` }
172
172
  },
173
173
  onFinish: async ({ agentId, outcome, runId }) => {
174
- // Runs on any non-error, non-abort outcome
174
+ // Runs on any non-error, non-abort outcome. For a threaded schedule, this is the hand-off, not the end of the run
175
175
  },
176
176
  onError: async ({ agentId, phase, error }) => {
177
- // Runs when prepare, the signal, or the agent run threw
177
+ // Runs when prepare or the signal threw, or a threadless run failed without aborting
178
178
  },
179
179
  onAbort: async ({ agentId, runId }) => {
180
- // Runs when the run was aborted mid-stream
180
+ // Runs when a threadless run was aborted
181
181
  },
182
182
  },
183
183
  })
@@ -186,9 +186,11 @@ const mastra = new Mastra({
186
186
  The hooks are:
187
187
 
188
188
  - `prepare`: runs before the fire. Return an object to override fire-time parameters such as `prompt` or `threadId`, `null` to skip the fire, or `undefined` to use the stored defaults.
189
- - `onFinish`: runs once per trigger that reached a non-error, non-abort terminal state.
190
- - `onError`: runs after a failure in `prepare` or the signal. It also runs when the agent run fails.
191
- - `onAbort`: runs when the run was aborted mid-stream.
189
+ - `onFinish`: runs once per trigger that reached a non-error, non-abort outcome. When a threaded schedule starts a new run, it runs with `outcome: 'succeeded'` as soon as the run starts, not when it finishes.
190
+ - `onError`: runs after a failure in `prepare` or the signal. For a schedule without a `threadId`, it also runs when the agent run fails with an error that isn't an abort.
191
+ - `onAbort`: runs when the run of a schedule without a `threadId` was aborted.
192
+
193
+ For a schedule with a `threadId`, the worker sends the prompt to the thread and doesn't wait for the run. Errors and aborts after the run starts surface on that thread's run, not through `onError` or `onAbort`.
192
194
 
193
195
  Every hook context includes `agentId` (the agent the schedule fired for) alongside `schedule` and `trigger`.
194
196
 
@@ -81,11 +81,19 @@ Returns the controller's workspace status.
81
81
 
82
82
  Returns: `Promise<AgentControllerWorkspaceStatus>`
83
83
 
84
- ### `session(resourceId, scope?)`
84
+ ### `session(sessionId)`
85
85
 
86
- Returns an `AgentControllerSession` bound to one resource. Sessions are get-or-create on the server, so calling `create()` on the same `resourceId` and `scope` resumes the existing conversation instead of forking it.
86
+ Returns an `AgentControllerSession` addressed by its session id. Every request goes to `/agent-controller/:controllerId/sessions/:sessionId/...`. Sessions are get-or-create on the server, so calling `create()` with the same `sessionId` resumes the existing conversation instead of forking it.
87
87
 
88
- Pass `scope` to address an independent session over the same `resourceId`. Sessions that share a `resourceId` but use different scopes each get their own run loop, thread binding, mode, model, and state. A common pattern is one session per git worktree with the worktree path as the scope. The scope travels on every request as a `sessionScope` query parameter.
88
+ Sessions that share a resource but use different session ids each get their own run loop, thread binding, mode, model, and state. Their stored threads and resource-scoped memory belong to the shared resource. Pass the resource to `create()`:
89
+
90
+ ```typescript
91
+ const runA = client.getAgentController('code').session('run-a')
92
+ await runA.create({ resourceId: 'factory-1' })
93
+
94
+ const runB = client.getAgentController('code').session('run-b')
95
+ await runB.create({ resourceId: 'factory-1' })
96
+ ```
89
97
 
90
98
  ## Session methods
91
99
 
@@ -93,6 +101,8 @@ Pass `scope` to address an independent session over the same `resourceId`. Sessi
93
101
 
94
102
  Creates or resumes the session.
95
103
 
104
+ **resourceId** (`string`): Memory resource that owns the session's threads. Defaults to the session id, so a session created with only an id keeps one resource of its own.
105
+
96
106
  **tags** (`Record<string, string>`): Scopes initial thread selection. A thread is a resume candidate only when its metadata matches every tag.
97
107
 
98
108
  **threadId** (`string`): Binds the session to one exact thread, creating it with that ID when it does not exist.
@@ -61,7 +61,7 @@ You can also pass `requestContext` as a `Record<string, any>`.
61
61
 
62
62
  **listAgentControllers()** (`Promise<AgentControllerInfo[]>`): Returns the agent controllers hosted on the connected Mastra instance. Each entry's id is the key the controller is registered under in new Mastra({ agentControllers }).
63
63
 
64
- **getAgentController(controllerId)** (`AgentController`): Retrieves a specific agent controller by the key it is registered under in new Mastra({ agentControllers }), which can differ from the controller id. .session(resourceId) returns a session client; call await session.create() to create or resume the server session.
64
+ **getAgentController(controllerId)** (`AgentController`): Retrieves a specific agent controller by the key it is registered under in new Mastra({ agentControllers }), which can differ from the controller id. .session(sessionId) returns a session client; call await session.create() to create or resume the server session.
65
65
 
66
66
  **listMemoryThreads(params)** (`Promise<StorageThreadType[]>`): Retrieves memory threads for the specified resource and agent. Requires a resourceId and an agentId.
67
67
 
@@ -90,7 +90,7 @@ const result = await mastraClient.querySpans({
90
90
  console.log(result.spans)
91
91
  ```
92
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.
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`, `endedAt`, or `timeToFirstChunkMs`, ascending or descending, and defaults to descending start time. Spans without a `timeToFirstChunkMs` value sort last in both directions.
94
94
 
95
95
  | Fields | Operators |
96
96
  | -------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
@@ -98,14 +98,14 @@ Pages default to 100 rows and allow at most 1,000. The response is `{ spans, pag
98
98
  | `organizationId`, `resourceId`, `runId`, `sessionId`, `userId`, `requestId`, `serviceName`, `experimentId`, `environment`, `executionSource` | Same string operators |
99
99
  | Entity, parent entity and root entity `Type`, `Id`, `Name`, `VersionId` fields, such as `parentEntityId` | Same string operators |
100
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 |
101
+ | `startedAt`, `endedAt`, `durationMs`, `timeToFirstChunkMs` | Comparisons, membership and presence |
102
102
  | `error` | `exists`, `notExists` |
103
103
 
104
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
105
 
106
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
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.
108
+ Check `capabilities.spanQueryContextFields` from `getObservabilityCapabilities()` before using the additional identity, context and parent/root entity filters. A missing or false value means these filters aren't available. With an older adapter, requests using these filters return a structured `422` error.
109
109
 
110
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
111
 
@@ -21,18 +21,20 @@ For hosted traces, see [Query observability data on Mastra Platform](https://mas
21
21
 
22
22
  The configured observability store must support each API. Call `getObservabilityCapabilities()` or `GET /api/observability/capabilities` and check these flags before showing a feature:
23
23
 
24
- | Capability | Store feature | Enables |
25
- | ---------------------------- | --------------------------------- | -------------------------------------------------------------------------------------- |
26
- | `traceQuery` | `trace-query` | `queryTraces()` |
27
- | `traceAggregate` | `trace-aggregate` | `aggregateTraces()` |
28
- | `traceQueryRootDuration` | `trace-query-root-duration` | Trace-scope `durationMs` predicates |
29
- | `traceQueryTimeToFirstChunk` | `trace-query-time-to-first-chunk` | `timeToFirstChunkMs` predicates and results |
30
- | `traceQueryContextIds` | `trace-query-context-ids` | `runId`, `sessionId`, `userId`, and `organizationId` predicates |
31
- | `traceQueryRootSpanFields` | `trace-query-root-span-fields` | Trace-scope `name` and `spanType` predicates, dimensions, and `countDistinct` measures |
32
- | `traceQueryDiscovery` | `trace-query-discovery` | [Field and value discovery](#discover-fields-and-values) |
33
- | `traceQueryTenantScope` | `trace-query-tenant-scope` | [Trusted tenant scope](#trusted-tenant-scope) |
34
-
35
- A missing `traceAggregate` value means the server doesn't support aggregation. Servers without the aggregate route return `404`, and stores without the feature return `501 TRACE_AGGREGATE_UNSUPPORTED`. Against a store without a sub-feature, a request that uses a gated field returns `501` before storage runs. Root span `name` and `spanType` are the exception and return `422` with a `field_not_allowed` issue.
24
+ | Capability | Store feature | Enables |
25
+ | -------------------------------- | -------------------------------------- | -------------------------------------------------------------------------------------- |
26
+ | `traceQuery` | `trace-query` | `queryTraces()` |
27
+ | `traceAggregate` | `trace-aggregate` | `aggregateTraces()` |
28
+ | `traceQueryRootDuration` | `trace-query-root-duration` | Trace-scope `durationMs` predicates |
29
+ | `traceQueryTimeToFirstChunk` | `trace-query-time-to-first-chunk` | `timeToFirstChunkMs` predicates and results |
30
+ | `traceQueryTimeToFirstChunkSort` | `trace-query-time-to-first-chunk-sort` | `orderBy` on `timeToFirstChunkMs` |
31
+ | `traceQueryContextIds` | `trace-query-context-ids` | `runId`, `sessionId`, `userId`, and `organizationId` predicates |
32
+ | `traceQueryRootSpanFields` | `trace-query-root-span-fields` | Trace-scope `name` and `spanType` predicates, dimensions, and `countDistinct` measures |
33
+ | `traceQueryRootEntityId` | `trace-query-root-entity-id` | Trace-scope `entityId` predicates, dimensions, and `countDistinct` measures |
34
+ | `traceQueryDiscovery` | `trace-query-discovery` | [Field and value discovery](#discover-fields-and-values) |
35
+ | `traceQueryTenantScope` | `trace-query-tenant-scope` | [Trusted tenant scope](#trusted-tenant-scope) |
36
+
37
+ A missing `traceAggregate` value means the server doesn't support aggregation. Servers without the aggregate route return `404`, and stores without the feature return `501 TRACE_AGGREGATE_UNSUPPORTED`. Against a store without a sub-feature, a request that uses a gated field returns `501` before storage runs. Root span `name`, `spanType`, and `entityId` are the exception and return `422` with a `field_not_allowed` issue.
36
38
 
37
39
  ## Select traces
38
40
 
@@ -75,7 +77,7 @@ Span clauses examine the current root span and current child spans. The root `ti
75
77
 
76
78
  | Predicate context | Fields | Operators |
77
79
  | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
78
- | Trace | `traceId`, `threadId`, `resourceId`, `runId`, `sessionId`, `userId`, `organizationId`, `entityName`, `entityType`, `name`, `spanType`, `environment`, `status` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
80
+ | Trace | `traceId`, `threadId`, `resourceId`, `runId`, `sessionId`, `userId`, `organizationId`, `entityId`, `entityName`, `entityType`, `name`, `spanType`, `environment`, `status` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
79
81
  | Trace metadata | `metadata.<key>` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
80
82
  | Trace | `startedAt`, `endedAt`, `durationMs`, `timeToFirstChunkMs` | `eq`, `ne`, `in`, `notIn`, `lt`, `lte`, `gt`, `gte`, `exists`, `notExists` |
81
83
  | Trace | `tags` | `includes`, `notIncludes`, `exists`, `notExists` |
@@ -84,7 +86,7 @@ Span clauses examine the current root span and current child spans. The root `ti
84
86
  | Span | `startedAt`, `endedAt`, `durationMs`, `timeToFirstChunkMs` | `eq`, `ne`, `in`, `notIn`, `lt`, `lte`, `gt`, `gte`, `exists`, `notExists` |
85
87
  | Span | `error` | `exists`, `notExists` |
86
88
 
87
- Trace-scope `name` and `spanType` read the current root span, so `{ op: 'eq', left: { path: 'spanType' }, right: { literal: 'workflow_run' } }` selects traces started by a workflow run. Inside `spans.some` or `spans.none`, the same fields match any span in the trace.
89
+ Trace-scope `name`, `spanType`, and `entityId` read the current root span, so `{ op: 'eq', left: { path: 'spanType' }, right: { literal: 'workflow_run' } }` selects traces started by a workflow run. Inside `spans.some` or `spans.none`, the same fields match any span in the trace.
88
90
 
89
91
  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`. Tag predicates name the stored tag collection in `path`. `includes` and `notIncludes` also take one tag in `value`, while `exists` and `notExists` take only `op` and `path`. See [Filter by tags](#filter-by-tags). Text predicates use the comparison shape with a string literal. See [Filter by text](#filter-by-text).
90
92
 
@@ -128,7 +130,13 @@ const slowFirstChunk = {
128
130
 
129
131
  The value is `null` when the span didn't stream a chunk, for example a tool call or a workflow run. A `null` value counts as missing, so it matches `notExists` and never matches ordered predicates. A value of `0` isn't missing. It means the first chunk arrived in the same millisecond the span started.
130
132
 
131
- Trace query results include the root span's `timeToFirstChunkMs`, and `querySpans()` results include each span's value. Sorting by this field isn't supported. Stores advertise support through the `trace-query-time-to-first-chunk` feature, and the server reports it as the `traceQueryTimeToFirstChunk` capability. Against an older store, results omit the field, a predicate on it returns `501` before storage runs, and field discovery omits it.
133
+ Trace query results include the root span's `timeToFirstChunkMs`, and `querySpans()` results include each span's value. Stores advertise support through the `trace-query-time-to-first-chunk` feature, and the server reports it as the `traceQueryTimeToFirstChunk` capability. Against an older store, results omit the field, a predicate on it returns `501` before storage runs, and field discovery omits it.
134
+
135
+ #### Sort by time to first chunk
136
+
137
+ Pass `orderBy: [{ field: 'timeToFirstChunkMs', direction: 'desc' }]` to list the slowest first chunks first. Traces sort by the root span's value. Missing values sort last in both directions, and `0` sorts as a value. Ties break by `traceId` for traces and by span identity for `querySpans()`.
138
+
139
+ Stores advertise the sort through the `trace-query-time-to-first-chunk-sort` feature, and the server reports it as the `traceQueryTimeToFirstChunkSort` capability. Against an older store, the sort returns `501` before storage runs.
132
140
 
133
141
  #### Filter by context identifiers
134
142
 
@@ -437,16 +445,16 @@ curl --request POST \
437
445
 
438
446
  ### Request fields
439
447
 
440
- | Field | Required | Description |
441
- | ------------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
442
- | `timeRange` | Yes | Trace start-time boundary. `from` is inclusive and `to` is exclusive. Both values must be ISO timestamps, and `from` must be earlier than `to`. |
443
- | `where` | No | Recursive trace predicate. Supports scalar conditions and `spans.some` or `spans.none` clauses. |
444
- | `orderBy` | No | One item ordering results by `startedAt` or `endedAt`, in `asc` or `desc` order. Defaults to `startedAt desc`. Not accepted in delta mode. |
445
- | `page` | No | `{ limit, after }`. `limit` defaults to 100 and has a maximum of 1000. Pass the opaque `page.next` value as `after`. |
446
- | `pagination` | No | Numbered pages: `{ page, perPage }`. Defaults to page 0 and 10 results. `perPage` has a maximum of 100. |
447
- | `mode` | No | Set to `'delta'` to poll using a delta cursor instead of `page` or `pagination`. |
448
- | `after` | No | Delta mode only. Opaque `deltaCursor` from a numbered page or previous poll. Omit to establish the current watermark. |
449
- | `limit` | No | Delta mode only. Maximum results per batch. Defaults to 10 and has a maximum of 100. |
448
+ | Field | Required | Description |
449
+ | ------------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
450
+ | `timeRange` | Yes | Trace start-time boundary. `from` is inclusive and `to` is exclusive. Both values must be ISO timestamps, and `from` must be earlier than `to`. |
451
+ | `where` | No | Recursive trace predicate. Supports scalar conditions and `spans.some` or `spans.none` clauses. |
452
+ | `orderBy` | No | One item ordering results by `startedAt`, `endedAt`, or `timeToFirstChunkMs`, in `asc` or `desc` order. Defaults to `startedAt desc`. Not accepted in delta mode. |
453
+ | `page` | No | `{ limit, after }`. `limit` defaults to 100 and has a maximum of 1000. Pass the opaque `page.next` value as `after`. |
454
+ | `pagination` | No | Numbered pages: `{ page, perPage }`. Defaults to page 0 and 10 results. `perPage` has a maximum of 100. |
455
+ | `mode` | No | Set to `'delta'` to poll using a delta cursor instead of `page` or `pagination`. |
456
+ | `after` | No | Delta mode only. Opaque `deltaCursor` from a numbered page or previous poll. Omit to establish the current watermark. |
457
+ | `limit` | No | Delta mode only. Maximum results per batch. Defaults to 10 and has a maximum of 100. |
450
458
 
451
459
  Unknown fields are rejected. Requests can't select a projection, declare joins, request counts or measures, or control authorization. Use [`aggregateTraces()`](#aggregate-traces) for counts and measures. Request bodies are limited to 256 KiB.
452
460
 
@@ -657,12 +665,13 @@ Unknown fields are rejected. Aggregation isn't paginated. Narrow the selection,
657
665
 
658
666
  Dimensions read the current root span of each selected trace:
659
667
 
660
- | Dimension | Notes |
661
- | ------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
662
- | `entityType`, `entityName`, `environment`, `status`, `serviceName`, `executionSource` | Root span attributes. |
663
- | `threadId`, `resourceId`, `userId`, `sessionId`, `organizationId`, `experimentId` | Context identifiers recorded on the root span. |
664
- | `name`, `spanType` | Root span name and type. Requires the `traceQueryRootSpanFields` capability. |
665
- | `metadata.<key>` | One non-empty top-level metadata key. Values are trimmed. Missing, empty, and non-string values group as `null`. |
668
+ | Dimension | Notes |
669
+ | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
670
+ | `entityType`, `entityName`, `environment`, `status`, `serviceName`, `executionSource` | Root span attributes. |
671
+ | `threadId`, `resourceId`, `userId`, `sessionId`, `organizationId`, `experimentId` | Context identifiers recorded on the root span. |
672
+ | `name`, `spanType` | Root span name and type. Requires the `traceQueryRootSpanFields` capability. |
673
+ | `entityId` | Root span entity ID. Groups traces that have no `entityName`, such as scorer runs. Requires the `traceQueryRootEntityId` capability. |
674
+ | `metadata.<key>` | One non-empty top-level metadata key. Values are trimmed. Missing, empty, and non-string values group as `null`. |
666
675
 
667
676
  Every dimension except `serviceName`, `executionSource`, and `experimentId` is also a trace-scope `where` field, so you can drill into a group by adding its values to the predicate. `traceId`, `spanId`, `runId`, and `requestId` aren't groupable. Traces with no value for a dimension form their own group with a `null` value.
668
677