@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.cjs.js +427 -173
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +321 -49
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +97 -2
- package/dist/index.d.ts +97 -2
- package/dist/index.esm.js +429 -175
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -1308,7 +1308,7 @@ function createChatStore() {
|
|
|
1308
1308
|
const { data } = await config.services.request.createConversationId({ agentId: agent.agentInfo.id, convMeta: config.params.convMeta });
|
|
1309
1309
|
const newSpec = {
|
|
1310
1310
|
skills: { items: [] },
|
|
1311
|
-
|
|
1311
|
+
knowledges: { items: [] }
|
|
1312
1312
|
};
|
|
1313
1313
|
updateConversations({
|
|
1314
1314
|
id: data || "",
|
|
@@ -1401,9 +1401,14 @@ function createChatStore() {
|
|
|
1401
1401
|
});
|
|
1402
1402
|
conversation.messages[conversationId].message = [];
|
|
1403
1403
|
if (data?.length) {
|
|
1404
|
-
data.
|
|
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
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
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
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
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;
|
|
@@ -1625,37 +1623,39 @@ function createChatStore() {
|
|
|
1625
1623
|
messages.push(finalMsg);
|
|
1626
1624
|
} else {
|
|
1627
1625
|
const contents = messages[idx].content;
|
|
1628
|
-
|
|
1626
|
+
let existingItemIndex = contents.findIndex(
|
|
1629
1627
|
(item) => item.type === "toolCall" && item.toolCallId === contentItem.toolCallId
|
|
1630
1628
|
);
|
|
1629
|
+
if (existingItemIndex === -1 && contentItem.toolCallId) {
|
|
1630
|
+
existingItemIndex = contents.findIndex(
|
|
1631
|
+
(item) => item.type === "toolCall" && !item.toolCallId && item._streamingIndex !== void 0
|
|
1632
|
+
);
|
|
1633
|
+
}
|
|
1631
1634
|
if (existingItemIndex !== -1) {
|
|
1632
|
-
const
|
|
1635
|
+
const nextItem = { ...contents[existingItemIndex] };
|
|
1633
1636
|
const newContent = contentItem.content || contentItem.arguments;
|
|
1634
|
-
const nextItem = { ...existingItem };
|
|
1635
1637
|
if (typeof newContent === "string") {
|
|
1636
|
-
nextItem.content = (
|
|
1638
|
+
nextItem.content = (nextItem.content || "") + newContent;
|
|
1637
1639
|
} else if (newContent !== void 0) {
|
|
1638
1640
|
nextItem.arguments = newContent;
|
|
1639
1641
|
}
|
|
1640
|
-
if (contentItem.toolName)
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
if (contentItem.
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
nextItem.
|
|
1642
|
+
if (contentItem.toolName) nextItem.toolName = contentItem.toolName;
|
|
1643
|
+
if (contentItem.title) nextItem.title = contentItem.title;
|
|
1644
|
+
if (contentItem.status) nextItem.status = contentItem.status;
|
|
1645
|
+
if (contentItem.toolIcon) nextItem.toolIcon = contentItem.toolIcon;
|
|
1646
|
+
if (contentItem.display?.title) nextItem.title = contentItem.display.title;
|
|
1647
|
+
if (contentItem.display) {
|
|
1648
|
+
nextItem.argsDisplay = contentItem.display;
|
|
1649
|
+
nextItem.displayProtocol = true;
|
|
1648
1650
|
}
|
|
1649
1651
|
messages[idx].content = contents.map((item, i) => i === existingItemIndex ? nextItem : item);
|
|
1650
1652
|
} else {
|
|
1651
|
-
messages[idx].content = [...contents, contentItem];
|
|
1653
|
+
messages[idx].content = [...contents, { ...contentItem, displayProtocol: !!contentItem.display }];
|
|
1652
1654
|
}
|
|
1653
1655
|
}
|
|
1654
|
-
conversation.messages[msg.conversationId].loading = true;
|
|
1656
|
+
if (isMain) conversation.messages[msg.conversationId].loading = true;
|
|
1655
1657
|
}
|
|
1656
|
-
function toolResultCallback(msg) {
|
|
1657
|
-
const messages = conversation.messages[msg.conversationId]?.message;
|
|
1658
|
-
if (!messages) return;
|
|
1658
|
+
function toolResultCallback(msg, messages, isMain) {
|
|
1659
1659
|
const contentItem = msg.content[0];
|
|
1660
1660
|
if (contentItem.type !== "toolResult") return;
|
|
1661
1661
|
let idx = -1;
|
|
@@ -1669,32 +1669,28 @@ function createChatStore() {
|
|
|
1669
1669
|
const contents = messages[idx].content;
|
|
1670
1670
|
const toolCallIndex = contents.findIndex((item) => item.type === "toolCall" && item.toolCallId === contentItem.toolCallId);
|
|
1671
1671
|
if (toolCallIndex !== -1) {
|
|
1672
|
-
const toolCallItem = contents[toolCallIndex];
|
|
1673
1672
|
const nextToolCallItem = {
|
|
1674
|
-
...
|
|
1673
|
+
...contents[toolCallIndex],
|
|
1675
1674
|
result: contentItem.result ?? contentItem.content
|
|
1676
1675
|
};
|
|
1677
|
-
if (contentItem.status)
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
if (contentItem.
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
nextToolCallItem.title = contentItem.title;
|
|
1676
|
+
if (contentItem.status) nextToolCallItem.status = contentItem.status;
|
|
1677
|
+
if (contentItem.isError !== void 0) nextToolCallItem.isError = contentItem.isError;
|
|
1678
|
+
if (contentItem.errorMessage) nextToolCallItem.errorMessage = contentItem.errorMessage;
|
|
1679
|
+
const dur = contentItem.durationMs ?? contentItem.duration;
|
|
1680
|
+
if (dur !== void 0) nextToolCallItem.duration = dur;
|
|
1681
|
+
if (contentItem.title) nextToolCallItem.title = contentItem.title;
|
|
1682
|
+
if (contentItem.display?.title) nextToolCallItem.title = contentItem.display.title;
|
|
1683
|
+
if (contentItem.display) {
|
|
1684
|
+
nextToolCallItem.resultDisplay = contentItem.display;
|
|
1685
|
+
nextToolCallItem.displayProtocol = true;
|
|
1688
1686
|
}
|
|
1689
1687
|
messages[idx].content = contents.map((item, i) => i === toolCallIndex ? nextToolCallItem : item);
|
|
1690
1688
|
} else {
|
|
1691
1689
|
messages[idx].content = [...contents, contentItem];
|
|
1692
1690
|
}
|
|
1693
|
-
conversation.messages[msg.conversationId].loading = true;
|
|
1691
|
+
if (isMain) conversation.messages[msg.conversationId].loading = true;
|
|
1694
1692
|
}
|
|
1695
|
-
function a2uiCommandCallback(msg) {
|
|
1696
|
-
const messages = conversation.messages[msg.conversationId]?.message;
|
|
1697
|
-
if (!messages) return;
|
|
1693
|
+
function a2uiCommandCallback(msg, messages, isMain) {
|
|
1698
1694
|
const idx = findExecutionMsgIndex(msg, messages);
|
|
1699
1695
|
const contentItem = msg.content[0];
|
|
1700
1696
|
if (contentItem.type !== "a2uiCommand") return;
|
|
@@ -1705,45 +1701,162 @@ function createChatStore() {
|
|
|
1705
1701
|
const prevContent = messages[idx]?.content || [];
|
|
1706
1702
|
messages[idx].content = [...prevContent, contentItem];
|
|
1707
1703
|
}
|
|
1708
|
-
conversation.messages[msg.conversationId].loading = true;
|
|
1704
|
+
if (isMain) conversation.messages[msg.conversationId].loading = true;
|
|
1705
|
+
}
|
|
1706
|
+
function toolCallDeltaCallback(msg, messages, isMain) {
|
|
1707
|
+
const contentItem = msg.content[0];
|
|
1708
|
+
if (contentItem.type !== "toolCallDelta") return;
|
|
1709
|
+
let idx = -1;
|
|
1710
|
+
if (contentItem.toolCallId) {
|
|
1711
|
+
idx = messages.findLastIndex(
|
|
1712
|
+
(m) => m.content?.some((c) => c.type === "toolCall" && c.toolCallId === contentItem.toolCallId)
|
|
1713
|
+
);
|
|
1714
|
+
}
|
|
1715
|
+
if (idx === -1 && contentItem.index !== void 0) {
|
|
1716
|
+
idx = messages.findLastIndex(
|
|
1717
|
+
(m) => m.executionId === msg.executionId && m.content?.some((c) => c.type === "toolCall" && c._streamingIndex === contentItem.index && !c.toolCallId)
|
|
1718
|
+
);
|
|
1719
|
+
}
|
|
1720
|
+
if (idx === -1) idx = findExecutionMsgIndex(msg, messages);
|
|
1721
|
+
const buildNewItem = () => {
|
|
1722
|
+
const item = {
|
|
1723
|
+
type: "toolCall",
|
|
1724
|
+
toolCallId: contentItem.toolCallId || void 0,
|
|
1725
|
+
_streamingIndex: contentItem.index,
|
|
1726
|
+
toolName: contentItem.toolName || void 0,
|
|
1727
|
+
toolIcon: contentItem.toolIcon,
|
|
1728
|
+
title: contentItem.title,
|
|
1729
|
+
content: contentItem.displayDelta ? "" : contentItem.argumentsDelta || "",
|
|
1730
|
+
status: contentItem.status || "running",
|
|
1731
|
+
displayProtocol: !!contentItem.displayDelta
|
|
1732
|
+
};
|
|
1733
|
+
if (contentItem.displayDelta?.title) item.title = contentItem.displayDelta.title;
|
|
1734
|
+
if (contentItem.displayDelta?.contentAppend) {
|
|
1735
|
+
item.streamingArgsDisplay = {
|
|
1736
|
+
title: contentItem.displayDelta.title,
|
|
1737
|
+
content: contentItem.displayDelta.contentAppend,
|
|
1738
|
+
kind: contentItem.displayDelta.kind,
|
|
1739
|
+
lang: contentItem.displayDelta.lang
|
|
1740
|
+
};
|
|
1741
|
+
}
|
|
1742
|
+
return item;
|
|
1743
|
+
};
|
|
1744
|
+
if (idx === -1) {
|
|
1745
|
+
messages.push({ ...msg, content: [buildNewItem()], generating: true });
|
|
1746
|
+
} else {
|
|
1747
|
+
const contents = messages[idx].content;
|
|
1748
|
+
let itemIdx = -1;
|
|
1749
|
+
if (contentItem.toolCallId) {
|
|
1750
|
+
itemIdx = contents.findIndex((c) => c.type === "toolCall" && c.toolCallId === contentItem.toolCallId);
|
|
1751
|
+
}
|
|
1752
|
+
if (itemIdx === -1 && contentItem.index !== void 0) {
|
|
1753
|
+
itemIdx = contents.findIndex((c) => c.type === "toolCall" && c._streamingIndex === contentItem.index && !c.toolCallId);
|
|
1754
|
+
}
|
|
1755
|
+
if (itemIdx !== -1) {
|
|
1756
|
+
const existing = contents[itemIdx];
|
|
1757
|
+
const nextItem = {
|
|
1758
|
+
...existing,
|
|
1759
|
+
type: "toolCall",
|
|
1760
|
+
content: contentItem.displayDelta ? existing.content || "" : (existing.content || "") + (contentItem.argumentsDelta || "")
|
|
1761
|
+
};
|
|
1762
|
+
if (contentItem.toolCallId && !existing.toolCallId) nextItem.toolCallId = contentItem.toolCallId;
|
|
1763
|
+
if (contentItem.toolName) nextItem.toolName = contentItem.toolName;
|
|
1764
|
+
if (contentItem.title) nextItem.title = contentItem.title;
|
|
1765
|
+
if (contentItem.status) nextItem.status = contentItem.status;
|
|
1766
|
+
if (contentItem.toolIcon) nextItem.toolIcon = contentItem.toolIcon;
|
|
1767
|
+
if (contentItem.displayDelta) nextItem.displayProtocol = true;
|
|
1768
|
+
if (contentItem.displayDelta?.title) nextItem.title = contentItem.displayDelta.title;
|
|
1769
|
+
if (contentItem.displayDelta?.contentAppend) {
|
|
1770
|
+
nextItem.streamingArgsDisplay = {
|
|
1771
|
+
title: contentItem.displayDelta.title || existing.streamingArgsDisplay?.title,
|
|
1772
|
+
content: (existing.streamingArgsDisplay?.content || "") + contentItem.displayDelta.contentAppend,
|
|
1773
|
+
kind: contentItem.displayDelta.kind || existing.streamingArgsDisplay?.kind,
|
|
1774
|
+
lang: contentItem.displayDelta.lang ?? existing.streamingArgsDisplay?.lang
|
|
1775
|
+
};
|
|
1776
|
+
}
|
|
1777
|
+
messages[idx].content = contents.map((c, i) => i === itemIdx ? nextItem : c);
|
|
1778
|
+
} else {
|
|
1779
|
+
messages[idx].content = [...contents, buildNewItem()];
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
if (isMain) conversation.messages[msg.conversationId].loading = true;
|
|
1783
|
+
}
|
|
1784
|
+
function findToolCallItemRecursive(messages, toolCallId) {
|
|
1785
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
1786
|
+
const msg = messages[i];
|
|
1787
|
+
const contents = msg.content || [];
|
|
1788
|
+
const itemIdx = contents.findIndex((c) => c.type === "toolCall" && c.toolCallId === toolCallId);
|
|
1789
|
+
if (itemIdx !== -1) {
|
|
1790
|
+
return { messageList: msg, itemIndex: itemIdx };
|
|
1791
|
+
}
|
|
1792
|
+
for (const content of contents) {
|
|
1793
|
+
if (content.type === "toolCall") {
|
|
1794
|
+
const subMessages = content.subMessages;
|
|
1795
|
+
if (subMessages?.length) {
|
|
1796
|
+
const found = findToolCallItemRecursive(subMessages, toolCallId);
|
|
1797
|
+
if (found) return found;
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
return null;
|
|
1803
|
+
}
|
|
1804
|
+
function routeSubAgentMessage(msg) {
|
|
1805
|
+
const conversationId = msg.conversationId;
|
|
1806
|
+
const mainMessages = conversation.messages[conversationId]?.message;
|
|
1807
|
+
if (!mainMessages) return;
|
|
1808
|
+
const found = findToolCallItemRecursive(mainMessages, msg.toolCallId);
|
|
1809
|
+
if (!found) {
|
|
1810
|
+
return;
|
|
1811
|
+
}
|
|
1812
|
+
const { messageList, itemIndex } = found;
|
|
1813
|
+
const contents = messageList.content;
|
|
1814
|
+
const toolCallItem = contents[itemIndex];
|
|
1815
|
+
toolCallItem.hasSubAgent = true;
|
|
1816
|
+
if (!toolCallItem.subMessages) {
|
|
1817
|
+
toolCallItem.subMessages = [];
|
|
1818
|
+
}
|
|
1819
|
+
processMessageContent(msg, toolCallItem.subMessages);
|
|
1820
|
+
messageList.content = contents.map((c, i) => i === itemIndex ? { ...toolCallItem } : c);
|
|
1709
1821
|
}
|
|
1710
|
-
function processSingleMessageContent(newMessage) {
|
|
1822
|
+
function processSingleMessageContent(newMessage, messages, isMain) {
|
|
1711
1823
|
switch (newMessage.content[0].type) {
|
|
1712
1824
|
case "runStarted":
|
|
1713
|
-
startCallback(newMessage);
|
|
1825
|
+
startCallback(newMessage, messages, isMain);
|
|
1714
1826
|
break;
|
|
1715
1827
|
case "text":
|
|
1716
|
-
textCallback(newMessage);
|
|
1828
|
+
textCallback(newMessage, messages, isMain);
|
|
1717
1829
|
break;
|
|
1718
1830
|
case "stepStarted":
|
|
1719
|
-
stepStartedCallback(newMessage);
|
|
1831
|
+
stepStartedCallback(newMessage, messages, isMain);
|
|
1720
1832
|
break;
|
|
1721
1833
|
case "stepFinished":
|
|
1722
|
-
stepFinishedCallback(newMessage);
|
|
1834
|
+
stepFinishedCallback(newMessage, messages, isMain);
|
|
1723
1835
|
break;
|
|
1724
1836
|
case "stepError":
|
|
1725
|
-
stepErrCallback(newMessage);
|
|
1837
|
+
stepErrCallback(newMessage, messages, isMain);
|
|
1726
1838
|
break;
|
|
1727
1839
|
case "runFinished":
|
|
1728
1840
|
case "runFailed":
|
|
1729
1841
|
case "runStopped":
|
|
1730
|
-
doneCallback(newMessage);
|
|
1842
|
+
doneCallback(newMessage, messages, isMain);
|
|
1731
1843
|
break;
|
|
1732
1844
|
case "conversationNewTitle":
|
|
1733
|
-
titleCallback(newMessage);
|
|
1845
|
+
titleCallback(newMessage, messages, isMain);
|
|
1734
1846
|
break;
|
|
1735
1847
|
case "toolCall":
|
|
1736
|
-
toolCallCallback(newMessage);
|
|
1848
|
+
toolCallCallback(newMessage, messages, isMain);
|
|
1849
|
+
break;
|
|
1850
|
+
case "toolCallDelta":
|
|
1851
|
+
toolCallDeltaCallback(newMessage, messages, isMain);
|
|
1737
1852
|
break;
|
|
1738
1853
|
case "toolResult":
|
|
1739
|
-
toolResultCallback(newMessage);
|
|
1854
|
+
toolResultCallback(newMessage, messages, isMain);
|
|
1740
1855
|
break;
|
|
1741
1856
|
case "a2uiCommand":
|
|
1742
|
-
a2uiCommandCallback(newMessage);
|
|
1857
|
+
a2uiCommandCallback(newMessage, messages, isMain);
|
|
1743
1858
|
break;
|
|
1744
1859
|
default: {
|
|
1745
|
-
const messages = conversation.messages[newMessage.conversationId]?.message;
|
|
1746
|
-
if (!messages) return;
|
|
1747
1860
|
const idx = findExecutionMsgIndex(newMessage, messages);
|
|
1748
1861
|
if (idx === -1) {
|
|
1749
1862
|
const finalMsg = { ...newMessage, generating: true };
|
|
@@ -1752,20 +1865,21 @@ function createChatStore() {
|
|
|
1752
1865
|
const prevContent = messages[idx]?.content || [];
|
|
1753
1866
|
messages[idx].content = [...prevContent, ...newMessage.content];
|
|
1754
1867
|
}
|
|
1755
|
-
conversation.messages[newMessage.conversationId].loading = true;
|
|
1868
|
+
if (isMain) conversation.messages[newMessage.conversationId].loading = true;
|
|
1756
1869
|
break;
|
|
1757
1870
|
}
|
|
1758
1871
|
}
|
|
1759
1872
|
}
|
|
1760
|
-
function processMessageContent(message3) {
|
|
1873
|
+
function processMessageContent(message3, targetMessages) {
|
|
1761
1874
|
const newMessage = {
|
|
1762
1875
|
...message3,
|
|
1763
1876
|
agentId: agent.agentInfo.id
|
|
1764
1877
|
};
|
|
1878
|
+
const isMain = !targetMessages;
|
|
1879
|
+
const messages = targetMessages ?? conversation.messages[newMessage.conversationId]?.message;
|
|
1880
|
+
if (!messages) return;
|
|
1765
1881
|
const contentList = Array.isArray(newMessage.content) ? newMessage.content : [];
|
|
1766
1882
|
if (contentList.length === 0) {
|
|
1767
|
-
const messages = conversation.messages[newMessage.conversationId]?.message;
|
|
1768
|
-
if (!messages) return;
|
|
1769
1883
|
const idx = findExecutionMsgIndex(newMessage, messages);
|
|
1770
1884
|
if (idx === -1) {
|
|
1771
1885
|
messages.push({ ...newMessage });
|
|
@@ -1781,17 +1895,32 @@ function createChatStore() {
|
|
|
1781
1895
|
return;
|
|
1782
1896
|
}
|
|
1783
1897
|
contentList.forEach((contentItem) => {
|
|
1784
|
-
processSingleMessageContent(
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1898
|
+
processSingleMessageContent(
|
|
1899
|
+
{
|
|
1900
|
+
...newMessage,
|
|
1901
|
+
content: [contentItem]
|
|
1902
|
+
},
|
|
1903
|
+
messages,
|
|
1904
|
+
isMain
|
|
1905
|
+
);
|
|
1788
1906
|
});
|
|
1789
|
-
normalizeMessagesByExecutionAndRole(
|
|
1907
|
+
normalizeMessagesByExecutionAndRole(messages);
|
|
1790
1908
|
}
|
|
1791
1909
|
function isStoppedIncomingMessage(newMessage) {
|
|
1792
1910
|
const messages = conversation.messages[newMessage.conversationId]?.message;
|
|
1793
1911
|
if (!messages) return false;
|
|
1794
|
-
|
|
1912
|
+
if (messages.some((item) => item.stopFlag && item.executionId === newMessage.executionId)) {
|
|
1913
|
+
return true;
|
|
1914
|
+
}
|
|
1915
|
+
return messages.some(
|
|
1916
|
+
(msg) => msg.content?.some((c) => {
|
|
1917
|
+
if (c.type === "toolCall") {
|
|
1918
|
+
const subMessages = c.subMessages;
|
|
1919
|
+
return subMessages?.some((sub) => sub.stopFlag && sub.executionId === newMessage.executionId);
|
|
1920
|
+
}
|
|
1921
|
+
return false;
|
|
1922
|
+
})
|
|
1923
|
+
);
|
|
1795
1924
|
}
|
|
1796
1925
|
const acceptMessage = async (newMessage) => {
|
|
1797
1926
|
const conversationId = newMessage.conversationId;
|
|
@@ -1801,6 +1930,10 @@ function createChatStore() {
|
|
|
1801
1930
|
if (canProceed === false) {
|
|
1802
1931
|
throw new Error("\u64CD\u4F5C\u88AB\u963B\u6B62");
|
|
1803
1932
|
}
|
|
1933
|
+
if (newMessage.toolCallId) {
|
|
1934
|
+
routeSubAgentMessage(newMessage);
|
|
1935
|
+
return;
|
|
1936
|
+
}
|
|
1804
1937
|
if (isStoppedIncomingMessage(newMessage)) {
|
|
1805
1938
|
conversation.messages[conversationId].loading = false;
|
|
1806
1939
|
return;
|
|
@@ -1873,6 +2006,11 @@ function createChatStore() {
|
|
|
1873
2006
|
const dealedParams = await config.hooks?.onHandleSendParams?.(sendParams);
|
|
1874
2007
|
await config.services.request.sendMessageStream(dealedParams || sendParams, agent.agentInfo?.id || "");
|
|
1875
2008
|
config.hooks?.onAfterSend?.();
|
|
2009
|
+
} catch (err) {
|
|
2010
|
+
conversation.messages[conversationId].loading = false;
|
|
2011
|
+
const errMsg = err?.response?.data?.message || err?.message || "\u53D1\u9001\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";
|
|
2012
|
+
antd.message.error(errMsg);
|
|
2013
|
+
throw err;
|
|
1876
2014
|
} finally {
|
|
1877
2015
|
}
|
|
1878
2016
|
};
|
|
@@ -1882,19 +2020,25 @@ function createChatStore() {
|
|
|
1882
2020
|
const lastMsg = messages[messages.length - 1];
|
|
1883
2021
|
if (lastMsg.executionId) {
|
|
1884
2022
|
await config.services.request.cancelMessage(lastMsg.executionId);
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
item.
|
|
1888
|
-
|
|
2023
|
+
const markStopped = (msgList, matchExecutionId) => {
|
|
2024
|
+
msgList.forEach((item) => {
|
|
2025
|
+
if (item.executionId === lastMsg.executionId) {
|
|
2026
|
+
item.generating = false;
|
|
2027
|
+
item.stopFlag = true;
|
|
2028
|
+
}
|
|
1889
2029
|
if (item.content && Array.isArray(item.content)) {
|
|
1890
2030
|
item.content.forEach((contentItem) => {
|
|
1891
2031
|
if (contentItem.type === "toolCall" && contentItem.status !== "success" && contentItem.status !== "error") {
|
|
1892
2032
|
contentItem.status = "error";
|
|
1893
2033
|
}
|
|
2034
|
+
if (contentItem.subMessages?.length) {
|
|
2035
|
+
markStopped(contentItem.subMessages);
|
|
2036
|
+
}
|
|
1894
2037
|
});
|
|
1895
2038
|
}
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
2039
|
+
});
|
|
2040
|
+
};
|
|
2041
|
+
markStopped(messages);
|
|
1898
2042
|
} else {
|
|
1899
2043
|
lastMsg.stopFlag = true;
|
|
1900
2044
|
lastMsg.generating = false;
|
|
@@ -4576,7 +4720,8 @@ var FilesNode = React10__namespace.default.memo(({ item }) => {
|
|
|
4576
4720
|
|
|
4577
4721
|
// src/components/CustomComponents/MessageNode/style.module.less
|
|
4578
4722
|
var style_module_default2 = {
|
|
4579
|
-
runStartedNode: "style_module_runStartedNode"
|
|
4723
|
+
runStartedNode: "style_module_runStartedNode",
|
|
4724
|
+
dot: "style_module_dot"};
|
|
4580
4725
|
var QuoteMsgNode = React10__namespace.default.memo(({ quoteMsg, role }) => {
|
|
4581
4726
|
if (!quoteMsg || !quoteMsg.messageContent) return null;
|
|
4582
4727
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4607,9 +4752,12 @@ var QuoteMsgNode = React10__namespace.default.memo(({ quoteMsg, role }) => {
|
|
|
4607
4752
|
}
|
|
4608
4753
|
);
|
|
4609
4754
|
});
|
|
4610
|
-
var RunStartedNode = React10__namespace.default.memo((
|
|
4611
|
-
|
|
4612
|
-
|
|
4755
|
+
var RunStartedNode = React10__namespace.default.memo(() => {
|
|
4756
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: style_module_default2.runStartedNode, children: [
|
|
4757
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: style_module_default2.dot }),
|
|
4758
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: style_module_default2.dot }),
|
|
4759
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: style_module_default2.dot })
|
|
4760
|
+
] });
|
|
4613
4761
|
});
|
|
4614
4762
|
var RESOURCE_MARKDOWN_TAG = "resourcetag";
|
|
4615
4763
|
var RESOURCE_TOKEN_REGEX = /(\w+):\/\/([^?\s]+)\?name=([^&\s]+)&label=([^\s]+)/g;
|
|
@@ -4661,13 +4809,43 @@ var TextNode2 = React10__namespace.default.memo(
|
|
|
4661
4809
|
|
|
4662
4810
|
// src/components/CustomComponents/ToolRenders/index.module.less
|
|
4663
4811
|
var index_module_default2 = {
|
|
4812
|
+
toolCollapse: "index_module_toolCollapse",
|
|
4664
4813
|
iconContainer: "index_module_iconContainer",
|
|
4665
4814
|
toolName: "index_module_toolName",
|
|
4815
|
+
toolNamePending: "index_module_toolNamePending",
|
|
4816
|
+
dot: "index_module_dot",
|
|
4817
|
+
dotBlink: "index_module_dotBlink",
|
|
4666
4818
|
duration: "index_module_duration",
|
|
4667
4819
|
statusIcon: "index_module_statusIcon",
|
|
4820
|
+
expandIcon: "index_module_expandIcon",
|
|
4821
|
+
expanded: "index_module_expanded",
|
|
4668
4822
|
sectionLabel: "index_module_sectionLabel",
|
|
4823
|
+
plainTextContainer: "index_module_plainTextContainer",
|
|
4669
4824
|
markdownContainer: "index_module_markdownContainer",
|
|
4825
|
+
summaryText: "index_module_summaryText",
|
|
4826
|
+
metaGrid: "index_module_metaGrid",
|
|
4827
|
+
metaItem: "index_module_metaItem",
|
|
4828
|
+
metaLabel: "index_module_metaLabel",
|
|
4829
|
+
metaValue: "index_module_metaValue",
|
|
4830
|
+
linkList: "index_module_linkList",
|
|
4831
|
+
linkItem: "index_module_linkItem",
|
|
4832
|
+
linkTitle: "index_module_linkTitle",
|
|
4833
|
+
linkIndex: "index_module_linkIndex",
|
|
4834
|
+
linkSummary: "index_module_linkSummary",
|
|
4835
|
+
linkUrl: "index_module_linkUrl",
|
|
4836
|
+
statusBlock: "index_module_statusBlock",
|
|
4837
|
+
status_info: "index_module_status_info",
|
|
4838
|
+
status_success: "index_module_status_success",
|
|
4839
|
+
status_warning: "index_module_status_warning",
|
|
4840
|
+
status_error: "index_module_status_error",
|
|
4841
|
+
errorDisplay: "index_module_errorDisplay",
|
|
4670
4842
|
sectionBlock: "index_module_sectionBlock",
|
|
4843
|
+
compactSectionBlock: "index_module_compactSectionBlock",
|
|
4844
|
+
contentScrollContainer: "index_module_contentScrollContainer",
|
|
4845
|
+
subAgentContainer: "index_module_subAgentContainer",
|
|
4846
|
+
subAgentHeader: "index_module_subAgentHeader",
|
|
4847
|
+
subAgentName: "index_module_subAgentName",
|
|
4848
|
+
subAgentMessages: "index_module_subAgentMessages",
|
|
4671
4849
|
todoList: "index_module_todoList",
|
|
4672
4850
|
todoItem: "index_module_todoItem",
|
|
4673
4851
|
statusIconWrapper: "index_module_statusIconWrapper",
|
|
@@ -4676,25 +4854,89 @@ var index_module_default2 = {
|
|
|
4676
4854
|
completed: "index_module_completed",
|
|
4677
4855
|
emptyText: "index_module_emptyText"
|
|
4678
4856
|
};
|
|
4679
|
-
var
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4857
|
+
var toMarkdown = (content, kind, lang) => {
|
|
4858
|
+
if (kind === "markdown") return content;
|
|
4859
|
+
if (kind === "data") return `\`\`\`json
|
|
4860
|
+
${content}
|
|
4861
|
+
\`\`\``;
|
|
4862
|
+
return lang ? `\`\`\`${lang}
|
|
4863
|
+
${content}
|
|
4864
|
+
\`\`\`` : `\`\`\`
|
|
4865
|
+
${content}
|
|
4866
|
+
\`\`\``;
|
|
4867
|
+
};
|
|
4868
|
+
var renderBlock = (block, index) => {
|
|
4869
|
+
if (block.kind === "status") {
|
|
4870
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${index_module_default2.statusBlock} ${index_module_default2[`status_${block.level}`] || ""}`, children: block.text }, `status-${index}`);
|
|
4871
|
+
}
|
|
4872
|
+
if (block.kind === "key_value") {
|
|
4873
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: index_module_default2.sectionBlock, children: [
|
|
4874
|
+
block.title && /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: index_module_default2.sectionLabel, children: block.title }),
|
|
4875
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.metaGrid, children: block.items.map((item, itemIndex) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: index_module_default2.metaItem, children: [
|
|
4876
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.metaLabel, children: item.label }),
|
|
4877
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.metaValue, children: item.value })
|
|
4878
|
+
] }, `${item.label}-${itemIndex}`)) })
|
|
4879
|
+
] }, `kv-${index}`);
|
|
4880
|
+
}
|
|
4881
|
+
if (block.kind === "links") {
|
|
4882
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: index_module_default2.sectionBlock, children: [
|
|
4883
|
+
block.title && /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: index_module_default2.sectionLabel, children: block.title }),
|
|
4884
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.linkList, children: block.items.map((item, itemIndex) => /* @__PURE__ */ jsxRuntime.jsxs("a", { href: item.url, target: "_blank", rel: "noreferrer", className: index_module_default2.linkItem, children: [
|
|
4885
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: index_module_default2.linkIndex, children: [
|
|
4886
|
+
itemIndex + 1,
|
|
4887
|
+
"."
|
|
4888
|
+
] }),
|
|
4889
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.linkTitle, children: item.title })
|
|
4890
|
+
] }, `${item.url}-${itemIndex}`)) })
|
|
4891
|
+
] }, `links-${index}`);
|
|
4892
|
+
}
|
|
4893
|
+
const markdown = block.kind === "markdown" ? block.content : toMarkdown(block.content, "code", block.lang);
|
|
4894
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: index_module_default2.sectionBlock, children: [
|
|
4895
|
+
block.title && /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: index_module_default2.sectionLabel, children: block.title }),
|
|
4896
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { content: markdown }) })
|
|
4897
|
+
] }, `${block.kind}-${index}`);
|
|
4898
|
+
};
|
|
4899
|
+
var renderDisplayView = (view, fallbackLabel) => {
|
|
4900
|
+
if (!view) return null;
|
|
4901
|
+
const hasBody = view.blocks && view.blocks.length > 0 || view.meta && view.meta.length > 0 || view.summary;
|
|
4902
|
+
if (!hasBody) return null;
|
|
4903
|
+
const hasRichBody = !!(view.blocks && view.blocks.length > 0);
|
|
4904
|
+
const isOnlyLinksBlock = !view.summary && (!view.meta || view.meta.length === 0) && view.blocks?.length === 1 && view.blocks[0].kind === "links";
|
|
4905
|
+
const label = isOnlyLinksBlock ? void 0 : (hasRichBody ? view.title : void 0);
|
|
4906
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${index_module_default2.sectionBlock} ${!hasRichBody ? index_module_default2.compactSectionBlock : ""}`, children: [
|
|
4907
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: index_module_default2.sectionLabel, children: label }),
|
|
4908
|
+
view.summary && /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.summaryText, children: view.summary }),
|
|
4909
|
+
view.meta && view.meta.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.metaGrid, children: view.meta.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: index_module_default2.metaItem, children: [
|
|
4910
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.metaLabel, children: item.label }),
|
|
4911
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.metaValue, children: item.value })
|
|
4912
|
+
] }, `${item.label}-${index}`)) }),
|
|
4913
|
+
view.blocks?.map((block, index) => renderBlock(block, index))
|
|
4914
|
+
] });
|
|
4915
|
+
};
|
|
4916
|
+
var DefaultToolRender = ({ argsContent, resultContent, item }) => {
|
|
4917
|
+
const sd = item.streamingArgsDisplay;
|
|
4918
|
+
const isError = item.isError || item.status === "error";
|
|
4919
|
+
const hasStructuredDisplay = !!item.displayProtocol || !!sd?.content || !!item.argsDisplay || !!item.resultDisplay;
|
|
4920
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: isError ? index_module_default2.errorDisplay : "", children: [
|
|
4921
|
+
!item.argsDisplay && sd?.content && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${index_module_default2.sectionBlock} ${index_module_default2.compactSectionBlock}`, children: [
|
|
4922
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: index_module_default2.sectionLabel, children: sd.title || "\u8F93\u5165\u751F\u6210\u4E2D" }),
|
|
4923
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { content: toMarkdown(sd.content, sd.kind, sd.lang) }) })
|
|
4924
|
+
] }),
|
|
4925
|
+
renderDisplayView(item.argsDisplay),
|
|
4926
|
+
renderDisplayView(item.resultDisplay),
|
|
4927
|
+
!hasStructuredDisplay && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4928
|
+
(item.content || item.arguments) && argsContent && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: index_module_default2.sectionBlock, children: [
|
|
4929
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: index_module_default2.sectionLabel, children: "\u8F93\u5165\u53C2\u6570" }),
|
|
4930
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { content: argsContent.isJson ? `\`\`\`json
|
|
4684
4931
|
${argsContent.text}
|
|
4685
4932
|
\`\`\`` : argsContent.text }) })
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4933
|
+
] }),
|
|
4934
|
+
item.result && resultContent && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: index_module_default2.sectionBlock, children: [
|
|
4935
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: index_module_default2.sectionLabel, children: "\u8FD4\u56DE\u7ED3\u679C" }),
|
|
4936
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { content: resultContent.isJson ? `\`\`\`json
|
|
4690
4937
|
${resultContent.text}
|
|
4691
4938
|
\`\`\`` : resultContent.text }) })
|
|
4692
|
-
|
|
4693
|
-
errorMessage && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: index_module_default2.sectionBlock, children: [
|
|
4694
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: index_module_default2.sectionLabel, children: "\u9519\u8BEF\u4FE1\u606F" }),
|
|
4695
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { content: `\`\`\`
|
|
4696
|
-
${errorMessage}
|
|
4697
|
-
\`\`\`` }) })
|
|
4939
|
+
] })
|
|
4698
4940
|
] })
|
|
4699
4941
|
] });
|
|
4700
4942
|
};
|
|
@@ -4778,9 +5020,12 @@ var formatContent = (content) => {
|
|
|
4778
5020
|
return { text, isJson: false, parsed: null };
|
|
4779
5021
|
}
|
|
4780
5022
|
};
|
|
5023
|
+
var hasDisplayViewBody = (view) => {
|
|
5024
|
+
return !!(view?.summary || view?.blocks?.length || view?.meta?.length);
|
|
5025
|
+
};
|
|
4781
5026
|
var ToolCallItem = ({ item }) => {
|
|
4782
5027
|
const { token } = antd.theme.useToken();
|
|
4783
|
-
const renderConfig = getToolRenderConfig(item
|
|
5028
|
+
const renderConfig = getToolRenderConfig(item);
|
|
4784
5029
|
const CustomRender = renderConfig.component;
|
|
4785
5030
|
const status = React10.useMemo(() => {
|
|
4786
5031
|
if (item.status) return item.status;
|
|
@@ -4804,35 +5049,36 @@ var ToolCallItem = ({ item }) => {
|
|
|
4804
5049
|
alwaysShow = renderConfig.alwaysShowContent;
|
|
4805
5050
|
}
|
|
4806
5051
|
if (alwaysShow) return true;
|
|
4807
|
-
|
|
4808
|
-
|
|
5052
|
+
if (item.displayProtocol) {
|
|
5053
|
+
if (item.streamingArgsDisplay?.content) return true;
|
|
5054
|
+
if (hasDisplayViewBody(item.argsDisplay)) return true;
|
|
5055
|
+
if (hasDisplayViewBody(item.resultDisplay)) return true;
|
|
5056
|
+
return false;
|
|
5057
|
+
}
|
|
5058
|
+
if (argsContent.text) return true;
|
|
5059
|
+
if (resultContent?.text) return true;
|
|
5060
|
+
return false;
|
|
5061
|
+
}, [
|
|
5062
|
+
renderConfig.disableExpandOnError,
|
|
5063
|
+
renderConfig.alwaysShowContent,
|
|
5064
|
+
item.displayProtocol,
|
|
5065
|
+
item.streamingArgsDisplay,
|
|
5066
|
+
item.argsDisplay,
|
|
5067
|
+
item.resultDisplay,
|
|
5068
|
+
status,
|
|
5069
|
+
argsContent.parsed,
|
|
5070
|
+
resultContent?.parsed,
|
|
5071
|
+
argsContent.text,
|
|
5072
|
+
resultContent?.text
|
|
5073
|
+
]);
|
|
4809
5074
|
const isDefaultExpanded = React10.useMemo(() => {
|
|
4810
5075
|
if (typeof renderConfig.defaultExpanded === "function") {
|
|
4811
5076
|
return renderConfig.defaultExpanded(argsContent.parsed, resultContent?.parsed);
|
|
4812
5077
|
}
|
|
4813
5078
|
return renderConfig.defaultExpanded;
|
|
4814
5079
|
}, [renderConfig.defaultExpanded, argsContent.parsed, resultContent?.parsed]);
|
|
4815
|
-
const
|
|
4816
|
-
|
|
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
|
-
};
|
|
5080
|
+
const showLoading = status === "running" || status === "pending";
|
|
5081
|
+
const displayName = item.title || (showLoading ? "" : item.toolName || "Unknown Tool");
|
|
4836
5082
|
const renderIcon = () => {
|
|
4837
5083
|
if (!item.toolIcon) {
|
|
4838
5084
|
return /* @__PURE__ */ jsxRuntime.jsx(icons.ToolOutlined, { style: { fontSize: 14, color: token.colorTextSecondary } });
|
|
@@ -4846,13 +5092,19 @@ var ToolCallItem = ({ item }) => {
|
|
|
4846
5092
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4847
5093
|
antd.Collapse,
|
|
4848
5094
|
{
|
|
4849
|
-
|
|
5095
|
+
className: index_module_default2.toolCollapse,
|
|
5096
|
+
style: { width: "100%" },
|
|
4850
5097
|
collapsible: hasContent ? void 0 : "disabled",
|
|
4851
5098
|
defaultActiveKey: isDefaultExpanded && hasContent ? [item.toolCallId || "fallback-key"] : void 0,
|
|
4852
5099
|
expandIconPlacement: "end",
|
|
5100
|
+
expandIcon: ({ isActive }) => hasContent ? /* @__PURE__ */ jsxRuntime.jsx(icons.RightOutlined, { className: `${index_module_default2.expandIcon} ${isActive ? index_module_default2.expanded : ""}` }) : null,
|
|
4853
5101
|
styles: {
|
|
4854
5102
|
header: {
|
|
4855
|
-
padding: "
|
|
5103
|
+
padding: "4px 8px",
|
|
5104
|
+
overflow: "hidden"
|
|
5105
|
+
},
|
|
5106
|
+
body: {
|
|
5107
|
+
padding: "0 8px 8px"
|
|
4856
5108
|
}
|
|
4857
5109
|
},
|
|
4858
5110
|
items: [
|
|
@@ -4861,14 +5113,18 @@ var ToolCallItem = ({ item }) => {
|
|
|
4861
5113
|
showArrow: hasContent,
|
|
4862
5114
|
label: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", gap: 8, style: { flex: 1, minWidth: 0 }, children: [
|
|
4863
5115
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.iconContainer, children: renderIcon() }),
|
|
4864
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.toolName, children:
|
|
4865
|
-
|
|
5116
|
+
displayName ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.toolName, children: displayName }) : /* @__PURE__ */ jsxRuntime.jsxs("span", { className: index_module_default2.toolNamePending, children: [
|
|
5117
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.dot }),
|
|
5118
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.dot }),
|
|
5119
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.dot })
|
|
5120
|
+
] }),
|
|
5121
|
+
showLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.statusIcon, style: { color: token.colorPrimary }, children: /* @__PURE__ */ jsxRuntime.jsx(icons.LoadingOutlined, {}) }),
|
|
4866
5122
|
item.duration && /* @__PURE__ */ jsxRuntime.jsxs(antd.Typography.Text, { className: index_module_default2.duration, children: [
|
|
4867
5123
|
item.duration,
|
|
4868
5124
|
"ms"
|
|
4869
5125
|
] })
|
|
4870
5126
|
] }),
|
|
4871
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5127
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.contentScrollContainer, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4872
5128
|
CustomRender,
|
|
4873
5129
|
{
|
|
4874
5130
|
item,
|
|
@@ -4878,7 +5134,7 @@ var ToolCallItem = ({ item }) => {
|
|
|
4878
5134
|
resultContent,
|
|
4879
5135
|
errorMessage: item.errorMessage
|
|
4880
5136
|
}
|
|
4881
|
-
)
|
|
5137
|
+
) })
|
|
4882
5138
|
}
|
|
4883
5139
|
]
|
|
4884
5140
|
}
|
|
@@ -4892,9 +5148,6 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
|
|
|
4892
5148
|
if (!RENDERABLE_MESSAGE_TYPES.includes(item.type)) {
|
|
4893
5149
|
return false;
|
|
4894
5150
|
}
|
|
4895
|
-
if (item.type === "runStarted") {
|
|
4896
|
-
return !!loading;
|
|
4897
|
-
}
|
|
4898
5151
|
if (item.type === "plan") {
|
|
4899
5152
|
return !shouldHideA2uiPlan(item);
|
|
4900
5153
|
}
|
|
@@ -4904,7 +5157,7 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
|
|
|
4904
5157
|
}
|
|
4905
5158
|
return true;
|
|
4906
5159
|
});
|
|
4907
|
-
}, [
|
|
5160
|
+
}, [message3.content]);
|
|
4908
5161
|
const quoteMsg = React10.useMemo(() => {
|
|
4909
5162
|
const quoteMsg2 = {};
|
|
4910
5163
|
if (message3.params) {
|
|
@@ -4918,7 +5171,8 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
|
|
|
4918
5171
|
}
|
|
4919
5172
|
return common.isEmptyObj(quoteMsg2) ? null : quoteMsg2;
|
|
4920
5173
|
}, [message3.params, message3.quoteMsg]);
|
|
4921
|
-
|
|
5174
|
+
const showPending = loading && (content.length === 0 || content[content.length - 1].type !== "text");
|
|
5175
|
+
if (content.length === 0 && !showPending) return null;
|
|
4922
5176
|
const lastToolCallIndex = (() => {
|
|
4923
5177
|
let lastIdx = -1;
|
|
4924
5178
|
content.forEach((item, i) => {
|
|
@@ -4935,7 +5189,6 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
|
|
|
4935
5189
|
placement: role.placement,
|
|
4936
5190
|
variant: item.type === "files" ? "borderless" : void 0,
|
|
4937
5191
|
content: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4938
|
-
item.type === "runStarted" && /* @__PURE__ */ jsxRuntime.jsx(RunStartedNode, { loading }, `flow-start-${index}`),
|
|
4939
5192
|
(item.type === "toolCall" || item.type === "toolResult") && /* @__PURE__ */ jsxRuntime.jsx(tool_call_item_default, { item }, `tool-call-${item.toolCallId || index}`),
|
|
4940
5193
|
item.type === "text" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4941
5194
|
TextNode2,
|
|
@@ -4956,6 +5209,7 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
|
|
|
4956
5209
|
),
|
|
4957
5210
|
index === lastToolCallIndex && messageIndex >= 0 ? /* @__PURE__ */ jsxRuntime.jsx(A2uiMessageCards, { messageIndex, message: message3 }) : null
|
|
4958
5211
|
] }, `message-${index}`)),
|
|
5212
|
+
showPending && /* @__PURE__ */ jsxRuntime.jsx(xV2.Bubble, { role: role.user, placement: role.placement, content: /* @__PURE__ */ jsxRuntime.jsx(RunStartedNode, {}) }),
|
|
4959
5213
|
quoteMsg && /* @__PURE__ */ jsxRuntime.jsx(QuoteMsgNode, { quoteMsg, role })
|
|
4960
5214
|
] });
|
|
4961
5215
|
});
|
|
@@ -5255,7 +5509,7 @@ var ResourceSelectorModal_default = ({ open, type, onCancel }) => {
|
|
|
5255
5509
|
setCategories([{ id: ALL_CATEGORY_ID, name: "\u5168\u90E8" }, ...tagsRes.data || []]);
|
|
5256
5510
|
setResources(fetchedResources);
|
|
5257
5511
|
const spec = conversationState.active.spec;
|
|
5258
|
-
const initialItems = isSkill ? spec?.skills?.items : spec?.
|
|
5512
|
+
const initialItems = isSkill ? spec?.skills?.items : spec?.knowledges?.items;
|
|
5259
5513
|
const validIds = new Set(fetchedResources.map((r) => r.id));
|
|
5260
5514
|
const validSelectedIds = (initialItems || []).map((item) => item.id).filter((id) => validIds.has(id));
|
|
5261
5515
|
setSelectedIds(validSelectedIds);
|
|
@@ -5302,7 +5556,7 @@ var ResourceSelectorModal_default = ({ open, type, onCancel }) => {
|
|
|
5302
5556
|
items: ids.map((id) => ({ id }))
|
|
5303
5557
|
};
|
|
5304
5558
|
} else {
|
|
5305
|
-
nextSpec.
|
|
5559
|
+
nextSpec.knowledges = {
|
|
5306
5560
|
items: ids.map((id) => {
|
|
5307
5561
|
const resource = resourceList.find((r) => r.id === id);
|
|
5308
5562
|
return { id, name: resource?.name || "" };
|
|
@@ -5449,7 +5703,7 @@ var KnowledgeBtn_default = ({}) => {
|
|
|
5449
5703
|
const chatStore = useChatStore();
|
|
5450
5704
|
const conversationState = valtio.useSnapshot(chatStore.conversation);
|
|
5451
5705
|
const [modalOpen, setModalOpen] = React10.useState(false);
|
|
5452
|
-
const knowledgeCount = conversationState.active.spec?.
|
|
5706
|
+
const knowledgeCount = conversationState.active.spec?.knowledges?.items?.length ?? 0;
|
|
5453
5707
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5454
5708
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: style_module_default.resourceBtn, onClick: () => setModalOpen(true), children: [
|
|
5455
5709
|
/* @__PURE__ */ jsxRuntime.jsx(IconFont_default, { type: "icon-remark" }),
|