@mastra/client-js 1.41.0-alpha.8 → 1.41.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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @mastra/client-js
2
2
 
3
+ ## 1.41.0-alpha.9
4
+
5
+ ### Patch Changes
6
+
7
+ - Preserve tool-call `providerMetadata` at the message-part level during client-tool continuations. ([#21703](https://github.com/mastra-ai/mastra/pull/21703))
8
+
9
+ The stream reducers nested `providerMetadata` inside `toolInvocation`, but the server reads it from `part.providerMetadata` when rebuilding the prompt. As a result the metadata was dropped on the recursive request, and Gemini thinking models (e.g. `gemini-3-flash-preview`) failed the follow-up turn with `Function call is missing a thought_signature in functionCall parts`.
10
+
11
+ - Updated dependencies [[`b0a2a07`](https://github.com/mastra-ai/mastra/commit/b0a2a07800d42bd9823292e7db832374ed084c9c), [`ccbbcd9`](https://github.com/mastra-ai/mastra/commit/ccbbcd974eedff4367a54ed0e24c9ee742ab2f61), [`3f5c6f7`](https://github.com/mastra-ai/mastra/commit/3f5c6f728ea35da344248de9aa070f12849f3aa0), [`77e6b1b`](https://github.com/mastra-ai/mastra/commit/77e6b1bc4c46ce94fe501023fb4393c812ec6be3), [`2e1d098`](https://github.com/mastra-ai/mastra/commit/2e1d0984e325fd319d32ea182f596b3170be3847)]:
12
+ - @mastra/core@1.60.0-alpha.9
13
+
3
14
  ## 1.41.0-alpha.8
4
15
 
5
16
  ### Minor Changes
@@ -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.41.0-alpha.8"
6
+ version: "1.41.0-alpha.9"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.41.0-alpha.8",
2
+ "version": "1.41.0-alpha.9",
3
3
  "package": "@mastra/client-js",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -1413,13 +1413,22 @@ var Agent = class extends BaseResource {
1413
1413
  let currentTextPart = void 0;
1414
1414
  let currentReasoningPart = void 0;
1415
1415
  let currentReasoningTextDetail = void 0;
1416
- function updateToolInvocationPart(toolCallId, invocation) {
1416
+ function updateToolInvocationPart(toolCallId, invocation, partProviderMetadata) {
1417
1417
  const part = message.parts.find((part) => part.type === "tool-invocation" && part.toolInvocation.toolCallId === toolCallId);
1418
- if (part != null) part.toolInvocation = invocation;
1419
- else message.parts.push({
1420
- type: "tool-invocation",
1421
- toolInvocation: invocation
1422
- });
1418
+ if (part != null) {
1419
+ part.toolInvocation = invocation;
1420
+ if (partProviderMetadata !== void 0) part.providerMetadata = {
1421
+ ...part.providerMetadata ?? {},
1422
+ ...partProviderMetadata
1423
+ };
1424
+ } else {
1425
+ const newPart = {
1426
+ type: "tool-invocation",
1427
+ toolInvocation: invocation
1428
+ };
1429
+ if (partProviderMetadata !== void 0) newPart.providerMetadata = partProviderMetadata;
1430
+ message.parts.push(newPart);
1431
+ }
1423
1432
  }
1424
1433
  const data = [];
1425
1434
  let messageAnnotations = replaceLastMessage ? lastMessage?.annotations : void 0;
@@ -1557,7 +1566,7 @@ var Agent = class extends BaseResource {
1557
1566
  if (message.toolInvocations == null) message.toolInvocations = [];
1558
1567
  message.toolInvocations.push(invocation);
1559
1568
  }
1560
- updateToolInvocationPart(value.toolCallId, invocation);
1569
+ updateToolInvocationPart(value.toolCallId, invocation, value.providerMetadata);
1561
1570
  execUpdate();
1562
1571
  if (onToolCall) {
1563
1572
  const result = await onToolCall({ toolCall: value });
@@ -1569,7 +1578,7 @@ var Agent = class extends BaseResource {
1569
1578
  result
1570
1579
  };
1571
1580
  message.toolInvocations[message.toolInvocations.length - 1] = invocation;
1572
- updateToolInvocationPart(value.toolCallId, invocation);
1581
+ updateToolInvocationPart(value.toolCallId, invocation, value.providerMetadata);
1573
1582
  execUpdate();
1574
1583
  }
1575
1584
  }
@@ -1585,7 +1594,7 @@ var Agent = class extends BaseResource {
1585
1594
  ...value
1586
1595
  };
1587
1596
  toolInvocations[toolInvocationIndex] = invocation;
1588
- updateToolInvocationPart(value.toolCallId, invocation);
1597
+ updateToolInvocationPart(value.toolCallId, invocation, value.providerMetadata);
1589
1598
  execUpdate();
1590
1599
  },
1591
1600
  onDataPart(value) {
@@ -1665,13 +1674,22 @@ var Agent = class extends BaseResource {
1665
1674
  let currentTextPart = void 0;
1666
1675
  let currentReasoningPart = void 0;
1667
1676
  let currentReasoningTextDetail = void 0;
1668
- function updateToolInvocationPart(toolCallId, invocation) {
1677
+ function updateToolInvocationPart(toolCallId, invocation, partProviderMetadata) {
1669
1678
  const part = message.parts.find((part) => part.type === "tool-invocation" && part.toolInvocation.toolCallId === toolCallId);
1670
- if (part != null) part.toolInvocation = invocation;
1671
- else message.parts.push({
1672
- type: "tool-invocation",
1673
- toolInvocation: invocation
1674
- });
1679
+ if (part != null) {
1680
+ part.toolInvocation = invocation;
1681
+ if (partProviderMetadata !== void 0) part.providerMetadata = {
1682
+ ...part.providerMetadata ?? {},
1683
+ ...partProviderMetadata
1684
+ };
1685
+ } else {
1686
+ const newPart = {
1687
+ type: "tool-invocation",
1688
+ toolInvocation: invocation
1689
+ };
1690
+ if (partProviderMetadata !== void 0) newPart.providerMetadata = partProviderMetadata;
1691
+ message.parts.push(newPart);
1692
+ }
1675
1693
  }
1676
1694
  const data = [];
1677
1695
  let messageAnnotations = replaceLastMessage ? lastMessage?.annotations : void 0;
@@ -1767,7 +1785,7 @@ var Agent = class extends BaseResource {
1767
1785
  if (message.toolInvocations == null) message.toolInvocations = [];
1768
1786
  message.toolInvocations.push(invocation);
1769
1787
  }
1770
- updateToolInvocationPart(chunk.payload.toolCallId, invocation);
1788
+ updateToolInvocationPart(chunk.payload.toolCallId, invocation, chunk.payload.providerMetadata);
1771
1789
  execUpdate();
1772
1790
  if (onToolCall) {
1773
1791
  const result = await onToolCall({ toolCall: chunk.payload });
@@ -1779,7 +1797,7 @@ var Agent = class extends BaseResource {
1779
1797
  result
1780
1798
  };
1781
1799
  message.toolInvocations[message.toolInvocations.length - 1] = invocation;
1782
- updateToolInvocationPart(chunk.payload.toolCallId, invocation);
1800
+ updateToolInvocationPart(chunk.payload.toolCallId, invocation, chunk.payload.providerMetadata);
1783
1801
  execUpdate();
1784
1802
  }
1785
1803
  }
@@ -1836,7 +1854,7 @@ var Agent = class extends BaseResource {
1836
1854
  ...chunk.payload
1837
1855
  };
1838
1856
  toolInvocations[toolInvocationIndex] = invocation;
1839
- updateToolInvocationPart(chunk.payload.toolCallId, invocation);
1857
+ updateToolInvocationPart(chunk.payload.toolCallId, invocation, chunk.payload.providerMetadata);
1840
1858
  execUpdate();
1841
1859
  break;
1842
1860
  }