@mastra/client-js 1.44.1-alpha.2 → 1.45.0-alpha.4

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.
@@ -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.44.1-alpha.2"
6
+ version: "1.45.0-alpha.4"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.44.1-alpha.2",
2
+ "version": "1.45.0-alpha.4",
3
3
  "package": "@mastra/client-js",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -133,6 +133,32 @@ const session = await controller.createSession({
133
133
 
134
134
  Use [`session.thread.create()`](https://mastra.ai/reference/agent-controller/session) and [`session.thread.switch()`](https://mastra.ai/reference/agent-controller/session) to move one live Session between conversations.
135
135
 
136
+ ### List stored messages from the client
137
+
138
+ Use the Agent Controller client to page through a thread's stored messages. Passing an options object returns the messages with pagination metadata:
139
+
140
+ ```typescript
141
+ import { MastraClient } from '@mastra/client-js'
142
+
143
+ const client = new MastraClient({ baseUrl: 'http://localhost:4111' })
144
+ const session = client.getAgentController('assistant-controller').session('user-123')
145
+
146
+ const result = await session.listMessages('support-ticket-42', {
147
+ page: 0,
148
+ perPage: 20,
149
+ orderBy: { field: 'createdAt', direction: 'DESC' },
150
+ filter: {
151
+ dateRange: { start: new Date('2026-01-01') },
152
+ },
153
+ })
154
+
155
+ console.log(result.messages)
156
+ console.log(result.total)
157
+ console.log(result.hasMore)
158
+ ```
159
+
160
+ `page` is zero-indexed. Omitting `perPage` uses the storage default of 40 messages. Use `include` to request a message by ID with adjacent messages. `limit` is a deprecated alias for `perPage`; existing paged callers may use `{ limit, page }`, but must use `perPage` with `orderBy`, `filter`, or `include`. The existing numeric form, `session.listMessages(threadId, limit)`, remains available when you need the newest message window as an array, ordered oldest-first.
161
+
136
162
  ## Switch modes and models
137
163
 
138
164
  Modes change the instructions and tools used by the shared backing agent without replacing the Session or thread. Configure mode-specific tools and visibility on the controller:
@@ -111,6 +111,9 @@ Hono and Fastify enforce the request-body limit before JSON parsing. Express and
111
111
  | Score | `scorerId`, `scorerVersion`, `scoreSource`, `entityVersionId`, `parentEntityVersionId`, `rootEntityVersionId` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
112
112
  | Score | `score`, `timestamp` | `eq`, `ne`, `in`, `notIn`, `lt`, `lte`, `gt`, `gte`, `exists`, `notExists` |
113
113
  | Score | `spanId` | `exists`, `notExists` |
114
+ | Feedback | `feedbackType`, `feedbackSource`, `feedbackUserId`, `sourceId`, `entityVersionId`, `parentEntityVersionId`, `rootEntityVersionId` | `eq`, `ne`, `in`, `notIn`, `exists`, `notExists` |
115
+ | Feedback | `value`, `timestamp` | `eq`, `ne`, `in`, `notIn`, `lt`, `lte`, `gt`, `gte`, `exists`, `notExists` |
116
+ | Feedback | `comment` | `exists`, `notExists` |
114
117
 
115
118
  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`.
116
119
 
@@ -270,6 +273,45 @@ The key must name one top-level property. Empty keys and nested paths are reject
270
273
 
271
274
  Metadata fields aren't available for grouping or field discovery.
272
275
 
276
+ ### Filter by feedback
277
+
278
+ Every condition inside one `feedback.some` or `feedback.none` clause applies to the same current feedback record. `feedbackType` and `feedbackSource` are exact application-defined strings rather than built-in enums. This query finds traces with a numeric patient rating below zero:
279
+
280
+ ```typescript
281
+ const negativePatientRating = {
282
+ feedback: {
283
+ some: {
284
+ op: 'and',
285
+ args: [
286
+ { op: 'eq', left: { path: 'feedbackType' }, right: { literal: 'rating' } },
287
+ { op: 'eq', left: { path: 'feedbackSource' }, right: { literal: 'patient' } },
288
+ { op: 'lt', left: { path: 'value' }, right: { literal: 0 } },
289
+ ],
290
+ },
291
+ },
292
+ }
293
+ ```
294
+
295
+ Strict stored-value types are the portable contract for feedback predicates. PostgreSQL and ClickHouse distinguish numeric `3` from textual `'3'` for equality and ordered comparisons. DuckDB currently persists feedback values as `VARCHAR`, so numeric-looking strings may be coerced for equality and ordered numeric predicates. OBS-306 will remove this DuckDB exception through typed persistence. Ordered operators require a finite numeric literal. `eq` and `ne` accept one string or number, while `in` and `notIn` require a non-empty set containing only strings or only numbers. `exists` and `notExists` test for either value type.
296
+
297
+ Use `none` to select traces without a matching record. Traces with no feedback also match:
298
+
299
+ ```typescript
300
+ const missingClinicianReview = {
301
+ feedback: {
302
+ none: {
303
+ op: 'and',
304
+ args: [
305
+ { op: 'eq', left: { path: 'feedbackType' }, right: { literal: 'clinical-review' } },
306
+ { op: 'eq', left: { path: 'feedbackSource' }, right: { literal: 'clinician' } },
307
+ ],
308
+ },
309
+ },
310
+ }
311
+ ```
312
+
313
+ Feedback `timestamp` predicates are independent of the root `timeRange`. Use `comment` only with `exists` or `notExists`. Comment contents aren't searchable. The deprecated feedback fields `source` and `userId` aren't available. Use `feedbackSource` and `feedbackUserId`.
314
+
273
315
  ## Responses
274
316
 
275
317
  An ungrouped query returns only lightweight completed traces:
package/dist/index.cjs CHANGED
@@ -6179,10 +6179,29 @@ var AgentControllerSession = class extends BaseResource {
6179
6179
  body: options ?? {}
6180
6180
  });
6181
6181
  }
6182
- /** List messages for a specific thread. */
6183
- async listMessages(threadId, limit) {
6184
- const params = limit != null ? `?limit=${limit}` : "";
6185
- return (await this.request(this.url(`${this.base()}/threads/${encodeURIComponent(threadId)}/messages${params}`))).messages.map(hydrateMessage);
6182
+ async listMessages(threadId, options) {
6183
+ const queryParams = new URLSearchParams();
6184
+ const legacy = typeof options === "number" || options === void 0;
6185
+ if (typeof options === "number") queryParams.set("limit", String(options));
6186
+ else if (options === void 0) queryParams.set("perPage", "false");
6187
+ else {
6188
+ const { limit, page, perPage, orderBy, filter, include } = options;
6189
+ if (limit !== void 0 && (perPage !== void 0 || orderBy !== void 0 || filter !== void 0 || include !== void 0)) throw new Error("limit can only be combined with page; use perPage with orderBy, filter, or include");
6190
+ if (limit !== void 0) queryParams.set("limit", String(limit));
6191
+ if (page !== void 0) queryParams.set("page", String(page));
6192
+ if (perPage !== void 0) queryParams.set("perPage", String(perPage));
6193
+ if (orderBy) queryParams.set("orderBy", JSON.stringify(orderBy));
6194
+ if (filter) queryParams.set("filter", JSON.stringify(filter));
6195
+ if (include) queryParams.set("include", JSON.stringify(include));
6196
+ }
6197
+ const query = queryParams.toString();
6198
+ const body = await this.request(this.url(`${this.base()}/threads/${encodeURIComponent(threadId)}/messages${query ? `?${query}` : ""}`));
6199
+ const messages = body.messages.map(hydrateMessage);
6200
+ if (legacy) return messages;
6201
+ return {
6202
+ ...body,
6203
+ messages
6204
+ };
6186
6205
  }
6187
6206
  /**
6188
6207
  * Queue a follow-up message. If the session is idle it sends immediately;