@zero-library/chat-copilot 3.1.10 → 3.1.11

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.cjs.js CHANGED
@@ -1401,9 +1401,14 @@ function createChatStore() {
1401
1401
  });
1402
1402
  conversation.messages[conversationId].message = [];
1403
1403
  if (data?.length) {
1404
- data.forEach((msg) => {
1404
+ const mainMessages = data.filter((msg) => !msg.toolCallId);
1405
+ const subAgentMessages = data.filter((msg) => msg.toolCallId);
1406
+ mainMessages.forEach((msg) => {
1405
1407
  processMessageContent(msg);
1406
1408
  });
1409
+ subAgentMessages.forEach((msg) => {
1410
+ routeSubAgentMessage(msg);
1411
+ });
1407
1412
  finalizeHistoryMessages(conversationId);
1408
1413
  normalizeMessagesByExecutionAndRole(conversation.messages[conversationId].message);
1409
1414
  }
@@ -1469,9 +1474,7 @@ function createChatStore() {
1469
1474
  item.generating = false;
1470
1475
  });
1471
1476
  }
1472
- function startCallback(msg) {
1473
- const messages = conversation.messages[msg.conversationId]?.message;
1474
- if (!messages) return;
1477
+ function startCallback(msg, messages, isMain) {
1475
1478
  const idx = findExecutionMsgIndex(msg, messages);
1476
1479
  const contentItem = msg.content[0];
1477
1480
  if (contentItem.type !== "runStarted") return;
@@ -1482,23 +1485,24 @@ function createChatStore() {
1482
1485
  generating: true
1483
1486
  };
1484
1487
  messages.push(finalMsg);
1485
- const targetConversation = conversations.list.items.find((item) => item.id === msg.conversationId);
1486
- if (targetConversation && msg.createdAt) {
1487
- updateConversations({
1488
- ...targetConversation,
1489
- id: targetConversation.id,
1490
- title: targetConversation.label,
1491
- updatedAt: msg.createdAt
1492
- });
1488
+ if (isMain) {
1489
+ const targetConversation = conversations.list.items.find((item) => item.id === msg.conversationId);
1490
+ if (targetConversation && msg.createdAt) {
1491
+ updateConversations({
1492
+ ...targetConversation,
1493
+ id: targetConversation.id,
1494
+ title: targetConversation.label,
1495
+ updatedAt: msg.createdAt
1496
+ });
1497
+ }
1493
1498
  }
1494
1499
  } else {
1495
1500
  const prevContent = messages[idx]?.content || [];
1496
1501
  messages[idx].content = [...prevContent, contentItem];
1497
1502
  }
1498
- conversation.messages[msg.conversationId].loading = true;
1503
+ if (isMain) conversation.messages[msg.conversationId].loading = true;
1499
1504
  }
1500
- function textCallback(msg) {
1501
- const messages = conversation.messages[msg.conversationId]?.message;
1505
+ function textCallback(msg, messages, isMain) {
1502
1506
  const idx = findExecutionMsgIndex(msg, messages);
1503
1507
  const contents = idx !== -1 && messages[idx] ? messages[idx].content || [] : [];
1504
1508
  const nextContent = msg.content[0];
@@ -1527,13 +1531,12 @@ function createChatStore() {
1527
1531
  messages[idx].content = [...contents, normalizedNextContent];
1528
1532
  }
1529
1533
  }
1530
- conversation.messages[msg.conversationId].loading = true;
1534
+ if (isMain) conversation.messages[msg.conversationId].loading = true;
1531
1535
  }
1532
- function stepStartedCallback(msg) {
1533
- const messages = conversation.messages[msg.conversationId]?.message;
1536
+ function stepStartedCallback(msg, messages, isMain) {
1534
1537
  const idx = findExecutionMsgIndex(msg, messages);
1535
1538
  const contentItem = msg.content[0];
1536
- conversation.messages[msg.conversationId].loading = true;
1539
+ if (isMain) conversation.messages[msg.conversationId].loading = true;
1537
1540
  if (idx !== -1 && messages[idx]) {
1538
1541
  const contentList = messages[idx].content || [];
1539
1542
  const runStartedIndex = contentList.findIndex((item) => item.type === "runStarted");
@@ -1543,38 +1546,34 @@ function createChatStore() {
1543
1546
  messages[idx].content = contentList.map((item, i) => i === runStartedIndex ? nextRunStartedItem : item);
1544
1547
  }
1545
1548
  }
1549
+ if (isMain) config.hooks?.onStepMessage?.(msg);
1546
1550
  config.hooks?.onStepMessage?.(msg);
1547
1551
  }
1548
- function stepFinishedCallback(msg) {
1549
- conversation.messages[msg.conversationId].loading = true;
1550
- config.hooks?.onStepMessage?.(msg);
1552
+ function stepFinishedCallback(msg, _messages, isMain) {
1553
+ if (isMain) conversation.messages[msg.conversationId].loading = true;
1554
+ if (isMain) config.hooks?.onStepMessage?.(msg);
1551
1555
  }
1552
- function stepErrCallback(msg) {
1553
- conversation.messages[msg.conversationId].loading = false;
1554
- const messages = conversation.messages[msg.conversationId]?.message;
1555
- if (messages) {
1556
- const idx = findExecutionMsgIndex(msg, messages);
1557
- const contentItem = msg.content[0];
1558
- messages.forEach((item) => {
1559
- if (item.executionId === msg.executionId) {
1560
- item.generating = false;
1561
- }
1562
- });
1563
- if (idx !== -1) {
1564
- messages[idx].generating = false;
1565
- }
1566
- if (idx !== -1) {
1567
- const prevContent = messages[idx]?.content || [];
1568
- messages[idx].content = [...prevContent, contentItem];
1569
- } else {
1570
- const finalMsg = { ...msg };
1571
- finalMsg.generating = false;
1572
- messages.push(finalMsg);
1556
+ function stepErrCallback(msg, messages, isMain) {
1557
+ if (isMain) conversation.messages[msg.conversationId].loading = false;
1558
+ const idx = findExecutionMsgIndex(msg, messages);
1559
+ const contentItem = msg.content[0];
1560
+ messages.forEach((item) => {
1561
+ if (item.executionId === msg.executionId) {
1562
+ item.generating = false;
1573
1563
  }
1564
+ });
1565
+ if (idx !== -1) {
1566
+ messages[idx].generating = false;
1567
+ const prevContent = messages[idx]?.content || [];
1568
+ messages[idx].content = [...prevContent, contentItem];
1569
+ } else {
1570
+ const finalMsg = { ...msg };
1571
+ finalMsg.generating = false;
1572
+ messages.push(finalMsg);
1574
1573
  }
1575
- config.hooks?.onStepMessage?.(msg);
1574
+ if (isMain) config.hooks?.onStepMessage?.(msg);
1576
1575
  }
1577
- function doneCallback(msg) {
1576
+ function doneCallback(msg, message3, isMain) {
1578
1577
  conversation.messages[msg.conversationId].loading = false;
1579
1578
  const messages = conversation.messages[msg.conversationId]?.message;
1580
1579
  if (messages) {
@@ -1595,11 +1594,12 @@ function createChatStore() {
1595
1594
  }
1596
1595
  }
1597
1596
  }
1598
- config.hooks?.onAfterAcceptMessage?.(msg);
1597
+ if (isMain) config.hooks?.onAfterAcceptMessage?.(msg);
1599
1598
  }
1600
- function titleCallback(msg) {
1599
+ function titleCallback(msg, _messages, isMain) {
1601
1600
  const content = msg.content[0];
1602
1601
  if (content.type !== "conversationNewTitle") return;
1602
+ if (!isMain) return;
1603
1603
  const title = content.title || "";
1604
1604
  const conversationId = msg.conversationId || "";
1605
1605
  if (content && conversations.list.items.length) {
@@ -1608,9 +1608,7 @@ function createChatStore() {
1608
1608
  conversations.list.items[idx].label = title;
1609
1609
  }
1610
1610
  }
1611
- function toolCallCallback(msg) {
1612
- const messages = conversation.messages[msg.conversationId]?.message;
1613
- if (!messages) return;
1611
+ function toolCallCallback(msg, messages, isMain) {
1614
1612
  let idx = -1;
1615
1613
  const contentItem = msg.content[0];
1616
1614
  if (contentItem.type !== "toolCall") return;
@@ -1646,16 +1644,20 @@ function createChatStore() {
1646
1644
  if (contentItem.status) {
1647
1645
  nextItem.status = contentItem.status;
1648
1646
  }
1647
+ if (contentItem.toolIcon) {
1648
+ nextItem.toolIcon = contentItem.toolIcon;
1649
+ }
1650
+ if (contentItem.display) {
1651
+ nextItem.display = (existingItem.display || "") + contentItem.display;
1652
+ }
1649
1653
  messages[idx].content = contents.map((item, i) => i === existingItemIndex ? nextItem : item);
1650
1654
  } else {
1651
1655
  messages[idx].content = [...contents, contentItem];
1652
1656
  }
1653
1657
  }
1654
- conversation.messages[msg.conversationId].loading = true;
1658
+ if (isMain) conversation.messages[msg.conversationId].loading = true;
1655
1659
  }
1656
- function toolResultCallback(msg) {
1657
- const messages = conversation.messages[msg.conversationId]?.message;
1658
- if (!messages) return;
1660
+ function toolResultCallback(msg, messages, isMain) {
1659
1661
  const contentItem = msg.content[0];
1660
1662
  if (contentItem.type !== "toolResult") return;
1661
1663
  let idx = -1;
@@ -1686,15 +1688,16 @@ function createChatStore() {
1686
1688
  if (contentItem.title) {
1687
1689
  nextToolCallItem.title = contentItem.title;
1688
1690
  }
1691
+ if (contentItem.display !== void 0) {
1692
+ nextToolCallItem.display = contentItem.display;
1693
+ }
1689
1694
  messages[idx].content = contents.map((item, i) => i === toolCallIndex ? nextToolCallItem : item);
1690
1695
  } else {
1691
1696
  messages[idx].content = [...contents, contentItem];
1692
1697
  }
1693
- conversation.messages[msg.conversationId].loading = true;
1698
+ if (isMain) conversation.messages[msg.conversationId].loading = true;
1694
1699
  }
1695
- function a2uiCommandCallback(msg) {
1696
- const messages = conversation.messages[msg.conversationId]?.message;
1697
- if (!messages) return;
1700
+ function a2uiCommandCallback(msg, messages, isMain) {
1698
1701
  const idx = findExecutionMsgIndex(msg, messages);
1699
1702
  const contentItem = msg.content[0];
1700
1703
  if (contentItem.type !== "a2uiCommand") return;
@@ -1705,45 +1708,147 @@ function createChatStore() {
1705
1708
  const prevContent = messages[idx]?.content || [];
1706
1709
  messages[idx].content = [...prevContent, contentItem];
1707
1710
  }
1708
- conversation.messages[msg.conversationId].loading = true;
1711
+ if (isMain) conversation.messages[msg.conversationId].loading = true;
1712
+ }
1713
+ function toolCallDeltaCallback(msg, messages, isMain) {
1714
+ const contentItem = msg.content[0];
1715
+ if (contentItem.type !== "toolCallDelta") return;
1716
+ let idx = -1;
1717
+ if (contentItem.toolCallId) {
1718
+ idx = messages.findLastIndex(
1719
+ (m) => m.content?.some((c) => (c.type === "toolCall" || c.type === "toolCallDelta") && c.toolCallId === contentItem.toolCallId)
1720
+ );
1721
+ }
1722
+ if (idx === -1) idx = findExecutionMsgIndex(msg, messages);
1723
+ if (idx === -1) {
1724
+ messages.push({
1725
+ ...msg,
1726
+ content: [
1727
+ {
1728
+ type: "toolCall",
1729
+ toolCallId: contentItem.toolCallId,
1730
+ toolName: contentItem.toolName || void 0,
1731
+ toolIcon: contentItem.toolIcon,
1732
+ title: contentItem.title,
1733
+ content: contentItem.argumentsDelta || "",
1734
+ display: contentItem.display,
1735
+ status: contentItem.status || "running"
1736
+ }
1737
+ ],
1738
+ generating: true
1739
+ });
1740
+ } else {
1741
+ const contents = messages[idx].content;
1742
+ const itemIdx = contents.findIndex(
1743
+ (c) => (c.type === "toolCall" || c.type === "toolCallDelta") && c.toolCallId === contentItem.toolCallId
1744
+ );
1745
+ if (itemIdx !== -1) {
1746
+ const existing = contents[itemIdx];
1747
+ const nextItem = {
1748
+ ...existing,
1749
+ type: "toolCall",
1750
+ content: (existing.content || "") + (contentItem.argumentsDelta || "")
1751
+ };
1752
+ if (contentItem.toolName) nextItem.toolName = contentItem.toolName;
1753
+ if (contentItem.title) nextItem.title = contentItem.title;
1754
+ if (contentItem.status) nextItem.status = contentItem.status;
1755
+ if (contentItem.toolIcon) nextItem.toolIcon = contentItem.toolIcon;
1756
+ if (contentItem.display) nextItem.display = (existing.display || "") + contentItem.display;
1757
+ messages[idx].content = contents.map((c, i) => i === itemIdx ? nextItem : c);
1758
+ } else {
1759
+ messages[idx].content = [
1760
+ ...contents,
1761
+ {
1762
+ type: "toolCall",
1763
+ toolCallId: contentItem.toolCallId,
1764
+ toolName: contentItem.toolName || void 0,
1765
+ toolIcon: contentItem.toolIcon,
1766
+ title: contentItem.title,
1767
+ content: contentItem.argumentsDelta || "",
1768
+ display: contentItem.display,
1769
+ status: contentItem.status || "running"
1770
+ }
1771
+ ];
1772
+ }
1773
+ }
1774
+ if (isMain) conversation.messages[msg.conversationId].loading = true;
1775
+ }
1776
+ function findToolCallItemRecursive(messages, toolCallId) {
1777
+ for (let i = messages.length - 1; i >= 0; i--) {
1778
+ const msg = messages[i];
1779
+ const contents = msg.content || [];
1780
+ const itemIdx = contents.findIndex((c) => c.type === "toolCall" && c.toolCallId === toolCallId);
1781
+ if (itemIdx !== -1) {
1782
+ return { messageList: msg, itemIndex: itemIdx };
1783
+ }
1784
+ for (const content of contents) {
1785
+ if (content.type === "toolCall") {
1786
+ const subMessages = content.subMessages;
1787
+ if (subMessages?.length) {
1788
+ const found = findToolCallItemRecursive(subMessages, toolCallId);
1789
+ if (found) return found;
1790
+ }
1791
+ }
1792
+ }
1793
+ }
1794
+ return null;
1795
+ }
1796
+ function routeSubAgentMessage(msg) {
1797
+ const conversationId = msg.conversationId;
1798
+ const mainMessages = conversation.messages[conversationId]?.message;
1799
+ if (!mainMessages) return;
1800
+ const found = findToolCallItemRecursive(mainMessages, msg.toolCallId);
1801
+ if (!found) {
1802
+ return;
1803
+ }
1804
+ const { messageList, itemIndex } = found;
1805
+ const contents = messageList.content;
1806
+ const toolCallItem = contents[itemIndex];
1807
+ toolCallItem.hasSubAgent = true;
1808
+ if (!toolCallItem.subMessages) {
1809
+ toolCallItem.subMessages = [];
1810
+ }
1811
+ processMessageContent(msg, toolCallItem.subMessages);
1812
+ messageList.content = contents.map((c, i) => i === itemIndex ? { ...toolCallItem } : c);
1709
1813
  }
1710
- function processSingleMessageContent(newMessage) {
1814
+ function processSingleMessageContent(newMessage, messages, isMain) {
1711
1815
  switch (newMessage.content[0].type) {
1712
1816
  case "runStarted":
1713
- startCallback(newMessage);
1817
+ startCallback(newMessage, messages, isMain);
1714
1818
  break;
1715
1819
  case "text":
1716
- textCallback(newMessage);
1820
+ textCallback(newMessage, messages, isMain);
1717
1821
  break;
1718
1822
  case "stepStarted":
1719
- stepStartedCallback(newMessage);
1823
+ stepStartedCallback(newMessage, messages, isMain);
1720
1824
  break;
1721
1825
  case "stepFinished":
1722
- stepFinishedCallback(newMessage);
1826
+ stepFinishedCallback(newMessage, messages, isMain);
1723
1827
  break;
1724
1828
  case "stepError":
1725
- stepErrCallback(newMessage);
1829
+ stepErrCallback(newMessage, messages, isMain);
1726
1830
  break;
1727
1831
  case "runFinished":
1728
1832
  case "runFailed":
1729
1833
  case "runStopped":
1730
- doneCallback(newMessage);
1834
+ doneCallback(newMessage, messages, isMain);
1731
1835
  break;
1732
1836
  case "conversationNewTitle":
1733
- titleCallback(newMessage);
1837
+ titleCallback(newMessage, messages, isMain);
1734
1838
  break;
1735
1839
  case "toolCall":
1736
- toolCallCallback(newMessage);
1840
+ toolCallCallback(newMessage, messages, isMain);
1841
+ break;
1842
+ case "toolCallDelta":
1843
+ toolCallDeltaCallback(newMessage, messages, isMain);
1737
1844
  break;
1738
1845
  case "toolResult":
1739
- toolResultCallback(newMessage);
1846
+ toolResultCallback(newMessage, messages, isMain);
1740
1847
  break;
1741
1848
  case "a2uiCommand":
1742
- a2uiCommandCallback(newMessage);
1849
+ a2uiCommandCallback(newMessage, messages, isMain);
1743
1850
  break;
1744
1851
  default: {
1745
- const messages = conversation.messages[newMessage.conversationId]?.message;
1746
- if (!messages) return;
1747
1852
  const idx = findExecutionMsgIndex(newMessage, messages);
1748
1853
  if (idx === -1) {
1749
1854
  const finalMsg = { ...newMessage, generating: true };
@@ -1752,20 +1857,21 @@ function createChatStore() {
1752
1857
  const prevContent = messages[idx]?.content || [];
1753
1858
  messages[idx].content = [...prevContent, ...newMessage.content];
1754
1859
  }
1755
- conversation.messages[newMessage.conversationId].loading = true;
1860
+ if (isMain) conversation.messages[newMessage.conversationId].loading = true;
1756
1861
  break;
1757
1862
  }
1758
1863
  }
1759
1864
  }
1760
- function processMessageContent(message3) {
1865
+ function processMessageContent(message3, targetMessages) {
1761
1866
  const newMessage = {
1762
1867
  ...message3,
1763
1868
  agentId: agent.agentInfo.id
1764
1869
  };
1870
+ const isMain = !targetMessages;
1871
+ const messages = targetMessages ?? conversation.messages[newMessage.conversationId]?.message;
1872
+ if (!messages) return;
1765
1873
  const contentList = Array.isArray(newMessage.content) ? newMessage.content : [];
1766
1874
  if (contentList.length === 0) {
1767
- const messages = conversation.messages[newMessage.conversationId]?.message;
1768
- if (!messages) return;
1769
1875
  const idx = findExecutionMsgIndex(newMessage, messages);
1770
1876
  if (idx === -1) {
1771
1877
  messages.push({ ...newMessage });
@@ -1781,17 +1887,32 @@ function createChatStore() {
1781
1887
  return;
1782
1888
  }
1783
1889
  contentList.forEach((contentItem) => {
1784
- processSingleMessageContent({
1785
- ...newMessage,
1786
- content: [contentItem]
1787
- });
1890
+ processSingleMessageContent(
1891
+ {
1892
+ ...newMessage,
1893
+ content: [contentItem]
1894
+ },
1895
+ messages,
1896
+ isMain
1897
+ );
1788
1898
  });
1789
- normalizeMessagesByExecutionAndRole(conversation.messages[newMessage.conversationId]?.message);
1899
+ normalizeMessagesByExecutionAndRole(messages);
1790
1900
  }
1791
1901
  function isStoppedIncomingMessage(newMessage) {
1792
1902
  const messages = conversation.messages[newMessage.conversationId]?.message;
1793
1903
  if (!messages) return false;
1794
- return messages.some((item) => item.stopFlag && item.executionId === newMessage.executionId);
1904
+ if (messages.some((item) => item.stopFlag && item.executionId === newMessage.executionId)) {
1905
+ return true;
1906
+ }
1907
+ return messages.some(
1908
+ (msg) => msg.content?.some((c) => {
1909
+ if (c.type === "toolCall") {
1910
+ const subMessages = c.subMessages;
1911
+ return subMessages?.some((sub) => sub.stopFlag && sub.executionId === newMessage.executionId);
1912
+ }
1913
+ return false;
1914
+ })
1915
+ );
1795
1916
  }
1796
1917
  const acceptMessage = async (newMessage) => {
1797
1918
  const conversationId = newMessage.conversationId;
@@ -1801,6 +1922,10 @@ function createChatStore() {
1801
1922
  if (canProceed === false) {
1802
1923
  throw new Error("\u64CD\u4F5C\u88AB\u963B\u6B62");
1803
1924
  }
1925
+ if (newMessage.toolCallId) {
1926
+ routeSubAgentMessage(newMessage);
1927
+ return;
1928
+ }
1804
1929
  if (isStoppedIncomingMessage(newMessage)) {
1805
1930
  conversation.messages[conversationId].loading = false;
1806
1931
  return;
@@ -1882,19 +2007,25 @@ function createChatStore() {
1882
2007
  const lastMsg = messages[messages.length - 1];
1883
2008
  if (lastMsg.executionId) {
1884
2009
  await config.services.request.cancelMessage(lastMsg.executionId);
1885
- messages.forEach((item) => {
1886
- if (item.executionId === lastMsg.executionId) {
1887
- item.generating = false;
1888
- item.stopFlag = true;
2010
+ const markStopped = (msgList, matchExecutionId) => {
2011
+ msgList.forEach((item) => {
2012
+ if (item.executionId === lastMsg.executionId) {
2013
+ item.generating = false;
2014
+ item.stopFlag = true;
2015
+ }
1889
2016
  if (item.content && Array.isArray(item.content)) {
1890
2017
  item.content.forEach((contentItem) => {
1891
2018
  if (contentItem.type === "toolCall" && contentItem.status !== "success" && contentItem.status !== "error") {
1892
2019
  contentItem.status = "error";
1893
2020
  }
2021
+ if (contentItem.subMessages?.length) {
2022
+ markStopped(contentItem.subMessages);
2023
+ }
1894
2024
  });
1895
2025
  }
1896
- }
1897
- });
2026
+ });
2027
+ };
2028
+ markStopped(messages);
1898
2029
  } else {
1899
2030
  lastMsg.stopFlag = true;
1900
2031
  lastMsg.generating = false;
@@ -4576,7 +4707,8 @@ var FilesNode = React10__namespace.default.memo(({ item }) => {
4576
4707
 
4577
4708
  // src/components/CustomComponents/MessageNode/style.module.less
4578
4709
  var style_module_default2 = {
4579
- runStartedNode: "style_module_runStartedNode"};
4710
+ runStartedNode: "style_module_runStartedNode",
4711
+ dot: "style_module_dot"};
4580
4712
  var QuoteMsgNode = React10__namespace.default.memo(({ quoteMsg, role }) => {
4581
4713
  if (!quoteMsg || !quoteMsg.messageContent) return null;
4582
4714
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -4607,9 +4739,12 @@ var QuoteMsgNode = React10__namespace.default.memo(({ quoteMsg, role }) => {
4607
4739
  }
4608
4740
  );
4609
4741
  });
4610
- var RunStartedNode = React10__namespace.default.memo(({ loading }) => {
4611
- if (!loading) return null;
4612
- return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { gap: 8, align: "center", className: style_module_default2.runStartedNode, children: /* @__PURE__ */ jsxRuntime.jsx(icons.LoadingOutlined, { style: { color: "#1677ff" } }) });
4742
+ var RunStartedNode = React10__namespace.default.memo(() => {
4743
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: style_module_default2.runStartedNode, children: [
4744
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: style_module_default2.dot }),
4745
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: style_module_default2.dot }),
4746
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: style_module_default2.dot })
4747
+ ] });
4613
4748
  });
4614
4749
  var RESOURCE_MARKDOWN_TAG = "resourcetag";
4615
4750
  var RESOURCE_TOKEN_REGEX = /(\w+):\/\/([^?\s]+)\?name=([^&\s]+)&label=([^\s]+)/g;
@@ -4663,11 +4798,17 @@ var TextNode2 = React10__namespace.default.memo(
4663
4798
  var index_module_default2 = {
4664
4799
  iconContainer: "index_module_iconContainer",
4665
4800
  toolName: "index_module_toolName",
4801
+ toolNamePending: "index_module_toolNamePending",
4802
+ dot: "index_module_dot",
4666
4803
  duration: "index_module_duration",
4667
4804
  statusIcon: "index_module_statusIcon",
4805
+ expandIcon: "index_module_expandIcon",
4806
+ expanded: "index_module_expanded",
4668
4807
  sectionLabel: "index_module_sectionLabel",
4808
+ plainTextContainer: "index_module_plainTextContainer",
4669
4809
  markdownContainer: "index_module_markdownContainer",
4670
4810
  sectionBlock: "index_module_sectionBlock",
4811
+ contentScrollContainer: "index_module_contentScrollContainer",
4671
4812
  todoList: "index_module_todoList",
4672
4813
  todoItem: "index_module_todoItem",
4673
4814
  statusIconWrapper: "index_module_statusIconWrapper",
@@ -4677,6 +4818,9 @@ var index_module_default2 = {
4677
4818
  emptyText: "index_module_emptyText"
4678
4819
  };
4679
4820
  var DefaultToolRender = ({ argsContent, resultContent, errorMessage, item }) => {
4821
+ if (item.display) {
4822
+ return /* @__PURE__ */ jsxRuntime.jsx("pre", { className: index_module_default2.plainTextContainer, children: item.display });
4823
+ }
4680
4824
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4681
4825
  (item.content || item.arguments) && argsContent && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: index_module_default2.sectionBlock, children: [
4682
4826
  /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: index_module_default2.sectionLabel, children: "\u8F93\u5165\u53C2\u6570" }),
@@ -4780,7 +4924,7 @@ var formatContent = (content) => {
4780
4924
  };
4781
4925
  var ToolCallItem = ({ item }) => {
4782
4926
  const { token } = antd.theme.useToken();
4783
- const renderConfig = getToolRenderConfig(item.toolName);
4927
+ const renderConfig = getToolRenderConfig(item);
4784
4928
  const CustomRender = renderConfig.component;
4785
4929
  const status = React10.useMemo(() => {
4786
4930
  if (item.status) return item.status;
@@ -4804,35 +4948,30 @@ var ToolCallItem = ({ item }) => {
4804
4948
  alwaysShow = renderConfig.alwaysShowContent;
4805
4949
  }
4806
4950
  if (alwaysShow) return true;
4807
- return Boolean(item.errorMessage);
4808
- }, [renderConfig.disableExpandOnError, renderConfig.alwaysShowContent, item.errorMessage, status, argsContent.parsed, resultContent?.parsed]);
4951
+ if (item.display) return true;
4952
+ if (item.errorMessage) return true;
4953
+ if (argsContent.text) return true;
4954
+ if (resultContent?.text) return true;
4955
+ return false;
4956
+ }, [
4957
+ renderConfig.disableExpandOnError,
4958
+ renderConfig.alwaysShowContent,
4959
+ item.display,
4960
+ item.errorMessage,
4961
+ status,
4962
+ argsContent.parsed,
4963
+ resultContent?.parsed,
4964
+ argsContent.text,
4965
+ resultContent?.text
4966
+ ]);
4809
4967
  const isDefaultExpanded = React10.useMemo(() => {
4810
4968
  if (typeof renderConfig.defaultExpanded === "function") {
4811
4969
  return renderConfig.defaultExpanded(argsContent.parsed, resultContent?.parsed);
4812
4970
  }
4813
4971
  return renderConfig.defaultExpanded;
4814
4972
  }, [renderConfig.defaultExpanded, argsContent.parsed, resultContent?.parsed]);
4815
- const statusConfig = {
4816
- running: {
4817
- icon: /* @__PURE__ */ jsxRuntime.jsx(icons.LoadingOutlined, {}),
4818
- color: token.colorPrimary
4819
- },
4820
- success: {
4821
- icon: null,
4822
- color: token.colorSuccess
4823
- },
4824
- error: {
4825
- icon: null,
4826
- color: token.colorSuccess
4827
- },
4828
- pending: {
4829
- icon: /* @__PURE__ */ jsxRuntime.jsx(icons.LoadingOutlined, {}),
4830
- color: token.colorTextSecondary
4831
- }
4832
- }[status] || {
4833
- icon: /* @__PURE__ */ jsxRuntime.jsx(icons.LoadingOutlined, {}),
4834
- color: token.colorPrimary
4835
- };
4973
+ const showLoading = status === "running" || status === "pending";
4974
+ const displayName = item.title || (showLoading ? "" : item.toolName || "Unknown Tool");
4836
4975
  const renderIcon = () => {
4837
4976
  if (!item.toolIcon) {
4838
4977
  return /* @__PURE__ */ jsxRuntime.jsx(icons.ToolOutlined, { style: { fontSize: 14, color: token.colorTextSecondary } });
@@ -4850,9 +4989,11 @@ var ToolCallItem = ({ item }) => {
4850
4989
  collapsible: hasContent ? void 0 : "disabled",
4851
4990
  defaultActiveKey: isDefaultExpanded && hasContent ? [item.toolCallId || "fallback-key"] : void 0,
4852
4991
  expandIconPlacement: "end",
4992
+ expandIcon: ({ isActive }) => hasContent ? /* @__PURE__ */ jsxRuntime.jsx(icons.RightOutlined, { className: `${index_module_default2.expandIcon} ${isActive ? index_module_default2.expanded : ""}` }) : null,
4853
4993
  styles: {
4854
4994
  header: {
4855
- padding: "6px 10px"
4995
+ padding: "6px 10px",
4996
+ overflow: "hidden"
4856
4997
  }
4857
4998
  },
4858
4999
  items: [
@@ -4861,14 +5002,18 @@ var ToolCallItem = ({ item }) => {
4861
5002
  showArrow: hasContent,
4862
5003
  label: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", gap: 8, style: { flex: 1, minWidth: 0 }, children: [
4863
5004
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.iconContainer, children: renderIcon() }),
4864
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.toolName, children: item.title || item.toolName || "Unknown Tool" }),
4865
- (status === "running" || status === "pending") && /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.statusIcon, style: { color: statusConfig.color }, children: statusConfig.icon }),
5005
+ displayName ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.toolName, children: displayName }) : /* @__PURE__ */ jsxRuntime.jsxs("span", { className: index_module_default2.toolNamePending, children: [
5006
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.dot }),
5007
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.dot }),
5008
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.dot })
5009
+ ] }),
5010
+ showLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.statusIcon, style: { color: token.colorPrimary }, children: /* @__PURE__ */ jsxRuntime.jsx(icons.LoadingOutlined, {}) }),
4866
5011
  item.duration && /* @__PURE__ */ jsxRuntime.jsxs(antd.Typography.Text, { className: index_module_default2.duration, children: [
4867
5012
  item.duration,
4868
5013
  "ms"
4869
5014
  ] })
4870
5015
  ] }),
4871
- children: /* @__PURE__ */ jsxRuntime.jsx(
5016
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.contentScrollContainer, children: /* @__PURE__ */ jsxRuntime.jsx(
4872
5017
  CustomRender,
4873
5018
  {
4874
5019
  item,
@@ -4878,7 +5023,7 @@ var ToolCallItem = ({ item }) => {
4878
5023
  resultContent,
4879
5024
  errorMessage: item.errorMessage
4880
5025
  }
4881
- )
5026
+ ) })
4882
5027
  }
4883
5028
  ]
4884
5029
  }
@@ -4892,9 +5037,6 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
4892
5037
  if (!RENDERABLE_MESSAGE_TYPES.includes(item.type)) {
4893
5038
  return false;
4894
5039
  }
4895
- if (item.type === "runStarted") {
4896
- return !!loading;
4897
- }
4898
5040
  if (item.type === "plan") {
4899
5041
  return !shouldHideA2uiPlan(item);
4900
5042
  }
@@ -4904,7 +5046,7 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
4904
5046
  }
4905
5047
  return true;
4906
5048
  });
4907
- }, [loading, message3.content]);
5049
+ }, [message3.content]);
4908
5050
  const quoteMsg = React10.useMemo(() => {
4909
5051
  const quoteMsg2 = {};
4910
5052
  if (message3.params) {
@@ -4918,7 +5060,8 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
4918
5060
  }
4919
5061
  return common.isEmptyObj(quoteMsg2) ? null : quoteMsg2;
4920
5062
  }, [message3.params, message3.quoteMsg]);
4921
- if (content.length === 0) return null;
5063
+ const showPending = loading && (content.length === 0 || content[content.length - 1].type !== "text");
5064
+ if (content.length === 0 && !showPending) return null;
4922
5065
  const lastToolCallIndex = (() => {
4923
5066
  let lastIdx = -1;
4924
5067
  content.forEach((item, i) => {
@@ -4935,7 +5078,6 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
4935
5078
  placement: role.placement,
4936
5079
  variant: item.type === "files" ? "borderless" : void 0,
4937
5080
  content: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4938
- item.type === "runStarted" && /* @__PURE__ */ jsxRuntime.jsx(RunStartedNode, { loading }, `flow-start-${index}`),
4939
5081
  (item.type === "toolCall" || item.type === "toolResult") && /* @__PURE__ */ jsxRuntime.jsx(tool_call_item_default, { item }, `tool-call-${item.toolCallId || index}`),
4940
5082
  item.type === "text" && /* @__PURE__ */ jsxRuntime.jsx(
4941
5083
  TextNode2,
@@ -4956,6 +5098,7 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
4956
5098
  ),
4957
5099
  index === lastToolCallIndex && messageIndex >= 0 ? /* @__PURE__ */ jsxRuntime.jsx(A2uiMessageCards, { messageIndex, message: message3 }) : null
4958
5100
  ] }, `message-${index}`)),
5101
+ showPending && /* @__PURE__ */ jsxRuntime.jsx(xV2.Bubble, { role: role.user, placement: role.placement, content: /* @__PURE__ */ jsxRuntime.jsx(RunStartedNode, {}) }),
4959
5102
  quoteMsg && /* @__PURE__ */ jsxRuntime.jsx(QuoteMsgNode, { quoteMsg, role })
4960
5103
  ] });
4961
5104
  });