@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/dist/index.js CHANGED
@@ -1389,13 +1389,22 @@ var Agent = class extends BaseResource {
1389
1389
  let currentTextPart = void 0;
1390
1390
  let currentReasoningPart = void 0;
1391
1391
  let currentReasoningTextDetail = void 0;
1392
- function updateToolInvocationPart(toolCallId, invocation) {
1392
+ function updateToolInvocationPart(toolCallId, invocation, partProviderMetadata) {
1393
1393
  const part = message.parts.find((part) => part.type === "tool-invocation" && part.toolInvocation.toolCallId === toolCallId);
1394
- if (part != null) part.toolInvocation = invocation;
1395
- else message.parts.push({
1396
- type: "tool-invocation",
1397
- toolInvocation: invocation
1398
- });
1394
+ if (part != null) {
1395
+ part.toolInvocation = invocation;
1396
+ if (partProviderMetadata !== void 0) part.providerMetadata = {
1397
+ ...part.providerMetadata ?? {},
1398
+ ...partProviderMetadata
1399
+ };
1400
+ } else {
1401
+ const newPart = {
1402
+ type: "tool-invocation",
1403
+ toolInvocation: invocation
1404
+ };
1405
+ if (partProviderMetadata !== void 0) newPart.providerMetadata = partProviderMetadata;
1406
+ message.parts.push(newPart);
1407
+ }
1399
1408
  }
1400
1409
  const data = [];
1401
1410
  let messageAnnotations = replaceLastMessage ? lastMessage?.annotations : void 0;
@@ -1533,7 +1542,7 @@ var Agent = class extends BaseResource {
1533
1542
  if (message.toolInvocations == null) message.toolInvocations = [];
1534
1543
  message.toolInvocations.push(invocation);
1535
1544
  }
1536
- updateToolInvocationPart(value.toolCallId, invocation);
1545
+ updateToolInvocationPart(value.toolCallId, invocation, value.providerMetadata);
1537
1546
  execUpdate();
1538
1547
  if (onToolCall) {
1539
1548
  const result = await onToolCall({ toolCall: value });
@@ -1545,7 +1554,7 @@ var Agent = class extends BaseResource {
1545
1554
  result
1546
1555
  };
1547
1556
  message.toolInvocations[message.toolInvocations.length - 1] = invocation;
1548
- updateToolInvocationPart(value.toolCallId, invocation);
1557
+ updateToolInvocationPart(value.toolCallId, invocation, value.providerMetadata);
1549
1558
  execUpdate();
1550
1559
  }
1551
1560
  }
@@ -1561,7 +1570,7 @@ var Agent = class extends BaseResource {
1561
1570
  ...value
1562
1571
  };
1563
1572
  toolInvocations[toolInvocationIndex] = invocation;
1564
- updateToolInvocationPart(value.toolCallId, invocation);
1573
+ updateToolInvocationPart(value.toolCallId, invocation, value.providerMetadata);
1565
1574
  execUpdate();
1566
1575
  },
1567
1576
  onDataPart(value) {
@@ -1641,13 +1650,22 @@ var Agent = class extends BaseResource {
1641
1650
  let currentTextPart = void 0;
1642
1651
  let currentReasoningPart = void 0;
1643
1652
  let currentReasoningTextDetail = void 0;
1644
- function updateToolInvocationPart(toolCallId, invocation) {
1653
+ function updateToolInvocationPart(toolCallId, invocation, partProviderMetadata) {
1645
1654
  const part = message.parts.find((part) => part.type === "tool-invocation" && part.toolInvocation.toolCallId === toolCallId);
1646
- if (part != null) part.toolInvocation = invocation;
1647
- else message.parts.push({
1648
- type: "tool-invocation",
1649
- toolInvocation: invocation
1650
- });
1655
+ if (part != null) {
1656
+ part.toolInvocation = invocation;
1657
+ if (partProviderMetadata !== void 0) part.providerMetadata = {
1658
+ ...part.providerMetadata ?? {},
1659
+ ...partProviderMetadata
1660
+ };
1661
+ } else {
1662
+ const newPart = {
1663
+ type: "tool-invocation",
1664
+ toolInvocation: invocation
1665
+ };
1666
+ if (partProviderMetadata !== void 0) newPart.providerMetadata = partProviderMetadata;
1667
+ message.parts.push(newPart);
1668
+ }
1651
1669
  }
1652
1670
  const data = [];
1653
1671
  let messageAnnotations = replaceLastMessage ? lastMessage?.annotations : void 0;
@@ -1743,7 +1761,7 @@ var Agent = class extends BaseResource {
1743
1761
  if (message.toolInvocations == null) message.toolInvocations = [];
1744
1762
  message.toolInvocations.push(invocation);
1745
1763
  }
1746
- updateToolInvocationPart(chunk.payload.toolCallId, invocation);
1764
+ updateToolInvocationPart(chunk.payload.toolCallId, invocation, chunk.payload.providerMetadata);
1747
1765
  execUpdate();
1748
1766
  if (onToolCall) {
1749
1767
  const result = await onToolCall({ toolCall: chunk.payload });
@@ -1755,7 +1773,7 @@ var Agent = class extends BaseResource {
1755
1773
  result
1756
1774
  };
1757
1775
  message.toolInvocations[message.toolInvocations.length - 1] = invocation;
1758
- updateToolInvocationPart(chunk.payload.toolCallId, invocation);
1776
+ updateToolInvocationPart(chunk.payload.toolCallId, invocation, chunk.payload.providerMetadata);
1759
1777
  execUpdate();
1760
1778
  }
1761
1779
  }
@@ -1812,7 +1830,7 @@ var Agent = class extends BaseResource {
1812
1830
  ...chunk.payload
1813
1831
  };
1814
1832
  toolInvocations[toolInvocationIndex] = invocation;
1815
- updateToolInvocationPart(chunk.payload.toolCallId, invocation);
1833
+ updateToolInvocationPart(chunk.payload.toolCallId, invocation, chunk.payload.providerMetadata);
1816
1834
  execUpdate();
1817
1835
  break;
1818
1836
  }