@mastra/client-js 1.55.0 → 1.56.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1659,9 +1659,9 @@ var Agent = class extends BaseResource {
1659
1659
  },
1660
1660
  onToolResultPart(value) {
1661
1661
  const toolInvocations = message.toolInvocations;
1662
- if (toolInvocations == null) throw new Error("tool_result must be preceded by a tool_call");
1662
+ if (toolInvocations == null) return;
1663
1663
  const toolInvocationIndex = toolInvocations.findIndex((invocation) => invocation.toolCallId === value.toolCallId);
1664
- if (toolInvocationIndex === -1) throw new Error("tool_result must be preceded by a tool_call with the same toolCallId");
1664
+ if (toolInvocationIndex === -1) return;
1665
1665
  const invocation = {
1666
1666
  ...toolInvocations[toolInvocationIndex],
1667
1667
  state: "result",
@@ -1939,9 +1939,9 @@ var Agent = class extends BaseResource {
1939
1939
  }
1940
1940
  case "tool-result": {
1941
1941
  const toolInvocations = message.toolInvocations;
1942
- if (toolInvocations == null) throw new Error("tool_result must be preceded by a tool_call");
1942
+ if (toolInvocations == null) break;
1943
1943
  const toolInvocationIndex = toolInvocations.findIndex((invocation) => invocation.toolCallId === chunk.payload.toolCallId);
1944
- if (toolInvocationIndex === -1) throw new Error("tool_result must be preceded by a tool_call with the same toolCallId");
1944
+ if (toolInvocationIndex === -1) break;
1945
1945
  const invocation = {
1946
1946
  ...toolInvocations[toolInvocationIndex],
1947
1947
  state: "result",
@@ -7851,11 +7851,21 @@ var MastraClient = class extends BaseResource {
7851
7851
  * Lists all datasets with optional pagination
7852
7852
  */
7853
7853
  listDatasets(params) {
7854
+ if (params?.datasetIds?.length === 0) return Promise.resolve({
7855
+ datasets: [],
7856
+ pagination: {
7857
+ total: 0,
7858
+ page: 0,
7859
+ perPage: false,
7860
+ hasMore: false
7861
+ }
7862
+ });
7854
7863
  const searchParams = new URLSearchParams();
7855
7864
  if (params?.page !== void 0) searchParams.set("page", String(params.page));
7856
7865
  if (params?.perPage !== void 0) searchParams.set("perPage", String(params.perPage));
7857
7866
  if (params?.targetType !== void 0) searchParams.set("targetType", params.targetType);
7858
7867
  for (const id of params?.targetIds ?? []) searchParams.append("targetIds", id);
7868
+ for (const id of params?.datasetIds ?? []) searchParams.append("datasetIds", id);
7859
7869
  if (params?.orderBy) {
7860
7870
  searchParams.set("orderBy[field]", params.orderBy.field);
7861
7871
  searchParams.set("orderBy[direction]", params.orderBy.direction);