@mastra/client-js 1.44.1-alpha.3 → 1.45.0

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/index.js CHANGED
@@ -6155,10 +6155,29 @@ var AgentControllerSession = class extends BaseResource {
6155
6155
  body: options ?? {}
6156
6156
  });
6157
6157
  }
6158
- /** List messages for a specific thread. */
6159
- async listMessages(threadId, limit) {
6160
- const params = limit != null ? `?limit=${limit}` : "";
6161
- return (await this.request(this.url(`${this.base()}/threads/${encodeURIComponent(threadId)}/messages${params}`))).messages.map(hydrateMessage);
6158
+ async listMessages(threadId, options) {
6159
+ const queryParams = new URLSearchParams();
6160
+ const legacy = typeof options === "number" || options === void 0;
6161
+ if (typeof options === "number") queryParams.set("limit", String(options));
6162
+ else if (options === void 0) queryParams.set("perPage", "false");
6163
+ else {
6164
+ const { limit, page, perPage, orderBy, filter, include } = options;
6165
+ 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");
6166
+ if (limit !== void 0) queryParams.set("limit", String(limit));
6167
+ if (page !== void 0) queryParams.set("page", String(page));
6168
+ if (perPage !== void 0) queryParams.set("perPage", String(perPage));
6169
+ if (orderBy) queryParams.set("orderBy", JSON.stringify(orderBy));
6170
+ if (filter) queryParams.set("filter", JSON.stringify(filter));
6171
+ if (include) queryParams.set("include", JSON.stringify(include));
6172
+ }
6173
+ const query = queryParams.toString();
6174
+ const body = await this.request(this.url(`${this.base()}/threads/${encodeURIComponent(threadId)}/messages${query ? `?${query}` : ""}`));
6175
+ const messages = body.messages.map(hydrateMessage);
6176
+ if (legacy) return messages;
6177
+ return {
6178
+ ...body,
6179
+ messages
6180
+ };
6162
6181
  }
6163
6182
  /**
6164
6183
  * Queue a follow-up message. If the session is idle it sends immediately;