@zero-library/chat-copilot 3.1.10 → 3.1.12

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.esm.js CHANGED
@@ -1,7 +1,7 @@
1
- import { CloudUploadOutlined, PaperClipOutlined, createFromIconfontCN, LoadingOutlined, EnterOutlined, DownloadOutlined, CloseOutlined, PlayCircleOutlined, CopyOutlined, DotChartOutlined, LikeOutlined, DislikeOutlined, ToolOutlined, SearchOutlined, UpOutlined, DownOutlined, PlusOutlined, CommentOutlined, RedoOutlined, DeleteOutlined, ClockCircleOutlined, CheckCircleOutlined, FileImageOutlined, FilePdfOutlined, FileWordOutlined, FileExcelOutlined, FilePptOutlined, FileZipOutlined, FileTextOutlined, FileUnknownOutlined } from '@ant-design/icons';
1
+ import { CloudUploadOutlined, PaperClipOutlined, createFromIconfontCN, EnterOutlined, DownloadOutlined, CloseOutlined, PlayCircleOutlined, CopyOutlined, DotChartOutlined, LoadingOutlined, RightOutlined, LikeOutlined, DislikeOutlined, ToolOutlined, SearchOutlined, UpOutlined, DownOutlined, PlusOutlined, CommentOutlined, RedoOutlined, DeleteOutlined, ClockCircleOutlined, CheckCircleOutlined, FileImageOutlined, FilePdfOutlined, FileWordOutlined, FileExcelOutlined, FilePptOutlined, FileZipOutlined, FileTextOutlined, FileUnknownOutlined } from '@ant-design/icons';
2
2
  import { Attachments, Sender, FileCard, Bubble, Think, XProvider, Mermaid, CodeHighlighter, Welcome, Prompts, Conversations } from '@ant-design/x-v2';
3
3
  import { useRefState, useDebounce, createTokenManager, useSyncInput, isEmptyObj, markdownToText, RenderWrapper, shouldRender, isFunction, downloadFile, LuyaFilePreview, MarkdownEditor, useDeepEffect, isObject, useWebSocket, isNullOrUnDef, isNumber, getFileSuffixName, emit, FileIcon, copyText, LazyComponent, isBoolean, UserAvatar, htmlToMarkdown, buildUrlParams, isExternal, deepCopy, transforms, deepMerge, createRequest, HttpStatus, isArray, isString, isDef, isNull, transform, getWebSocketUrl, safeParseJson } from '@zero-library/common';
4
- import { App, Badge, Button, Flex, Typography, Tooltip, Layout, Tag, Spin, Splitter, Image as Image$1, Popover, Skeleton, Alert, theme, Collapse, Divider as Divider$1, Select as Select$1, Avatar, Space, Form, Drawer, Empty, Modal, Checkbox, Input, InputNumber, Switch as Switch$1, message, List, Upload, Card, Table, Progress as Progress$1 } from 'antd';
4
+ import { App, Badge, Button, Flex, Typography, Tooltip, Layout, Tag, Spin, Splitter, Image as Image$1, Popover, Skeleton, Alert, theme, Collapse, Divider as Divider$1, Select as Select$1, Avatar, Space, Form, Drawer, Empty, Modal, Checkbox, Input, InputNumber, Switch as Switch$1, message, Upload, List, Card, Table, Progress as Progress$1 } from 'antd';
5
5
  import * as React10 from 'react';
6
6
  import React10__default, { createContext, forwardRef, useRef, useEffect, useImperativeHandle, useMemo, memo, useState, useContext, useCallback, useLayoutEffect } from 'react';
7
7
  import { useSnapshot, proxy } from 'valtio';
@@ -1279,7 +1279,7 @@ function createChatStore() {
1279
1279
  const { data } = await config.services.request.createConversationId({ agentId: agent.agentInfo.id, convMeta: config.params.convMeta });
1280
1280
  const newSpec = {
1281
1281
  skills: { items: [] },
1282
- knowledge: { items: [] }
1282
+ knowledges: { items: [] }
1283
1283
  };
1284
1284
  updateConversations({
1285
1285
  id: data || "",
@@ -1372,9 +1372,14 @@ function createChatStore() {
1372
1372
  });
1373
1373
  conversation.messages[conversationId].message = [];
1374
1374
  if (data?.length) {
1375
- data.forEach((msg) => {
1375
+ const mainMessages = data.filter((msg) => !msg.toolCallId);
1376
+ const subAgentMessages = data.filter((msg) => msg.toolCallId);
1377
+ mainMessages.forEach((msg) => {
1376
1378
  processMessageContent(msg);
1377
1379
  });
1380
+ subAgentMessages.forEach((msg) => {
1381
+ routeSubAgentMessage(msg);
1382
+ });
1378
1383
  finalizeHistoryMessages(conversationId);
1379
1384
  normalizeMessagesByExecutionAndRole(conversation.messages[conversationId].message);
1380
1385
  }
@@ -1440,9 +1445,7 @@ function createChatStore() {
1440
1445
  item.generating = false;
1441
1446
  });
1442
1447
  }
1443
- function startCallback(msg) {
1444
- const messages = conversation.messages[msg.conversationId]?.message;
1445
- if (!messages) return;
1448
+ function startCallback(msg, messages, isMain) {
1446
1449
  const idx = findExecutionMsgIndex(msg, messages);
1447
1450
  const contentItem = msg.content[0];
1448
1451
  if (contentItem.type !== "runStarted") return;
@@ -1453,23 +1456,24 @@ function createChatStore() {
1453
1456
  generating: true
1454
1457
  };
1455
1458
  messages.push(finalMsg);
1456
- const targetConversation = conversations.list.items.find((item) => item.id === msg.conversationId);
1457
- if (targetConversation && msg.createdAt) {
1458
- updateConversations({
1459
- ...targetConversation,
1460
- id: targetConversation.id,
1461
- title: targetConversation.label,
1462
- updatedAt: msg.createdAt
1463
- });
1459
+ if (isMain) {
1460
+ const targetConversation = conversations.list.items.find((item) => item.id === msg.conversationId);
1461
+ if (targetConversation && msg.createdAt) {
1462
+ updateConversations({
1463
+ ...targetConversation,
1464
+ id: targetConversation.id,
1465
+ title: targetConversation.label,
1466
+ updatedAt: msg.createdAt
1467
+ });
1468
+ }
1464
1469
  }
1465
1470
  } else {
1466
1471
  const prevContent = messages[idx]?.content || [];
1467
1472
  messages[idx].content = [...prevContent, contentItem];
1468
1473
  }
1469
- conversation.messages[msg.conversationId].loading = true;
1474
+ if (isMain) conversation.messages[msg.conversationId].loading = true;
1470
1475
  }
1471
- function textCallback(msg) {
1472
- const messages = conversation.messages[msg.conversationId]?.message;
1476
+ function textCallback(msg, messages, isMain) {
1473
1477
  const idx = findExecutionMsgIndex(msg, messages);
1474
1478
  const contents = idx !== -1 && messages[idx] ? messages[idx].content || [] : [];
1475
1479
  const nextContent = msg.content[0];
@@ -1498,13 +1502,12 @@ function createChatStore() {
1498
1502
  messages[idx].content = [...contents, normalizedNextContent];
1499
1503
  }
1500
1504
  }
1501
- conversation.messages[msg.conversationId].loading = true;
1505
+ if (isMain) conversation.messages[msg.conversationId].loading = true;
1502
1506
  }
1503
- function stepStartedCallback(msg) {
1504
- const messages = conversation.messages[msg.conversationId]?.message;
1507
+ function stepStartedCallback(msg, messages, isMain) {
1505
1508
  const idx = findExecutionMsgIndex(msg, messages);
1506
1509
  const contentItem = msg.content[0];
1507
- conversation.messages[msg.conversationId].loading = true;
1510
+ if (isMain) conversation.messages[msg.conversationId].loading = true;
1508
1511
  if (idx !== -1 && messages[idx]) {
1509
1512
  const contentList = messages[idx].content || [];
1510
1513
  const runStartedIndex = contentList.findIndex((item) => item.type === "runStarted");
@@ -1514,38 +1517,34 @@ function createChatStore() {
1514
1517
  messages[idx].content = contentList.map((item, i) => i === runStartedIndex ? nextRunStartedItem : item);
1515
1518
  }
1516
1519
  }
1520
+ if (isMain) config.hooks?.onStepMessage?.(msg);
1517
1521
  config.hooks?.onStepMessage?.(msg);
1518
1522
  }
1519
- function stepFinishedCallback(msg) {
1520
- conversation.messages[msg.conversationId].loading = true;
1521
- config.hooks?.onStepMessage?.(msg);
1523
+ function stepFinishedCallback(msg, _messages, isMain) {
1524
+ if (isMain) conversation.messages[msg.conversationId].loading = true;
1525
+ if (isMain) config.hooks?.onStepMessage?.(msg);
1522
1526
  }
1523
- function stepErrCallback(msg) {
1524
- conversation.messages[msg.conversationId].loading = false;
1525
- const messages = conversation.messages[msg.conversationId]?.message;
1526
- if (messages) {
1527
- const idx = findExecutionMsgIndex(msg, messages);
1528
- const contentItem = msg.content[0];
1529
- messages.forEach((item) => {
1530
- if (item.executionId === msg.executionId) {
1531
- item.generating = false;
1532
- }
1533
- });
1534
- if (idx !== -1) {
1535
- messages[idx].generating = false;
1536
- }
1537
- if (idx !== -1) {
1538
- const prevContent = messages[idx]?.content || [];
1539
- messages[idx].content = [...prevContent, contentItem];
1540
- } else {
1541
- const finalMsg = { ...msg };
1542
- finalMsg.generating = false;
1543
- messages.push(finalMsg);
1527
+ function stepErrCallback(msg, messages, isMain) {
1528
+ if (isMain) conversation.messages[msg.conversationId].loading = false;
1529
+ const idx = findExecutionMsgIndex(msg, messages);
1530
+ const contentItem = msg.content[0];
1531
+ messages.forEach((item) => {
1532
+ if (item.executionId === msg.executionId) {
1533
+ item.generating = false;
1544
1534
  }
1535
+ });
1536
+ if (idx !== -1) {
1537
+ messages[idx].generating = false;
1538
+ const prevContent = messages[idx]?.content || [];
1539
+ messages[idx].content = [...prevContent, contentItem];
1540
+ } else {
1541
+ const finalMsg = { ...msg };
1542
+ finalMsg.generating = false;
1543
+ messages.push(finalMsg);
1545
1544
  }
1546
- config.hooks?.onStepMessage?.(msg);
1545
+ if (isMain) config.hooks?.onStepMessage?.(msg);
1547
1546
  }
1548
- function doneCallback(msg) {
1547
+ function doneCallback(msg, message3, isMain) {
1549
1548
  conversation.messages[msg.conversationId].loading = false;
1550
1549
  const messages = conversation.messages[msg.conversationId]?.message;
1551
1550
  if (messages) {
@@ -1566,11 +1565,12 @@ function createChatStore() {
1566
1565
  }
1567
1566
  }
1568
1567
  }
1569
- config.hooks?.onAfterAcceptMessage?.(msg);
1568
+ if (isMain) config.hooks?.onAfterAcceptMessage?.(msg);
1570
1569
  }
1571
- function titleCallback(msg) {
1570
+ function titleCallback(msg, _messages, isMain) {
1572
1571
  const content = msg.content[0];
1573
1572
  if (content.type !== "conversationNewTitle") return;
1573
+ if (!isMain) return;
1574
1574
  const title = content.title || "";
1575
1575
  const conversationId = msg.conversationId || "";
1576
1576
  if (content && conversations.list.items.length) {
@@ -1579,9 +1579,7 @@ function createChatStore() {
1579
1579
  conversations.list.items[idx].label = title;
1580
1580
  }
1581
1581
  }
1582
- function toolCallCallback(msg) {
1583
- const messages = conversation.messages[msg.conversationId]?.message;
1584
- if (!messages) return;
1582
+ function toolCallCallback(msg, messages, isMain) {
1585
1583
  let idx = -1;
1586
1584
  const contentItem = msg.content[0];
1587
1585
  if (contentItem.type !== "toolCall") return;
@@ -1596,37 +1594,39 @@ function createChatStore() {
1596
1594
  messages.push(finalMsg);
1597
1595
  } else {
1598
1596
  const contents = messages[idx].content;
1599
- const existingItemIndex = contents.findIndex(
1597
+ let existingItemIndex = contents.findIndex(
1600
1598
  (item) => item.type === "toolCall" && item.toolCallId === contentItem.toolCallId
1601
1599
  );
1600
+ if (existingItemIndex === -1 && contentItem.toolCallId) {
1601
+ existingItemIndex = contents.findIndex(
1602
+ (item) => item.type === "toolCall" && !item.toolCallId && item._streamingIndex !== void 0
1603
+ );
1604
+ }
1602
1605
  if (existingItemIndex !== -1) {
1603
- const existingItem = contents[existingItemIndex];
1606
+ const nextItem = { ...contents[existingItemIndex] };
1604
1607
  const newContent = contentItem.content || contentItem.arguments;
1605
- const nextItem = { ...existingItem };
1606
1608
  if (typeof newContent === "string") {
1607
- nextItem.content = (existingItem.content || "") + newContent;
1609
+ nextItem.content = (nextItem.content || "") + newContent;
1608
1610
  } else if (newContent !== void 0) {
1609
1611
  nextItem.arguments = newContent;
1610
1612
  }
1611
- if (contentItem.toolName) {
1612
- nextItem.toolName = contentItem.toolName;
1613
- }
1614
- if (contentItem.title) {
1615
- nextItem.title = contentItem.title;
1616
- }
1617
- if (contentItem.status) {
1618
- nextItem.status = contentItem.status;
1613
+ if (contentItem.toolName) nextItem.toolName = contentItem.toolName;
1614
+ if (contentItem.title) nextItem.title = contentItem.title;
1615
+ if (contentItem.status) nextItem.status = contentItem.status;
1616
+ if (contentItem.toolIcon) nextItem.toolIcon = contentItem.toolIcon;
1617
+ if (contentItem.display?.title) nextItem.title = contentItem.display.title;
1618
+ if (contentItem.display) {
1619
+ nextItem.argsDisplay = contentItem.display;
1620
+ nextItem.displayProtocol = true;
1619
1621
  }
1620
1622
  messages[idx].content = contents.map((item, i) => i === existingItemIndex ? nextItem : item);
1621
1623
  } else {
1622
- messages[idx].content = [...contents, contentItem];
1624
+ messages[idx].content = [...contents, { ...contentItem, displayProtocol: !!contentItem.display }];
1623
1625
  }
1624
1626
  }
1625
- conversation.messages[msg.conversationId].loading = true;
1627
+ if (isMain) conversation.messages[msg.conversationId].loading = true;
1626
1628
  }
1627
- function toolResultCallback(msg) {
1628
- const messages = conversation.messages[msg.conversationId]?.message;
1629
- if (!messages) return;
1629
+ function toolResultCallback(msg, messages, isMain) {
1630
1630
  const contentItem = msg.content[0];
1631
1631
  if (contentItem.type !== "toolResult") return;
1632
1632
  let idx = -1;
@@ -1640,32 +1640,28 @@ function createChatStore() {
1640
1640
  const contents = messages[idx].content;
1641
1641
  const toolCallIndex = contents.findIndex((item) => item.type === "toolCall" && item.toolCallId === contentItem.toolCallId);
1642
1642
  if (toolCallIndex !== -1) {
1643
- const toolCallItem = contents[toolCallIndex];
1644
1643
  const nextToolCallItem = {
1645
- ...toolCallItem,
1644
+ ...contents[toolCallIndex],
1646
1645
  result: contentItem.result ?? contentItem.content
1647
1646
  };
1648
- if (contentItem.status) {
1649
- nextToolCallItem.status = contentItem.status;
1650
- }
1651
- if (contentItem.errorMessage) {
1652
- nextToolCallItem.errorMessage = contentItem.errorMessage;
1653
- }
1654
- if (contentItem.duration) {
1655
- nextToolCallItem.duration = contentItem.duration;
1656
- }
1657
- if (contentItem.title) {
1658
- nextToolCallItem.title = contentItem.title;
1647
+ if (contentItem.status) nextToolCallItem.status = contentItem.status;
1648
+ if (contentItem.isError !== void 0) nextToolCallItem.isError = contentItem.isError;
1649
+ if (contentItem.errorMessage) nextToolCallItem.errorMessage = contentItem.errorMessage;
1650
+ const dur = contentItem.durationMs ?? contentItem.duration;
1651
+ if (dur !== void 0) nextToolCallItem.duration = dur;
1652
+ if (contentItem.title) nextToolCallItem.title = contentItem.title;
1653
+ if (contentItem.display?.title) nextToolCallItem.title = contentItem.display.title;
1654
+ if (contentItem.display) {
1655
+ nextToolCallItem.resultDisplay = contentItem.display;
1656
+ nextToolCallItem.displayProtocol = true;
1659
1657
  }
1660
1658
  messages[idx].content = contents.map((item, i) => i === toolCallIndex ? nextToolCallItem : item);
1661
1659
  } else {
1662
1660
  messages[idx].content = [...contents, contentItem];
1663
1661
  }
1664
- conversation.messages[msg.conversationId].loading = true;
1662
+ if (isMain) conversation.messages[msg.conversationId].loading = true;
1665
1663
  }
1666
- function a2uiCommandCallback(msg) {
1667
- const messages = conversation.messages[msg.conversationId]?.message;
1668
- if (!messages) return;
1664
+ function a2uiCommandCallback(msg, messages, isMain) {
1669
1665
  const idx = findExecutionMsgIndex(msg, messages);
1670
1666
  const contentItem = msg.content[0];
1671
1667
  if (contentItem.type !== "a2uiCommand") return;
@@ -1676,45 +1672,162 @@ function createChatStore() {
1676
1672
  const prevContent = messages[idx]?.content || [];
1677
1673
  messages[idx].content = [...prevContent, contentItem];
1678
1674
  }
1679
- conversation.messages[msg.conversationId].loading = true;
1675
+ if (isMain) conversation.messages[msg.conversationId].loading = true;
1676
+ }
1677
+ function toolCallDeltaCallback(msg, messages, isMain) {
1678
+ const contentItem = msg.content[0];
1679
+ if (contentItem.type !== "toolCallDelta") return;
1680
+ let idx = -1;
1681
+ if (contentItem.toolCallId) {
1682
+ idx = messages.findLastIndex(
1683
+ (m) => m.content?.some((c) => c.type === "toolCall" && c.toolCallId === contentItem.toolCallId)
1684
+ );
1685
+ }
1686
+ if (idx === -1 && contentItem.index !== void 0) {
1687
+ idx = messages.findLastIndex(
1688
+ (m) => m.executionId === msg.executionId && m.content?.some((c) => c.type === "toolCall" && c._streamingIndex === contentItem.index && !c.toolCallId)
1689
+ );
1690
+ }
1691
+ if (idx === -1) idx = findExecutionMsgIndex(msg, messages);
1692
+ const buildNewItem = () => {
1693
+ const item = {
1694
+ type: "toolCall",
1695
+ toolCallId: contentItem.toolCallId || void 0,
1696
+ _streamingIndex: contentItem.index,
1697
+ toolName: contentItem.toolName || void 0,
1698
+ toolIcon: contentItem.toolIcon,
1699
+ title: contentItem.title,
1700
+ content: contentItem.displayDelta ? "" : contentItem.argumentsDelta || "",
1701
+ status: contentItem.status || "running",
1702
+ displayProtocol: !!contentItem.displayDelta
1703
+ };
1704
+ if (contentItem.displayDelta?.title) item.title = contentItem.displayDelta.title;
1705
+ if (contentItem.displayDelta?.contentAppend) {
1706
+ item.streamingArgsDisplay = {
1707
+ title: contentItem.displayDelta.title,
1708
+ content: contentItem.displayDelta.contentAppend,
1709
+ kind: contentItem.displayDelta.kind,
1710
+ lang: contentItem.displayDelta.lang
1711
+ };
1712
+ }
1713
+ return item;
1714
+ };
1715
+ if (idx === -1) {
1716
+ messages.push({ ...msg, content: [buildNewItem()], generating: true });
1717
+ } else {
1718
+ const contents = messages[idx].content;
1719
+ let itemIdx = -1;
1720
+ if (contentItem.toolCallId) {
1721
+ itemIdx = contents.findIndex((c) => c.type === "toolCall" && c.toolCallId === contentItem.toolCallId);
1722
+ }
1723
+ if (itemIdx === -1 && contentItem.index !== void 0) {
1724
+ itemIdx = contents.findIndex((c) => c.type === "toolCall" && c._streamingIndex === contentItem.index && !c.toolCallId);
1725
+ }
1726
+ if (itemIdx !== -1) {
1727
+ const existing = contents[itemIdx];
1728
+ const nextItem = {
1729
+ ...existing,
1730
+ type: "toolCall",
1731
+ content: contentItem.displayDelta ? existing.content || "" : (existing.content || "") + (contentItem.argumentsDelta || "")
1732
+ };
1733
+ if (contentItem.toolCallId && !existing.toolCallId) nextItem.toolCallId = contentItem.toolCallId;
1734
+ if (contentItem.toolName) nextItem.toolName = contentItem.toolName;
1735
+ if (contentItem.title) nextItem.title = contentItem.title;
1736
+ if (contentItem.status) nextItem.status = contentItem.status;
1737
+ if (contentItem.toolIcon) nextItem.toolIcon = contentItem.toolIcon;
1738
+ if (contentItem.displayDelta) nextItem.displayProtocol = true;
1739
+ if (contentItem.displayDelta?.title) nextItem.title = contentItem.displayDelta.title;
1740
+ if (contentItem.displayDelta?.contentAppend) {
1741
+ nextItem.streamingArgsDisplay = {
1742
+ title: contentItem.displayDelta.title || existing.streamingArgsDisplay?.title,
1743
+ content: (existing.streamingArgsDisplay?.content || "") + contentItem.displayDelta.contentAppend,
1744
+ kind: contentItem.displayDelta.kind || existing.streamingArgsDisplay?.kind,
1745
+ lang: contentItem.displayDelta.lang ?? existing.streamingArgsDisplay?.lang
1746
+ };
1747
+ }
1748
+ messages[idx].content = contents.map((c, i) => i === itemIdx ? nextItem : c);
1749
+ } else {
1750
+ messages[idx].content = [...contents, buildNewItem()];
1751
+ }
1752
+ }
1753
+ if (isMain) conversation.messages[msg.conversationId].loading = true;
1754
+ }
1755
+ function findToolCallItemRecursive(messages, toolCallId) {
1756
+ for (let i = messages.length - 1; i >= 0; i--) {
1757
+ const msg = messages[i];
1758
+ const contents = msg.content || [];
1759
+ const itemIdx = contents.findIndex((c) => c.type === "toolCall" && c.toolCallId === toolCallId);
1760
+ if (itemIdx !== -1) {
1761
+ return { messageList: msg, itemIndex: itemIdx };
1762
+ }
1763
+ for (const content of contents) {
1764
+ if (content.type === "toolCall") {
1765
+ const subMessages = content.subMessages;
1766
+ if (subMessages?.length) {
1767
+ const found = findToolCallItemRecursive(subMessages, toolCallId);
1768
+ if (found) return found;
1769
+ }
1770
+ }
1771
+ }
1772
+ }
1773
+ return null;
1774
+ }
1775
+ function routeSubAgentMessage(msg) {
1776
+ const conversationId = msg.conversationId;
1777
+ const mainMessages = conversation.messages[conversationId]?.message;
1778
+ if (!mainMessages) return;
1779
+ const found = findToolCallItemRecursive(mainMessages, msg.toolCallId);
1780
+ if (!found) {
1781
+ return;
1782
+ }
1783
+ const { messageList, itemIndex } = found;
1784
+ const contents = messageList.content;
1785
+ const toolCallItem = contents[itemIndex];
1786
+ toolCallItem.hasSubAgent = true;
1787
+ if (!toolCallItem.subMessages) {
1788
+ toolCallItem.subMessages = [];
1789
+ }
1790
+ processMessageContent(msg, toolCallItem.subMessages);
1791
+ messageList.content = contents.map((c, i) => i === itemIndex ? { ...toolCallItem } : c);
1680
1792
  }
1681
- function processSingleMessageContent(newMessage) {
1793
+ function processSingleMessageContent(newMessage, messages, isMain) {
1682
1794
  switch (newMessage.content[0].type) {
1683
1795
  case "runStarted":
1684
- startCallback(newMessage);
1796
+ startCallback(newMessage, messages, isMain);
1685
1797
  break;
1686
1798
  case "text":
1687
- textCallback(newMessage);
1799
+ textCallback(newMessage, messages, isMain);
1688
1800
  break;
1689
1801
  case "stepStarted":
1690
- stepStartedCallback(newMessage);
1802
+ stepStartedCallback(newMessage, messages, isMain);
1691
1803
  break;
1692
1804
  case "stepFinished":
1693
- stepFinishedCallback(newMessage);
1805
+ stepFinishedCallback(newMessage, messages, isMain);
1694
1806
  break;
1695
1807
  case "stepError":
1696
- stepErrCallback(newMessage);
1808
+ stepErrCallback(newMessage, messages, isMain);
1697
1809
  break;
1698
1810
  case "runFinished":
1699
1811
  case "runFailed":
1700
1812
  case "runStopped":
1701
- doneCallback(newMessage);
1813
+ doneCallback(newMessage, messages, isMain);
1702
1814
  break;
1703
1815
  case "conversationNewTitle":
1704
- titleCallback(newMessage);
1816
+ titleCallback(newMessage, messages, isMain);
1705
1817
  break;
1706
1818
  case "toolCall":
1707
- toolCallCallback(newMessage);
1819
+ toolCallCallback(newMessage, messages, isMain);
1820
+ break;
1821
+ case "toolCallDelta":
1822
+ toolCallDeltaCallback(newMessage, messages, isMain);
1708
1823
  break;
1709
1824
  case "toolResult":
1710
- toolResultCallback(newMessage);
1825
+ toolResultCallback(newMessage, messages, isMain);
1711
1826
  break;
1712
1827
  case "a2uiCommand":
1713
- a2uiCommandCallback(newMessage);
1828
+ a2uiCommandCallback(newMessage, messages, isMain);
1714
1829
  break;
1715
1830
  default: {
1716
- const messages = conversation.messages[newMessage.conversationId]?.message;
1717
- if (!messages) return;
1718
1831
  const idx = findExecutionMsgIndex(newMessage, messages);
1719
1832
  if (idx === -1) {
1720
1833
  const finalMsg = { ...newMessage, generating: true };
@@ -1723,20 +1836,21 @@ function createChatStore() {
1723
1836
  const prevContent = messages[idx]?.content || [];
1724
1837
  messages[idx].content = [...prevContent, ...newMessage.content];
1725
1838
  }
1726
- conversation.messages[newMessage.conversationId].loading = true;
1839
+ if (isMain) conversation.messages[newMessage.conversationId].loading = true;
1727
1840
  break;
1728
1841
  }
1729
1842
  }
1730
1843
  }
1731
- function processMessageContent(message3) {
1844
+ function processMessageContent(message3, targetMessages) {
1732
1845
  const newMessage = {
1733
1846
  ...message3,
1734
1847
  agentId: agent.agentInfo.id
1735
1848
  };
1849
+ const isMain = !targetMessages;
1850
+ const messages = targetMessages ?? conversation.messages[newMessage.conversationId]?.message;
1851
+ if (!messages) return;
1736
1852
  const contentList = Array.isArray(newMessage.content) ? newMessage.content : [];
1737
1853
  if (contentList.length === 0) {
1738
- const messages = conversation.messages[newMessage.conversationId]?.message;
1739
- if (!messages) return;
1740
1854
  const idx = findExecutionMsgIndex(newMessage, messages);
1741
1855
  if (idx === -1) {
1742
1856
  messages.push({ ...newMessage });
@@ -1752,17 +1866,32 @@ function createChatStore() {
1752
1866
  return;
1753
1867
  }
1754
1868
  contentList.forEach((contentItem) => {
1755
- processSingleMessageContent({
1756
- ...newMessage,
1757
- content: [contentItem]
1758
- });
1869
+ processSingleMessageContent(
1870
+ {
1871
+ ...newMessage,
1872
+ content: [contentItem]
1873
+ },
1874
+ messages,
1875
+ isMain
1876
+ );
1759
1877
  });
1760
- normalizeMessagesByExecutionAndRole(conversation.messages[newMessage.conversationId]?.message);
1878
+ normalizeMessagesByExecutionAndRole(messages);
1761
1879
  }
1762
1880
  function isStoppedIncomingMessage(newMessage) {
1763
1881
  const messages = conversation.messages[newMessage.conversationId]?.message;
1764
1882
  if (!messages) return false;
1765
- return messages.some((item) => item.stopFlag && item.executionId === newMessage.executionId);
1883
+ if (messages.some((item) => item.stopFlag && item.executionId === newMessage.executionId)) {
1884
+ return true;
1885
+ }
1886
+ return messages.some(
1887
+ (msg) => msg.content?.some((c) => {
1888
+ if (c.type === "toolCall") {
1889
+ const subMessages = c.subMessages;
1890
+ return subMessages?.some((sub) => sub.stopFlag && sub.executionId === newMessage.executionId);
1891
+ }
1892
+ return false;
1893
+ })
1894
+ );
1766
1895
  }
1767
1896
  const acceptMessage = async (newMessage) => {
1768
1897
  const conversationId = newMessage.conversationId;
@@ -1772,6 +1901,10 @@ function createChatStore() {
1772
1901
  if (canProceed === false) {
1773
1902
  throw new Error("\u64CD\u4F5C\u88AB\u963B\u6B62");
1774
1903
  }
1904
+ if (newMessage.toolCallId) {
1905
+ routeSubAgentMessage(newMessage);
1906
+ return;
1907
+ }
1775
1908
  if (isStoppedIncomingMessage(newMessage)) {
1776
1909
  conversation.messages[conversationId].loading = false;
1777
1910
  return;
@@ -1844,6 +1977,11 @@ function createChatStore() {
1844
1977
  const dealedParams = await config.hooks?.onHandleSendParams?.(sendParams);
1845
1978
  await config.services.request.sendMessageStream(dealedParams || sendParams, agent.agentInfo?.id || "");
1846
1979
  config.hooks?.onAfterSend?.();
1980
+ } catch (err) {
1981
+ conversation.messages[conversationId].loading = false;
1982
+ const errMsg = err?.response?.data?.message || err?.message || "\u53D1\u9001\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";
1983
+ message.error(errMsg);
1984
+ throw err;
1847
1985
  } finally {
1848
1986
  }
1849
1987
  };
@@ -1853,19 +1991,25 @@ function createChatStore() {
1853
1991
  const lastMsg = messages[messages.length - 1];
1854
1992
  if (lastMsg.executionId) {
1855
1993
  await config.services.request.cancelMessage(lastMsg.executionId);
1856
- messages.forEach((item) => {
1857
- if (item.executionId === lastMsg.executionId) {
1858
- item.generating = false;
1859
- item.stopFlag = true;
1994
+ const markStopped = (msgList, matchExecutionId) => {
1995
+ msgList.forEach((item) => {
1996
+ if (item.executionId === lastMsg.executionId) {
1997
+ item.generating = false;
1998
+ item.stopFlag = true;
1999
+ }
1860
2000
  if (item.content && Array.isArray(item.content)) {
1861
2001
  item.content.forEach((contentItem) => {
1862
2002
  if (contentItem.type === "toolCall" && contentItem.status !== "success" && contentItem.status !== "error") {
1863
2003
  contentItem.status = "error";
1864
2004
  }
2005
+ if (contentItem.subMessages?.length) {
2006
+ markStopped(contentItem.subMessages);
2007
+ }
1865
2008
  });
1866
2009
  }
1867
- }
1868
- });
2010
+ });
2011
+ };
2012
+ markStopped(messages);
1869
2013
  } else {
1870
2014
  lastMsg.stopFlag = true;
1871
2015
  lastMsg.generating = false;
@@ -4547,7 +4691,8 @@ var FilesNode = React10__default.memo(({ item }) => {
4547
4691
 
4548
4692
  // src/components/CustomComponents/MessageNode/style.module.less
4549
4693
  var style_module_default2 = {
4550
- runStartedNode: "style_module_runStartedNode"};
4694
+ runStartedNode: "style_module_runStartedNode",
4695
+ dot: "style_module_dot"};
4551
4696
  var QuoteMsgNode = React10__default.memo(({ quoteMsg, role }) => {
4552
4697
  if (!quoteMsg || !quoteMsg.messageContent) return null;
4553
4698
  return /* @__PURE__ */ jsx(
@@ -4578,9 +4723,12 @@ var QuoteMsgNode = React10__default.memo(({ quoteMsg, role }) => {
4578
4723
  }
4579
4724
  );
4580
4725
  });
4581
- var RunStartedNode = React10__default.memo(({ loading }) => {
4582
- if (!loading) return null;
4583
- return /* @__PURE__ */ jsx(Flex, { gap: 8, align: "center", className: style_module_default2.runStartedNode, children: /* @__PURE__ */ jsx(LoadingOutlined, { style: { color: "#1677ff" } }) });
4726
+ var RunStartedNode = React10__default.memo(() => {
4727
+ return /* @__PURE__ */ jsxs("span", { className: style_module_default2.runStartedNode, children: [
4728
+ /* @__PURE__ */ jsx("span", { className: style_module_default2.dot }),
4729
+ /* @__PURE__ */ jsx("span", { className: style_module_default2.dot }),
4730
+ /* @__PURE__ */ jsx("span", { className: style_module_default2.dot })
4731
+ ] });
4584
4732
  });
4585
4733
  var RESOURCE_MARKDOWN_TAG = "resourcetag";
4586
4734
  var RESOURCE_TOKEN_REGEX = /(\w+):\/\/([^?\s]+)\?name=([^&\s]+)&label=([^\s]+)/g;
@@ -4632,13 +4780,43 @@ var TextNode2 = React10__default.memo(
4632
4780
 
4633
4781
  // src/components/CustomComponents/ToolRenders/index.module.less
4634
4782
  var index_module_default2 = {
4783
+ toolCollapse: "index_module_toolCollapse",
4635
4784
  iconContainer: "index_module_iconContainer",
4636
4785
  toolName: "index_module_toolName",
4786
+ toolNamePending: "index_module_toolNamePending",
4787
+ dot: "index_module_dot",
4788
+ dotBlink: "index_module_dotBlink",
4637
4789
  duration: "index_module_duration",
4638
4790
  statusIcon: "index_module_statusIcon",
4791
+ expandIcon: "index_module_expandIcon",
4792
+ expanded: "index_module_expanded",
4639
4793
  sectionLabel: "index_module_sectionLabel",
4794
+ plainTextContainer: "index_module_plainTextContainer",
4640
4795
  markdownContainer: "index_module_markdownContainer",
4796
+ summaryText: "index_module_summaryText",
4797
+ metaGrid: "index_module_metaGrid",
4798
+ metaItem: "index_module_metaItem",
4799
+ metaLabel: "index_module_metaLabel",
4800
+ metaValue: "index_module_metaValue",
4801
+ linkList: "index_module_linkList",
4802
+ linkItem: "index_module_linkItem",
4803
+ linkTitle: "index_module_linkTitle",
4804
+ linkIndex: "index_module_linkIndex",
4805
+ linkSummary: "index_module_linkSummary",
4806
+ linkUrl: "index_module_linkUrl",
4807
+ statusBlock: "index_module_statusBlock",
4808
+ status_info: "index_module_status_info",
4809
+ status_success: "index_module_status_success",
4810
+ status_warning: "index_module_status_warning",
4811
+ status_error: "index_module_status_error",
4812
+ errorDisplay: "index_module_errorDisplay",
4641
4813
  sectionBlock: "index_module_sectionBlock",
4814
+ compactSectionBlock: "index_module_compactSectionBlock",
4815
+ contentScrollContainer: "index_module_contentScrollContainer",
4816
+ subAgentContainer: "index_module_subAgentContainer",
4817
+ subAgentHeader: "index_module_subAgentHeader",
4818
+ subAgentName: "index_module_subAgentName",
4819
+ subAgentMessages: "index_module_subAgentMessages",
4642
4820
  todoList: "index_module_todoList",
4643
4821
  todoItem: "index_module_todoItem",
4644
4822
  statusIconWrapper: "index_module_statusIconWrapper",
@@ -4647,25 +4825,89 @@ var index_module_default2 = {
4647
4825
  completed: "index_module_completed",
4648
4826
  emptyText: "index_module_emptyText"
4649
4827
  };
4650
- var DefaultToolRender = ({ argsContent, resultContent, errorMessage, item }) => {
4651
- return /* @__PURE__ */ jsxs(Fragment, { children: [
4652
- (item.content || item.arguments) && argsContent && /* @__PURE__ */ jsxs("div", { className: index_module_default2.sectionBlock, children: [
4653
- /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: "\u8F93\u5165\u53C2\u6570" }),
4654
- /* @__PURE__ */ jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: argsContent.isJson ? `\`\`\`json
4828
+ var toMarkdown = (content, kind, lang) => {
4829
+ if (kind === "markdown") return content;
4830
+ if (kind === "data") return `\`\`\`json
4831
+ ${content}
4832
+ \`\`\``;
4833
+ return lang ? `\`\`\`${lang}
4834
+ ${content}
4835
+ \`\`\`` : `\`\`\`
4836
+ ${content}
4837
+ \`\`\``;
4838
+ };
4839
+ var renderBlock = (block, index) => {
4840
+ if (block.kind === "status") {
4841
+ return /* @__PURE__ */ jsx("div", { className: `${index_module_default2.statusBlock} ${index_module_default2[`status_${block.level}`] || ""}`, children: block.text }, `status-${index}`);
4842
+ }
4843
+ if (block.kind === "key_value") {
4844
+ return /* @__PURE__ */ jsxs("div", { className: index_module_default2.sectionBlock, children: [
4845
+ block.title && /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: block.title }),
4846
+ /* @__PURE__ */ jsx("div", { className: index_module_default2.metaGrid, children: block.items.map((item, itemIndex) => /* @__PURE__ */ jsxs("div", { className: index_module_default2.metaItem, children: [
4847
+ /* @__PURE__ */ jsx("span", { className: index_module_default2.metaLabel, children: item.label }),
4848
+ /* @__PURE__ */ jsx("span", { className: index_module_default2.metaValue, children: item.value })
4849
+ ] }, `${item.label}-${itemIndex}`)) })
4850
+ ] }, `kv-${index}`);
4851
+ }
4852
+ if (block.kind === "links") {
4853
+ return /* @__PURE__ */ jsxs("div", { className: index_module_default2.sectionBlock, children: [
4854
+ block.title && /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: block.title }),
4855
+ /* @__PURE__ */ jsx("div", { className: index_module_default2.linkList, children: block.items.map((item, itemIndex) => /* @__PURE__ */ jsxs("a", { href: item.url, target: "_blank", rel: "noreferrer", className: index_module_default2.linkItem, children: [
4856
+ /* @__PURE__ */ jsxs("span", { className: index_module_default2.linkIndex, children: [
4857
+ itemIndex + 1,
4858
+ "."
4859
+ ] }),
4860
+ /* @__PURE__ */ jsx("span", { className: index_module_default2.linkTitle, children: item.title })
4861
+ ] }, `${item.url}-${itemIndex}`)) })
4862
+ ] }, `links-${index}`);
4863
+ }
4864
+ const markdown = block.kind === "markdown" ? block.content : toMarkdown(block.content, "code", block.lang);
4865
+ return /* @__PURE__ */ jsxs("div", { className: index_module_default2.sectionBlock, children: [
4866
+ block.title && /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: block.title }),
4867
+ /* @__PURE__ */ jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: markdown }) })
4868
+ ] }, `${block.kind}-${index}`);
4869
+ };
4870
+ var renderDisplayView = (view, fallbackLabel) => {
4871
+ if (!view) return null;
4872
+ const hasBody = view.blocks && view.blocks.length > 0 || view.meta && view.meta.length > 0 || view.summary;
4873
+ if (!hasBody) return null;
4874
+ const hasRichBody = !!(view.blocks && view.blocks.length > 0);
4875
+ const isOnlyLinksBlock = !view.summary && (!view.meta || view.meta.length === 0) && view.blocks?.length === 1 && view.blocks[0].kind === "links";
4876
+ const label = isOnlyLinksBlock ? void 0 : (hasRichBody ? view.title : void 0);
4877
+ return /* @__PURE__ */ jsxs("div", { className: `${index_module_default2.sectionBlock} ${!hasRichBody ? index_module_default2.compactSectionBlock : ""}`, children: [
4878
+ label && /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: label }),
4879
+ view.summary && /* @__PURE__ */ jsx("div", { className: index_module_default2.summaryText, children: view.summary }),
4880
+ view.meta && view.meta.length > 0 && /* @__PURE__ */ jsx("div", { className: index_module_default2.metaGrid, children: view.meta.map((item, index) => /* @__PURE__ */ jsxs("div", { className: index_module_default2.metaItem, children: [
4881
+ /* @__PURE__ */ jsx("span", { className: index_module_default2.metaLabel, children: item.label }),
4882
+ /* @__PURE__ */ jsx("span", { className: index_module_default2.metaValue, children: item.value })
4883
+ ] }, `${item.label}-${index}`)) }),
4884
+ view.blocks?.map((block, index) => renderBlock(block, index))
4885
+ ] });
4886
+ };
4887
+ var DefaultToolRender = ({ argsContent, resultContent, item }) => {
4888
+ const sd = item.streamingArgsDisplay;
4889
+ const isError = item.isError || item.status === "error";
4890
+ const hasStructuredDisplay = !!item.displayProtocol || !!sd?.content || !!item.argsDisplay || !!item.resultDisplay;
4891
+ return /* @__PURE__ */ jsxs("div", { className: isError ? index_module_default2.errorDisplay : "", children: [
4892
+ !item.argsDisplay && sd?.content && /* @__PURE__ */ jsxs("div", { className: `${index_module_default2.sectionBlock} ${index_module_default2.compactSectionBlock}`, children: [
4893
+ /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: sd.title || "\u8F93\u5165\u751F\u6210\u4E2D" }),
4894
+ /* @__PURE__ */ jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: toMarkdown(sd.content, sd.kind, sd.lang) }) })
4895
+ ] }),
4896
+ renderDisplayView(item.argsDisplay),
4897
+ renderDisplayView(item.resultDisplay),
4898
+ !hasStructuredDisplay && /* @__PURE__ */ jsxs(Fragment, { children: [
4899
+ (item.content || item.arguments) && argsContent && /* @__PURE__ */ jsxs("div", { className: index_module_default2.sectionBlock, children: [
4900
+ /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: "\u8F93\u5165\u53C2\u6570" }),
4901
+ /* @__PURE__ */ jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: argsContent.isJson ? `\`\`\`json
4655
4902
  ${argsContent.text}
4656
4903
  \`\`\`` : argsContent.text }) })
4657
- ] }),
4658
- item.result && resultContent && /* @__PURE__ */ jsxs("div", { className: index_module_default2.sectionBlock, children: [
4659
- /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: "\u8FD4\u56DE\u7ED3\u679C" }),
4660
- /* @__PURE__ */ jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: resultContent.isJson ? `\`\`\`json
4904
+ ] }),
4905
+ item.result && resultContent && /* @__PURE__ */ jsxs("div", { className: index_module_default2.sectionBlock, children: [
4906
+ /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: "\u8FD4\u56DE\u7ED3\u679C" }),
4907
+ /* @__PURE__ */ jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: resultContent.isJson ? `\`\`\`json
4661
4908
  ${resultContent.text}
4662
4909
  \`\`\`` : resultContent.text }) })
4663
- ] }),
4664
- errorMessage && /* @__PURE__ */ jsxs("div", { className: index_module_default2.sectionBlock, children: [
4665
- /* @__PURE__ */ jsx(Typography.Text, { className: index_module_default2.sectionLabel, children: "\u9519\u8BEF\u4FE1\u606F" }),
4666
- /* @__PURE__ */ jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: `\`\`\`
4667
- ${errorMessage}
4668
- \`\`\`` }) })
4910
+ ] })
4669
4911
  ] })
4670
4912
  ] });
4671
4913
  };
@@ -4749,9 +4991,12 @@ var formatContent = (content) => {
4749
4991
  return { text, isJson: false, parsed: null };
4750
4992
  }
4751
4993
  };
4994
+ var hasDisplayViewBody = (view) => {
4995
+ return !!(view?.summary || view?.blocks?.length || view?.meta?.length);
4996
+ };
4752
4997
  var ToolCallItem = ({ item }) => {
4753
4998
  const { token } = theme.useToken();
4754
- const renderConfig = getToolRenderConfig(item.toolName);
4999
+ const renderConfig = getToolRenderConfig(item);
4755
5000
  const CustomRender = renderConfig.component;
4756
5001
  const status = useMemo(() => {
4757
5002
  if (item.status) return item.status;
@@ -4775,35 +5020,36 @@ var ToolCallItem = ({ item }) => {
4775
5020
  alwaysShow = renderConfig.alwaysShowContent;
4776
5021
  }
4777
5022
  if (alwaysShow) return true;
4778
- return Boolean(item.errorMessage);
4779
- }, [renderConfig.disableExpandOnError, renderConfig.alwaysShowContent, item.errorMessage, status, argsContent.parsed, resultContent?.parsed]);
5023
+ if (item.displayProtocol) {
5024
+ if (item.streamingArgsDisplay?.content) return true;
5025
+ if (hasDisplayViewBody(item.argsDisplay)) return true;
5026
+ if (hasDisplayViewBody(item.resultDisplay)) return true;
5027
+ return false;
5028
+ }
5029
+ if (argsContent.text) return true;
5030
+ if (resultContent?.text) return true;
5031
+ return false;
5032
+ }, [
5033
+ renderConfig.disableExpandOnError,
5034
+ renderConfig.alwaysShowContent,
5035
+ item.displayProtocol,
5036
+ item.streamingArgsDisplay,
5037
+ item.argsDisplay,
5038
+ item.resultDisplay,
5039
+ status,
5040
+ argsContent.parsed,
5041
+ resultContent?.parsed,
5042
+ argsContent.text,
5043
+ resultContent?.text
5044
+ ]);
4780
5045
  const isDefaultExpanded = useMemo(() => {
4781
5046
  if (typeof renderConfig.defaultExpanded === "function") {
4782
5047
  return renderConfig.defaultExpanded(argsContent.parsed, resultContent?.parsed);
4783
5048
  }
4784
5049
  return renderConfig.defaultExpanded;
4785
5050
  }, [renderConfig.defaultExpanded, argsContent.parsed, resultContent?.parsed]);
4786
- const statusConfig = {
4787
- running: {
4788
- icon: /* @__PURE__ */ jsx(LoadingOutlined, {}),
4789
- color: token.colorPrimary
4790
- },
4791
- success: {
4792
- icon: null,
4793
- color: token.colorSuccess
4794
- },
4795
- error: {
4796
- icon: null,
4797
- color: token.colorSuccess
4798
- },
4799
- pending: {
4800
- icon: /* @__PURE__ */ jsx(LoadingOutlined, {}),
4801
- color: token.colorTextSecondary
4802
- }
4803
- }[status] || {
4804
- icon: /* @__PURE__ */ jsx(LoadingOutlined, {}),
4805
- color: token.colorPrimary
4806
- };
5051
+ const showLoading = status === "running" || status === "pending";
5052
+ const displayName = item.title || (showLoading ? "" : item.toolName || "Unknown Tool");
4807
5053
  const renderIcon = () => {
4808
5054
  if (!item.toolIcon) {
4809
5055
  return /* @__PURE__ */ jsx(ToolOutlined, { style: { fontSize: 14, color: token.colorTextSecondary } });
@@ -4817,13 +5063,19 @@ var ToolCallItem = ({ item }) => {
4817
5063
  return /* @__PURE__ */ jsx(
4818
5064
  Collapse,
4819
5065
  {
4820
- style: { width: "70%" },
5066
+ className: index_module_default2.toolCollapse,
5067
+ style: { width: "100%" },
4821
5068
  collapsible: hasContent ? void 0 : "disabled",
4822
5069
  defaultActiveKey: isDefaultExpanded && hasContent ? [item.toolCallId || "fallback-key"] : void 0,
4823
5070
  expandIconPlacement: "end",
5071
+ expandIcon: ({ isActive }) => hasContent ? /* @__PURE__ */ jsx(RightOutlined, { className: `${index_module_default2.expandIcon} ${isActive ? index_module_default2.expanded : ""}` }) : null,
4824
5072
  styles: {
4825
5073
  header: {
4826
- padding: "6px 10px"
5074
+ padding: "4px 8px",
5075
+ overflow: "hidden"
5076
+ },
5077
+ body: {
5078
+ padding: "0 8px 8px"
4827
5079
  }
4828
5080
  },
4829
5081
  items: [
@@ -4832,14 +5084,18 @@ var ToolCallItem = ({ item }) => {
4832
5084
  showArrow: hasContent,
4833
5085
  label: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 8, style: { flex: 1, minWidth: 0 }, children: [
4834
5086
  /* @__PURE__ */ jsx("div", { className: index_module_default2.iconContainer, children: renderIcon() }),
4835
- /* @__PURE__ */ jsx("span", { className: index_module_default2.toolName, children: item.title || item.toolName || "Unknown Tool" }),
4836
- (status === "running" || status === "pending") && /* @__PURE__ */ jsx("div", { className: index_module_default2.statusIcon, style: { color: statusConfig.color }, children: statusConfig.icon }),
5087
+ displayName ? /* @__PURE__ */ jsx("span", { className: index_module_default2.toolName, children: displayName }) : /* @__PURE__ */ jsxs("span", { className: index_module_default2.toolNamePending, children: [
5088
+ /* @__PURE__ */ jsx("span", { className: index_module_default2.dot }),
5089
+ /* @__PURE__ */ jsx("span", { className: index_module_default2.dot }),
5090
+ /* @__PURE__ */ jsx("span", { className: index_module_default2.dot })
5091
+ ] }),
5092
+ showLoading && /* @__PURE__ */ jsx("div", { className: index_module_default2.statusIcon, style: { color: token.colorPrimary }, children: /* @__PURE__ */ jsx(LoadingOutlined, {}) }),
4837
5093
  item.duration && /* @__PURE__ */ jsxs(Typography.Text, { className: index_module_default2.duration, children: [
4838
5094
  item.duration,
4839
5095
  "ms"
4840
5096
  ] })
4841
5097
  ] }),
4842
- children: /* @__PURE__ */ jsx(
5098
+ children: /* @__PURE__ */ jsx("div", { className: index_module_default2.contentScrollContainer, children: /* @__PURE__ */ jsx(
4843
5099
  CustomRender,
4844
5100
  {
4845
5101
  item,
@@ -4849,7 +5105,7 @@ var ToolCallItem = ({ item }) => {
4849
5105
  resultContent,
4850
5106
  errorMessage: item.errorMessage
4851
5107
  }
4852
- )
5108
+ ) })
4853
5109
  }
4854
5110
  ]
4855
5111
  }
@@ -4863,9 +5119,6 @@ var MessageRender_default = React10__default.memo(({ role, message: message3, me
4863
5119
  if (!RENDERABLE_MESSAGE_TYPES.includes(item.type)) {
4864
5120
  return false;
4865
5121
  }
4866
- if (item.type === "runStarted") {
4867
- return !!loading;
4868
- }
4869
5122
  if (item.type === "plan") {
4870
5123
  return !shouldHideA2uiPlan(item);
4871
5124
  }
@@ -4875,7 +5128,7 @@ var MessageRender_default = React10__default.memo(({ role, message: message3, me
4875
5128
  }
4876
5129
  return true;
4877
5130
  });
4878
- }, [loading, message3.content]);
5131
+ }, [message3.content]);
4879
5132
  const quoteMsg = useMemo(() => {
4880
5133
  const quoteMsg2 = {};
4881
5134
  if (message3.params) {
@@ -4889,7 +5142,8 @@ var MessageRender_default = React10__default.memo(({ role, message: message3, me
4889
5142
  }
4890
5143
  return isEmptyObj(quoteMsg2) ? null : quoteMsg2;
4891
5144
  }, [message3.params, message3.quoteMsg]);
4892
- if (content.length === 0) return null;
5145
+ const showPending = loading && (content.length === 0 || content[content.length - 1].type !== "text");
5146
+ if (content.length === 0 && !showPending) return null;
4893
5147
  const lastToolCallIndex = (() => {
4894
5148
  let lastIdx = -1;
4895
5149
  content.forEach((item, i) => {
@@ -4906,7 +5160,6 @@ var MessageRender_default = React10__default.memo(({ role, message: message3, me
4906
5160
  placement: role.placement,
4907
5161
  variant: item.type === "files" ? "borderless" : void 0,
4908
5162
  content: /* @__PURE__ */ jsxs(Fragment, { children: [
4909
- item.type === "runStarted" && /* @__PURE__ */ jsx(RunStartedNode, { loading }, `flow-start-${index}`),
4910
5163
  (item.type === "toolCall" || item.type === "toolResult") && /* @__PURE__ */ jsx(tool_call_item_default, { item }, `tool-call-${item.toolCallId || index}`),
4911
5164
  item.type === "text" && /* @__PURE__ */ jsx(
4912
5165
  TextNode2,
@@ -4927,6 +5180,7 @@ var MessageRender_default = React10__default.memo(({ role, message: message3, me
4927
5180
  ),
4928
5181
  index === lastToolCallIndex && messageIndex >= 0 ? /* @__PURE__ */ jsx(A2uiMessageCards, { messageIndex, message: message3 }) : null
4929
5182
  ] }, `message-${index}`)),
5183
+ showPending && /* @__PURE__ */ jsx(Bubble, { role: role.user, placement: role.placement, content: /* @__PURE__ */ jsx(RunStartedNode, {}) }),
4930
5184
  quoteMsg && /* @__PURE__ */ jsx(QuoteMsgNode, { quoteMsg, role })
4931
5185
  ] });
4932
5186
  });
@@ -5226,7 +5480,7 @@ var ResourceSelectorModal_default = ({ open, type, onCancel }) => {
5226
5480
  setCategories([{ id: ALL_CATEGORY_ID, name: "\u5168\u90E8" }, ...tagsRes.data || []]);
5227
5481
  setResources(fetchedResources);
5228
5482
  const spec = conversationState.active.spec;
5229
- const initialItems = isSkill ? spec?.skills?.items : spec?.knowledge?.items;
5483
+ const initialItems = isSkill ? spec?.skills?.items : spec?.knowledges?.items;
5230
5484
  const validIds = new Set(fetchedResources.map((r) => r.id));
5231
5485
  const validSelectedIds = (initialItems || []).map((item) => item.id).filter((id) => validIds.has(id));
5232
5486
  setSelectedIds(validSelectedIds);
@@ -5273,7 +5527,7 @@ var ResourceSelectorModal_default = ({ open, type, onCancel }) => {
5273
5527
  items: ids.map((id) => ({ id }))
5274
5528
  };
5275
5529
  } else {
5276
- nextSpec.knowledge = {
5530
+ nextSpec.knowledges = {
5277
5531
  items: ids.map((id) => {
5278
5532
  const resource = resourceList.find((r) => r.id === id);
5279
5533
  return { id, name: resource?.name || "" };
@@ -5420,7 +5674,7 @@ var KnowledgeBtn_default = ({}) => {
5420
5674
  const chatStore = useChatStore();
5421
5675
  const conversationState = useSnapshot(chatStore.conversation);
5422
5676
  const [modalOpen, setModalOpen] = useState(false);
5423
- const knowledgeCount = conversationState.active.spec?.knowledge?.items?.length ?? 0;
5677
+ const knowledgeCount = conversationState.active.spec?.knowledges?.items?.length ?? 0;
5424
5678
  return /* @__PURE__ */ jsxs(Fragment, { children: [
5425
5679
  /* @__PURE__ */ jsxs("div", { className: style_module_default.resourceBtn, onClick: () => setModalOpen(true), children: [
5426
5680
  /* @__PURE__ */ jsx(IconFont_default, { type: "icon-remark" }),