@zero-library/chat-copilot 3.1.9 → 3.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +410 -302
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +152 -32
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +32 -1
- package/dist/index.d.ts +32 -1
- package/dist/index.esm.js +413 -305
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -1356,7 +1356,7 @@ function createChatStore() {
|
|
|
1356
1356
|
};
|
|
1357
1357
|
const setConversationSpec = (spec) => {
|
|
1358
1358
|
if (common.isObject(spec)) {
|
|
1359
|
-
Object.assign(conversation.active.spec, spec);
|
|
1359
|
+
Object.assign(conversation.active.spec || {}, spec);
|
|
1360
1360
|
}
|
|
1361
1361
|
};
|
|
1362
1362
|
const setConversationUserInput = (userInput) => {
|
|
@@ -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,52 +1546,60 @@ 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) {
|
|
1580
|
+
const idx = findExecutionMsgIndex(msg, messages);
|
|
1581
|
+
const contentItem = msg.content[0];
|
|
1581
1582
|
messages.forEach((item) => {
|
|
1582
1583
|
if (item.executionId === msg.executionId) {
|
|
1583
1584
|
item.generating = false;
|
|
1584
1585
|
}
|
|
1585
1586
|
});
|
|
1587
|
+
if (contentItem?.type === "runFailed") {
|
|
1588
|
+
if (idx !== -1) {
|
|
1589
|
+
const prevContent = messages[idx]?.content || [];
|
|
1590
|
+
messages[idx].content = [...prevContent, contentItem];
|
|
1591
|
+
} else {
|
|
1592
|
+
const finalMsg = { ...msg, generating: false };
|
|
1593
|
+
messages.push(finalMsg);
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1586
1596
|
}
|
|
1587
|
-
config.hooks?.onAfterAcceptMessage?.(msg);
|
|
1597
|
+
if (isMain) config.hooks?.onAfterAcceptMessage?.(msg);
|
|
1588
1598
|
}
|
|
1589
|
-
function titleCallback(msg) {
|
|
1599
|
+
function titleCallback(msg, _messages, isMain) {
|
|
1590
1600
|
const content = msg.content[0];
|
|
1591
1601
|
if (content.type !== "conversationNewTitle") return;
|
|
1602
|
+
if (!isMain) return;
|
|
1592
1603
|
const title = content.title || "";
|
|
1593
1604
|
const conversationId = msg.conversationId || "";
|
|
1594
1605
|
if (content && conversations.list.items.length) {
|
|
@@ -1597,9 +1608,7 @@ function createChatStore() {
|
|
|
1597
1608
|
conversations.list.items[idx].label = title;
|
|
1598
1609
|
}
|
|
1599
1610
|
}
|
|
1600
|
-
function toolCallCallback(msg) {
|
|
1601
|
-
const messages = conversation.messages[msg.conversationId]?.message;
|
|
1602
|
-
if (!messages) return;
|
|
1611
|
+
function toolCallCallback(msg, messages, isMain) {
|
|
1603
1612
|
let idx = -1;
|
|
1604
1613
|
const contentItem = msg.content[0];
|
|
1605
1614
|
if (contentItem.type !== "toolCall") return;
|
|
@@ -1635,16 +1644,20 @@ function createChatStore() {
|
|
|
1635
1644
|
if (contentItem.status) {
|
|
1636
1645
|
nextItem.status = contentItem.status;
|
|
1637
1646
|
}
|
|
1647
|
+
if (contentItem.toolIcon) {
|
|
1648
|
+
nextItem.toolIcon = contentItem.toolIcon;
|
|
1649
|
+
}
|
|
1650
|
+
if (contentItem.display) {
|
|
1651
|
+
nextItem.display = (existingItem.display || "") + contentItem.display;
|
|
1652
|
+
}
|
|
1638
1653
|
messages[idx].content = contents.map((item, i) => i === existingItemIndex ? nextItem : item);
|
|
1639
1654
|
} else {
|
|
1640
1655
|
messages[idx].content = [...contents, contentItem];
|
|
1641
1656
|
}
|
|
1642
1657
|
}
|
|
1643
|
-
conversation.messages[msg.conversationId].loading = true;
|
|
1658
|
+
if (isMain) conversation.messages[msg.conversationId].loading = true;
|
|
1644
1659
|
}
|
|
1645
|
-
function toolResultCallback(msg) {
|
|
1646
|
-
const messages = conversation.messages[msg.conversationId]?.message;
|
|
1647
|
-
if (!messages) return;
|
|
1660
|
+
function toolResultCallback(msg, messages, isMain) {
|
|
1648
1661
|
const contentItem = msg.content[0];
|
|
1649
1662
|
if (contentItem.type !== "toolResult") return;
|
|
1650
1663
|
let idx = -1;
|
|
@@ -1675,15 +1688,16 @@ function createChatStore() {
|
|
|
1675
1688
|
if (contentItem.title) {
|
|
1676
1689
|
nextToolCallItem.title = contentItem.title;
|
|
1677
1690
|
}
|
|
1691
|
+
if (contentItem.display !== void 0) {
|
|
1692
|
+
nextToolCallItem.display = contentItem.display;
|
|
1693
|
+
}
|
|
1678
1694
|
messages[idx].content = contents.map((item, i) => i === toolCallIndex ? nextToolCallItem : item);
|
|
1679
1695
|
} else {
|
|
1680
1696
|
messages[idx].content = [...contents, contentItem];
|
|
1681
1697
|
}
|
|
1682
|
-
conversation.messages[msg.conversationId].loading = true;
|
|
1698
|
+
if (isMain) conversation.messages[msg.conversationId].loading = true;
|
|
1683
1699
|
}
|
|
1684
|
-
function a2uiCommandCallback(msg) {
|
|
1685
|
-
const messages = conversation.messages[msg.conversationId]?.message;
|
|
1686
|
-
if (!messages) return;
|
|
1700
|
+
function a2uiCommandCallback(msg, messages, isMain) {
|
|
1687
1701
|
const idx = findExecutionMsgIndex(msg, messages);
|
|
1688
1702
|
const contentItem = msg.content[0];
|
|
1689
1703
|
if (contentItem.type !== "a2uiCommand") return;
|
|
@@ -1694,45 +1708,147 @@ function createChatStore() {
|
|
|
1694
1708
|
const prevContent = messages[idx]?.content || [];
|
|
1695
1709
|
messages[idx].content = [...prevContent, contentItem];
|
|
1696
1710
|
}
|
|
1697
|
-
conversation.messages[msg.conversationId].loading = true;
|
|
1711
|
+
if (isMain) conversation.messages[msg.conversationId].loading = true;
|
|
1712
|
+
}
|
|
1713
|
+
function toolCallDeltaCallback(msg, messages, isMain) {
|
|
1714
|
+
const contentItem = msg.content[0];
|
|
1715
|
+
if (contentItem.type !== "toolCallDelta") return;
|
|
1716
|
+
let idx = -1;
|
|
1717
|
+
if (contentItem.toolCallId) {
|
|
1718
|
+
idx = messages.findLastIndex(
|
|
1719
|
+
(m) => m.content?.some((c) => (c.type === "toolCall" || c.type === "toolCallDelta") && c.toolCallId === contentItem.toolCallId)
|
|
1720
|
+
);
|
|
1721
|
+
}
|
|
1722
|
+
if (idx === -1) idx = findExecutionMsgIndex(msg, messages);
|
|
1723
|
+
if (idx === -1) {
|
|
1724
|
+
messages.push({
|
|
1725
|
+
...msg,
|
|
1726
|
+
content: [
|
|
1727
|
+
{
|
|
1728
|
+
type: "toolCall",
|
|
1729
|
+
toolCallId: contentItem.toolCallId,
|
|
1730
|
+
toolName: contentItem.toolName || void 0,
|
|
1731
|
+
toolIcon: contentItem.toolIcon,
|
|
1732
|
+
title: contentItem.title,
|
|
1733
|
+
content: contentItem.argumentsDelta || "",
|
|
1734
|
+
display: contentItem.display,
|
|
1735
|
+
status: contentItem.status || "running"
|
|
1736
|
+
}
|
|
1737
|
+
],
|
|
1738
|
+
generating: true
|
|
1739
|
+
});
|
|
1740
|
+
} else {
|
|
1741
|
+
const contents = messages[idx].content;
|
|
1742
|
+
const itemIdx = contents.findIndex(
|
|
1743
|
+
(c) => (c.type === "toolCall" || c.type === "toolCallDelta") && c.toolCallId === contentItem.toolCallId
|
|
1744
|
+
);
|
|
1745
|
+
if (itemIdx !== -1) {
|
|
1746
|
+
const existing = contents[itemIdx];
|
|
1747
|
+
const nextItem = {
|
|
1748
|
+
...existing,
|
|
1749
|
+
type: "toolCall",
|
|
1750
|
+
content: (existing.content || "") + (contentItem.argumentsDelta || "")
|
|
1751
|
+
};
|
|
1752
|
+
if (contentItem.toolName) nextItem.toolName = contentItem.toolName;
|
|
1753
|
+
if (contentItem.title) nextItem.title = contentItem.title;
|
|
1754
|
+
if (contentItem.status) nextItem.status = contentItem.status;
|
|
1755
|
+
if (contentItem.toolIcon) nextItem.toolIcon = contentItem.toolIcon;
|
|
1756
|
+
if (contentItem.display) nextItem.display = (existing.display || "") + contentItem.display;
|
|
1757
|
+
messages[idx].content = contents.map((c, i) => i === itemIdx ? nextItem : c);
|
|
1758
|
+
} else {
|
|
1759
|
+
messages[idx].content = [
|
|
1760
|
+
...contents,
|
|
1761
|
+
{
|
|
1762
|
+
type: "toolCall",
|
|
1763
|
+
toolCallId: contentItem.toolCallId,
|
|
1764
|
+
toolName: contentItem.toolName || void 0,
|
|
1765
|
+
toolIcon: contentItem.toolIcon,
|
|
1766
|
+
title: contentItem.title,
|
|
1767
|
+
content: contentItem.argumentsDelta || "",
|
|
1768
|
+
display: contentItem.display,
|
|
1769
|
+
status: contentItem.status || "running"
|
|
1770
|
+
}
|
|
1771
|
+
];
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
if (isMain) conversation.messages[msg.conversationId].loading = true;
|
|
1775
|
+
}
|
|
1776
|
+
function findToolCallItemRecursive(messages, toolCallId) {
|
|
1777
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
1778
|
+
const msg = messages[i];
|
|
1779
|
+
const contents = msg.content || [];
|
|
1780
|
+
const itemIdx = contents.findIndex((c) => c.type === "toolCall" && c.toolCallId === toolCallId);
|
|
1781
|
+
if (itemIdx !== -1) {
|
|
1782
|
+
return { messageList: msg, itemIndex: itemIdx };
|
|
1783
|
+
}
|
|
1784
|
+
for (const content of contents) {
|
|
1785
|
+
if (content.type === "toolCall") {
|
|
1786
|
+
const subMessages = content.subMessages;
|
|
1787
|
+
if (subMessages?.length) {
|
|
1788
|
+
const found = findToolCallItemRecursive(subMessages, toolCallId);
|
|
1789
|
+
if (found) return found;
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
return null;
|
|
1795
|
+
}
|
|
1796
|
+
function routeSubAgentMessage(msg) {
|
|
1797
|
+
const conversationId = msg.conversationId;
|
|
1798
|
+
const mainMessages = conversation.messages[conversationId]?.message;
|
|
1799
|
+
if (!mainMessages) return;
|
|
1800
|
+
const found = findToolCallItemRecursive(mainMessages, msg.toolCallId);
|
|
1801
|
+
if (!found) {
|
|
1802
|
+
return;
|
|
1803
|
+
}
|
|
1804
|
+
const { messageList, itemIndex } = found;
|
|
1805
|
+
const contents = messageList.content;
|
|
1806
|
+
const toolCallItem = contents[itemIndex];
|
|
1807
|
+
toolCallItem.hasSubAgent = true;
|
|
1808
|
+
if (!toolCallItem.subMessages) {
|
|
1809
|
+
toolCallItem.subMessages = [];
|
|
1810
|
+
}
|
|
1811
|
+
processMessageContent(msg, toolCallItem.subMessages);
|
|
1812
|
+
messageList.content = contents.map((c, i) => i === itemIndex ? { ...toolCallItem } : c);
|
|
1698
1813
|
}
|
|
1699
|
-
function processSingleMessageContent(newMessage) {
|
|
1814
|
+
function processSingleMessageContent(newMessage, messages, isMain) {
|
|
1700
1815
|
switch (newMessage.content[0].type) {
|
|
1701
1816
|
case "runStarted":
|
|
1702
|
-
startCallback(newMessage);
|
|
1817
|
+
startCallback(newMessage, messages, isMain);
|
|
1703
1818
|
break;
|
|
1704
1819
|
case "text":
|
|
1705
|
-
textCallback(newMessage);
|
|
1820
|
+
textCallback(newMessage, messages, isMain);
|
|
1706
1821
|
break;
|
|
1707
1822
|
case "stepStarted":
|
|
1708
|
-
stepStartedCallback(newMessage);
|
|
1823
|
+
stepStartedCallback(newMessage, messages, isMain);
|
|
1709
1824
|
break;
|
|
1710
1825
|
case "stepFinished":
|
|
1711
|
-
stepFinishedCallback(newMessage);
|
|
1826
|
+
stepFinishedCallback(newMessage, messages, isMain);
|
|
1712
1827
|
break;
|
|
1713
1828
|
case "stepError":
|
|
1714
|
-
stepErrCallback(newMessage);
|
|
1829
|
+
stepErrCallback(newMessage, messages, isMain);
|
|
1715
1830
|
break;
|
|
1716
1831
|
case "runFinished":
|
|
1717
1832
|
case "runFailed":
|
|
1718
1833
|
case "runStopped":
|
|
1719
|
-
doneCallback(newMessage);
|
|
1834
|
+
doneCallback(newMessage, messages, isMain);
|
|
1720
1835
|
break;
|
|
1721
1836
|
case "conversationNewTitle":
|
|
1722
|
-
titleCallback(newMessage);
|
|
1837
|
+
titleCallback(newMessage, messages, isMain);
|
|
1723
1838
|
break;
|
|
1724
1839
|
case "toolCall":
|
|
1725
|
-
toolCallCallback(newMessage);
|
|
1840
|
+
toolCallCallback(newMessage, messages, isMain);
|
|
1841
|
+
break;
|
|
1842
|
+
case "toolCallDelta":
|
|
1843
|
+
toolCallDeltaCallback(newMessage, messages, isMain);
|
|
1726
1844
|
break;
|
|
1727
1845
|
case "toolResult":
|
|
1728
|
-
toolResultCallback(newMessage);
|
|
1846
|
+
toolResultCallback(newMessage, messages, isMain);
|
|
1729
1847
|
break;
|
|
1730
1848
|
case "a2uiCommand":
|
|
1731
|
-
a2uiCommandCallback(newMessage);
|
|
1849
|
+
a2uiCommandCallback(newMessage, messages, isMain);
|
|
1732
1850
|
break;
|
|
1733
1851
|
default: {
|
|
1734
|
-
const messages = conversation.messages[newMessage.conversationId]?.message;
|
|
1735
|
-
if (!messages) return;
|
|
1736
1852
|
const idx = findExecutionMsgIndex(newMessage, messages);
|
|
1737
1853
|
if (idx === -1) {
|
|
1738
1854
|
const finalMsg = { ...newMessage, generating: true };
|
|
@@ -1741,20 +1857,21 @@ function createChatStore() {
|
|
|
1741
1857
|
const prevContent = messages[idx]?.content || [];
|
|
1742
1858
|
messages[idx].content = [...prevContent, ...newMessage.content];
|
|
1743
1859
|
}
|
|
1744
|
-
conversation.messages[newMessage.conversationId].loading = true;
|
|
1860
|
+
if (isMain) conversation.messages[newMessage.conversationId].loading = true;
|
|
1745
1861
|
break;
|
|
1746
1862
|
}
|
|
1747
1863
|
}
|
|
1748
1864
|
}
|
|
1749
|
-
function processMessageContent(message3) {
|
|
1865
|
+
function processMessageContent(message3, targetMessages) {
|
|
1750
1866
|
const newMessage = {
|
|
1751
1867
|
...message3,
|
|
1752
1868
|
agentId: agent.agentInfo.id
|
|
1753
1869
|
};
|
|
1870
|
+
const isMain = !targetMessages;
|
|
1871
|
+
const messages = targetMessages ?? conversation.messages[newMessage.conversationId]?.message;
|
|
1872
|
+
if (!messages) return;
|
|
1754
1873
|
const contentList = Array.isArray(newMessage.content) ? newMessage.content : [];
|
|
1755
1874
|
if (contentList.length === 0) {
|
|
1756
|
-
const messages = conversation.messages[newMessage.conversationId]?.message;
|
|
1757
|
-
if (!messages) return;
|
|
1758
1875
|
const idx = findExecutionMsgIndex(newMessage, messages);
|
|
1759
1876
|
if (idx === -1) {
|
|
1760
1877
|
messages.push({ ...newMessage });
|
|
@@ -1770,17 +1887,32 @@ function createChatStore() {
|
|
|
1770
1887
|
return;
|
|
1771
1888
|
}
|
|
1772
1889
|
contentList.forEach((contentItem) => {
|
|
1773
|
-
processSingleMessageContent(
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1890
|
+
processSingleMessageContent(
|
|
1891
|
+
{
|
|
1892
|
+
...newMessage,
|
|
1893
|
+
content: [contentItem]
|
|
1894
|
+
},
|
|
1895
|
+
messages,
|
|
1896
|
+
isMain
|
|
1897
|
+
);
|
|
1777
1898
|
});
|
|
1778
|
-
normalizeMessagesByExecutionAndRole(
|
|
1899
|
+
normalizeMessagesByExecutionAndRole(messages);
|
|
1779
1900
|
}
|
|
1780
1901
|
function isStoppedIncomingMessage(newMessage) {
|
|
1781
1902
|
const messages = conversation.messages[newMessage.conversationId]?.message;
|
|
1782
1903
|
if (!messages) return false;
|
|
1783
|
-
|
|
1904
|
+
if (messages.some((item) => item.stopFlag && item.executionId === newMessage.executionId)) {
|
|
1905
|
+
return true;
|
|
1906
|
+
}
|
|
1907
|
+
return messages.some(
|
|
1908
|
+
(msg) => msg.content?.some((c) => {
|
|
1909
|
+
if (c.type === "toolCall") {
|
|
1910
|
+
const subMessages = c.subMessages;
|
|
1911
|
+
return subMessages?.some((sub) => sub.stopFlag && sub.executionId === newMessage.executionId);
|
|
1912
|
+
}
|
|
1913
|
+
return false;
|
|
1914
|
+
})
|
|
1915
|
+
);
|
|
1784
1916
|
}
|
|
1785
1917
|
const acceptMessage = async (newMessage) => {
|
|
1786
1918
|
const conversationId = newMessage.conversationId;
|
|
@@ -1790,6 +1922,10 @@ function createChatStore() {
|
|
|
1790
1922
|
if (canProceed === false) {
|
|
1791
1923
|
throw new Error("\u64CD\u4F5C\u88AB\u963B\u6B62");
|
|
1792
1924
|
}
|
|
1925
|
+
if (newMessage.toolCallId) {
|
|
1926
|
+
routeSubAgentMessage(newMessage);
|
|
1927
|
+
return;
|
|
1928
|
+
}
|
|
1793
1929
|
if (isStoppedIncomingMessage(newMessage)) {
|
|
1794
1930
|
conversation.messages[conversationId].loading = false;
|
|
1795
1931
|
return;
|
|
@@ -1871,19 +2007,25 @@ function createChatStore() {
|
|
|
1871
2007
|
const lastMsg = messages[messages.length - 1];
|
|
1872
2008
|
if (lastMsg.executionId) {
|
|
1873
2009
|
await config.services.request.cancelMessage(lastMsg.executionId);
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
item.
|
|
1877
|
-
|
|
2010
|
+
const markStopped = (msgList, matchExecutionId) => {
|
|
2011
|
+
msgList.forEach((item) => {
|
|
2012
|
+
if (item.executionId === lastMsg.executionId) {
|
|
2013
|
+
item.generating = false;
|
|
2014
|
+
item.stopFlag = true;
|
|
2015
|
+
}
|
|
1878
2016
|
if (item.content && Array.isArray(item.content)) {
|
|
1879
2017
|
item.content.forEach((contentItem) => {
|
|
1880
2018
|
if (contentItem.type === "toolCall" && contentItem.status !== "success" && contentItem.status !== "error") {
|
|
1881
2019
|
contentItem.status = "error";
|
|
1882
2020
|
}
|
|
2021
|
+
if (contentItem.subMessages?.length) {
|
|
2022
|
+
markStopped(contentItem.subMessages);
|
|
2023
|
+
}
|
|
1883
2024
|
});
|
|
1884
2025
|
}
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
2026
|
+
});
|
|
2027
|
+
};
|
|
2028
|
+
markStopped(messages);
|
|
1887
2029
|
} else {
|
|
1888
2030
|
lastMsg.stopFlag = true;
|
|
1889
2031
|
lastMsg.generating = false;
|
|
@@ -2620,6 +2762,7 @@ var AgentNavigate_default = React10.memo(({ data }) => {
|
|
|
2620
2762
|
}, [data]);
|
|
2621
2763
|
const handleClick = () => {
|
|
2622
2764
|
if (!content?.emit) return;
|
|
2765
|
+
common.emit(content.emit, { ...content.data, name: "luya-web-drawer" }, "nearest");
|
|
2623
2766
|
};
|
|
2624
2767
|
return /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: handleClick, style: { padding: 0 }, type: "link", children: content?.name || "\u70B9\u51FB\u6B64\u5904" });
|
|
2625
2768
|
});
|
|
@@ -2830,9 +2973,7 @@ var MdEdit_default = ({ data, loading }) => {
|
|
|
2830
2973
|
};
|
|
2831
2974
|
var PreviewLink_default = ({ data, loading, message: message3, ...rest }) => {
|
|
2832
2975
|
const chatStore = useChatStore();
|
|
2833
|
-
const getLinkFileName = (
|
|
2834
|
-
const url = new URL(href, window.location.origin);
|
|
2835
|
-
const path = url.searchParams.get("path") || url.pathname;
|
|
2976
|
+
const getLinkFileName = (path) => {
|
|
2836
2977
|
const lastSegment = path.split("/").pop();
|
|
2837
2978
|
if (!lastSegment) {
|
|
2838
2979
|
return "link";
|
|
@@ -2843,24 +2984,12 @@ var PreviewLink_default = ({ data, loading, message: message3, ...rest }) => {
|
|
|
2843
2984
|
return lastSegment;
|
|
2844
2985
|
}
|
|
2845
2986
|
};
|
|
2846
|
-
const
|
|
2847
|
-
|
|
2848
|
-
};
|
|
2849
|
-
const handlePreviewLink = (href) => {
|
|
2850
|
-
const fileName = getLinkFileName(href);
|
|
2851
|
-
const suffix = common.getFileSuffixName(fileName);
|
|
2852
|
-
chatStore.setPreview({
|
|
2853
|
-
fileUrl: getPreviewFileUrl(href),
|
|
2854
|
-
fileName,
|
|
2855
|
-
suffix
|
|
2856
|
-
});
|
|
2857
|
-
};
|
|
2858
|
-
const handlePathToUrl = (href) => {
|
|
2859
|
-
const fileName = getLinkFileName(href);
|
|
2987
|
+
const handlePreviewByPath = (path) => {
|
|
2988
|
+
const fileName = getLinkFileName(path);
|
|
2860
2989
|
const suffix = common.getFileSuffixName(fileName);
|
|
2861
2990
|
chatStore.setPreview({
|
|
2862
2991
|
fileUrl: chatStore.config.services.request.getPreviewUrl({
|
|
2863
|
-
path
|
|
2992
|
+
path,
|
|
2864
2993
|
workspaceId: message3.conversationId
|
|
2865
2994
|
}),
|
|
2866
2995
|
fileName,
|
|
@@ -2874,12 +3003,18 @@ var PreviewLink_default = ({ data, loading, message: message3, ...rest }) => {
|
|
|
2874
3003
|
return;
|
|
2875
3004
|
}
|
|
2876
3005
|
e.preventDefault();
|
|
2877
|
-
if (String(rest.href).startsWith("/luya")) {
|
|
2878
|
-
|
|
3006
|
+
if (String(rest.href).startsWith("/luya") || String(rest.href).startsWith("/agents")) {
|
|
3007
|
+
const url = new URL(href, window.location.origin);
|
|
3008
|
+
const path = url.searchParams.get("path");
|
|
3009
|
+
if (!path) {
|
|
3010
|
+
window.open(href, "_blank");
|
|
3011
|
+
return;
|
|
3012
|
+
}
|
|
3013
|
+
handlePreviewByPath(path);
|
|
2879
3014
|
return;
|
|
2880
3015
|
}
|
|
2881
3016
|
if (String(rest.href).startsWith("/workspace")) {
|
|
2882
|
-
|
|
3017
|
+
handlePreviewByPath(href);
|
|
2883
3018
|
return;
|
|
2884
3019
|
}
|
|
2885
3020
|
window.open(href, "_blank");
|
|
@@ -3388,11 +3523,8 @@ var A2uiComponents = {
|
|
|
3388
3523
|
|
|
3389
3524
|
// src/components/CustomComponents/A2uiRuntime/controller/extract.ts
|
|
3390
3525
|
var A2UI_TAG_REGEX = /<A2UI\s+id="([^"]*)"\s*>([\s\S]*?)<\/A2UI>/g;
|
|
3391
|
-
function hasA2uiTag(text) {
|
|
3392
|
-
return typeof text === "string" && text.includes("<A2UI");
|
|
3393
|
-
}
|
|
3394
3526
|
function parseA2uiTagsFromText(text) {
|
|
3395
|
-
if (!
|
|
3527
|
+
if (typeof text !== "string" || !text.includes("<A2UI")) return [];
|
|
3396
3528
|
const tags = [];
|
|
3397
3529
|
const regex = new RegExp(A2UI_TAG_REGEX);
|
|
3398
3530
|
let match;
|
|
@@ -3410,61 +3542,17 @@ function parseA2uiTagsFromText(text) {
|
|
|
3410
3542
|
return tags;
|
|
3411
3543
|
}
|
|
3412
3544
|
function stripA2uiTags(text) {
|
|
3413
|
-
if (!
|
|
3414
|
-
|
|
3415
|
-
result = result.replace(/<A2UI\b[\s\S]*$/, "");
|
|
3416
|
-
return result.trim();
|
|
3417
|
-
}
|
|
3418
|
-
function splitA2uiTextSegments(text) {
|
|
3419
|
-
if (typeof text !== "string" || !text.includes("<A2UI")) {
|
|
3420
|
-
return text ? [{ type: "text", content: text }] : [];
|
|
3421
|
-
}
|
|
3422
|
-
const segments = [];
|
|
3423
|
-
const regex = new RegExp(A2UI_TAG_REGEX);
|
|
3424
|
-
let lastIndex = 0;
|
|
3425
|
-
let match;
|
|
3426
|
-
while ((match = regex.exec(text)) !== null) {
|
|
3427
|
-
if (match.index > lastIndex) {
|
|
3428
|
-
const before = text.slice(lastIndex, match.index);
|
|
3429
|
-
if (before) segments.push({ type: "text", content: before });
|
|
3430
|
-
}
|
|
3431
|
-
const json = match[2].trim();
|
|
3432
|
-
if (json) {
|
|
3433
|
-
try {
|
|
3434
|
-
const parsed = JSON.parse(json);
|
|
3435
|
-
const commands = Array.isArray(parsed) ? parsed : [parsed];
|
|
3436
|
-
const surfaceIds = commands.map((cmd) => String(cmd?.createSurface?.surfaceId || "").trim()).filter(Boolean);
|
|
3437
|
-
if (surfaceIds.length) {
|
|
3438
|
-
segments.push({ type: "a2ui", surfaceIds });
|
|
3439
|
-
}
|
|
3440
|
-
} catch {
|
|
3441
|
-
}
|
|
3442
|
-
}
|
|
3443
|
-
lastIndex = regex.lastIndex;
|
|
3444
|
-
}
|
|
3445
|
-
if (lastIndex < text.length) {
|
|
3446
|
-
let remaining = text.slice(lastIndex);
|
|
3447
|
-
remaining = remaining.replace(/<A2UI\b[\s\S]*$/, "");
|
|
3448
|
-
if (remaining) segments.push({ type: "text", content: remaining });
|
|
3449
|
-
}
|
|
3450
|
-
return segments.length ? segments : [];
|
|
3545
|
+
if (typeof text !== "string" || !text.includes("<A2UI")) return text;
|
|
3546
|
+
return text.replace(A2UI_TAG_REGEX, "").trim();
|
|
3451
3547
|
}
|
|
3452
|
-
function
|
|
3453
|
-
|
|
3454
|
-
const
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
if (typeof text !== "string" || !text.includes("<A2UI")) continue;
|
|
3459
|
-
const tags = parseA2uiTagsFromText(text);
|
|
3460
|
-
for (const tag of tags) {
|
|
3461
|
-
for (const cmd of tag.commands) {
|
|
3462
|
-
const sid = String(cmd?.createSurface?.surfaceId || "").trim();
|
|
3463
|
-
if (sid) surfaceIds.add(sid);
|
|
3464
|
-
}
|
|
3465
|
-
}
|
|
3548
|
+
function extractItemTextForA2ui(item) {
|
|
3549
|
+
if (!item || item.type !== "toolCall") return "";
|
|
3550
|
+
const result = item.result;
|
|
3551
|
+
if (typeof result === "string") return result;
|
|
3552
|
+
if (result && typeof result === "object" && typeof result.stdout === "string") {
|
|
3553
|
+
return result.stdout;
|
|
3466
3554
|
}
|
|
3467
|
-
return
|
|
3555
|
+
return "";
|
|
3468
3556
|
}
|
|
3469
3557
|
function extractDismissedSurfaceIdsFromMessages(messages) {
|
|
3470
3558
|
const lastCreateIndexBySurface = /* @__PURE__ */ new Map();
|
|
@@ -3478,15 +3566,13 @@ function extractDismissedSurfaceIdsFromMessages(messages) {
|
|
|
3478
3566
|
const surfaceId = String(item.command?.createSurface?.surfaceId || "").trim();
|
|
3479
3567
|
if (surfaceId) lastCreateIndexBySurface.set(surfaceId, messageIndex);
|
|
3480
3568
|
}
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
for (const
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
if (surfaceId) lastCreateIndexBySurface.set(surfaceId, messageIndex);
|
|
3489
|
-
}
|
|
3569
|
+
const text = extractItemTextForA2ui(item);
|
|
3570
|
+
if (typeof text === "string" && text.includes("<A2UI")) {
|
|
3571
|
+
const tags = parseA2uiTagsFromText(text);
|
|
3572
|
+
for (const tag of tags) {
|
|
3573
|
+
for (const cmd of tag.commands) {
|
|
3574
|
+
const surfaceId = String(cmd?.createSurface?.surfaceId || "").trim();
|
|
3575
|
+
if (surfaceId) lastCreateIndexBySurface.set(surfaceId, messageIndex);
|
|
3490
3576
|
}
|
|
3491
3577
|
}
|
|
3492
3578
|
}
|
|
@@ -4013,28 +4099,6 @@ function sanitizeA2uiCommands(commands) {
|
|
|
4013
4099
|
return rest;
|
|
4014
4100
|
});
|
|
4015
4101
|
}
|
|
4016
|
-
function diffConversationMessages(messages, prevCursors) {
|
|
4017
|
-
if (messages.length < prevCursors.length) {
|
|
4018
|
-
return { shouldReplayAll: true, nextCursors: [], pendingItems: [] };
|
|
4019
|
-
}
|
|
4020
|
-
const nextCursors = [];
|
|
4021
|
-
const pendingItems = [];
|
|
4022
|
-
for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
|
|
4023
|
-
const message3 = messages[messageIndex];
|
|
4024
|
-
const messageId = String(message3?.messageId ?? messageIndex);
|
|
4025
|
-
const items = Array.isArray(message3?.content) ? message3.content : [];
|
|
4026
|
-
const prevCursor = prevCursors[messageIndex];
|
|
4027
|
-
const startIndex = prevCursor ? prevCursor.contentLength : 0;
|
|
4028
|
-
if (prevCursor && (prevCursor.messageId !== messageId || items.length < prevCursor.contentLength)) {
|
|
4029
|
-
return { shouldReplayAll: true, nextCursors: [], pendingItems: [] };
|
|
4030
|
-
}
|
|
4031
|
-
for (let itemIndex = startIndex; itemIndex < items.length; itemIndex += 1) {
|
|
4032
|
-
pendingItems.push({ messageIndex, messageId, item: items[itemIndex] });
|
|
4033
|
-
}
|
|
4034
|
-
nextCursors.push({ messageId, contentLength: items.length });
|
|
4035
|
-
}
|
|
4036
|
-
return { shouldReplayAll: false, nextCursors, pendingItems };
|
|
4037
|
-
}
|
|
4038
4102
|
function initializeWizardSurface(state, surfaceId, effects, nextWizardSteps) {
|
|
4039
4103
|
const wizard = state.wizardSchemaBySurface[surfaceId];
|
|
4040
4104
|
const createCommandIndex = state.latestCreateCommandIndexBySurface[surfaceId];
|
|
@@ -4054,6 +4118,10 @@ function initializeWizardSurface(state, surfaceId, effects, nextWizardSteps) {
|
|
|
4054
4118
|
function processA2uiCommand(cmd, messageIndex, messageId, nextState, effects, deletedSurfaceIds, nextWizardSteps) {
|
|
4055
4119
|
nextState.serverCommands.push(cmd);
|
|
4056
4120
|
nextState.lastA2uiHost = { id: messageId, index: messageIndex };
|
|
4121
|
+
const wizardSchema = normalizeWizardSchema(cmd);
|
|
4122
|
+
if (wizardSchema) {
|
|
4123
|
+
nextState.wizardSchemaBySurface[wizardSchema.surfaceId] = wizardSchema;
|
|
4124
|
+
}
|
|
4057
4125
|
const surfaceId = extractSurfaceId2(cmd);
|
|
4058
4126
|
if (!surfaceId) return;
|
|
4059
4127
|
if (cmd?.createSurface) {
|
|
@@ -4064,6 +4132,11 @@ function processA2uiCommand(cmd, messageIndex, messageId, nextState, effects, de
|
|
|
4064
4132
|
if (cmd?.createSurface) {
|
|
4065
4133
|
nextState.latestCreateCommandIndexBySurface[surfaceId] = nextState.serverCommands.length - 1;
|
|
4066
4134
|
nextState.optimisticallyDismissedSurfaceIds = nextState.optimisticallyDismissedSurfaceIds.filter((id) => id !== surfaceId);
|
|
4135
|
+
const schemaSource = cmd.createSurface.schema ?? cmd.createSurface.wizard ?? cmd.createSurface.plan;
|
|
4136
|
+
const schema = normalizeWizardSchema(schemaSource) ?? normalizeWizardSchema(cmd.createSurface);
|
|
4137
|
+
if (schema) {
|
|
4138
|
+
nextState.wizardSchemaBySurface[surfaceId] = schema;
|
|
4139
|
+
}
|
|
4067
4140
|
initializeWizardSurface(nextState, surfaceId, effects, nextWizardSteps);
|
|
4068
4141
|
}
|
|
4069
4142
|
if (cmd?.updateDataModel) {
|
|
@@ -4080,6 +4153,28 @@ function processA2uiCommand(cmd, messageIndex, messageId, nextState, effects, de
|
|
|
4080
4153
|
delete nextState.modelPathBySurface[surfaceId];
|
|
4081
4154
|
}
|
|
4082
4155
|
}
|
|
4156
|
+
function diffConversationMessages(messages, prevCursors) {
|
|
4157
|
+
if (messages.length < prevCursors.length) {
|
|
4158
|
+
return { shouldReplayAll: true, nextCursors: [], pendingItems: [] };
|
|
4159
|
+
}
|
|
4160
|
+
const nextCursors = [];
|
|
4161
|
+
const pendingItems = [];
|
|
4162
|
+
for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
|
|
4163
|
+
const message3 = messages[messageIndex];
|
|
4164
|
+
const messageId = String(message3?.messageId ?? messageIndex);
|
|
4165
|
+
const items = Array.isArray(message3?.content) ? message3.content : [];
|
|
4166
|
+
const prevCursor = prevCursors[messageIndex];
|
|
4167
|
+
const startIndex = prevCursor ? prevCursor.contentLength : 0;
|
|
4168
|
+
if (prevCursor && (prevCursor.messageId !== messageId || items.length < prevCursor.contentLength)) {
|
|
4169
|
+
return { shouldReplayAll: true, nextCursors: [], pendingItems: [] };
|
|
4170
|
+
}
|
|
4171
|
+
for (let itemIndex = startIndex; itemIndex < items.length; itemIndex += 1) {
|
|
4172
|
+
pendingItems.push({ messageIndex, messageId, item: items[itemIndex] });
|
|
4173
|
+
}
|
|
4174
|
+
nextCursors.push({ messageId, contentLength: items.length });
|
|
4175
|
+
}
|
|
4176
|
+
return { shouldReplayAll: false, nextCursors, pendingItems };
|
|
4177
|
+
}
|
|
4083
4178
|
function scanA2uiTagsFromMessages(messages, processedTagIds) {
|
|
4084
4179
|
const newTags = [];
|
|
4085
4180
|
const newTagIds = [];
|
|
@@ -4088,8 +4183,7 @@ function scanA2uiTagsFromMessages(messages, processedTagIds) {
|
|
|
4088
4183
|
const messageId = String(message3?.messageId ?? messageIndex);
|
|
4089
4184
|
const items = Array.isArray(message3?.content) ? message3.content : [];
|
|
4090
4185
|
for (const item of items) {
|
|
4091
|
-
|
|
4092
|
-
const text = item.messageContent || item.text || "";
|
|
4186
|
+
const text = extractItemTextForA2ui(item);
|
|
4093
4187
|
if (typeof text !== "string" || !text.includes("<A2UI")) continue;
|
|
4094
4188
|
const tags = parseA2uiTagsFromText(text);
|
|
4095
4189
|
for (const tag of tags) {
|
|
@@ -4104,14 +4198,9 @@ function scanA2uiTagsFromMessages(messages, processedTagIds) {
|
|
|
4104
4198
|
}
|
|
4105
4199
|
function reduceA2uiRuntimeMessages(state, messages) {
|
|
4106
4200
|
const { shouldReplayAll, pendingItems, nextCursors } = diffConversationMessages(messages || [], state.processedMessageCursors);
|
|
4107
|
-
const itemsToProcess = shouldReplayAll ? messages.flatMap((message3, messageIndex) => {
|
|
4108
|
-
const messageId = String(message3?.messageId ?? messageIndex);
|
|
4109
|
-
const items = Array.isArray(message3?.content) ? message3.content : [];
|
|
4110
|
-
return items.map((item) => ({ messageIndex, messageId, item }));
|
|
4111
|
-
}) : pendingItems;
|
|
4112
4201
|
const tagProcessedSet = new Set(shouldReplayAll ? [] : state.processedTagIds);
|
|
4113
4202
|
const { newTags, newTagIds } = scanA2uiTagsFromMessages(messages || [], tagProcessedSet);
|
|
4114
|
-
if (!shouldReplayAll &&
|
|
4203
|
+
if (!shouldReplayAll && pendingItems.length === 0 && newTags.length === 0) {
|
|
4115
4204
|
return { state, effects: [] };
|
|
4116
4205
|
}
|
|
4117
4206
|
const nextState = shouldReplayAll ? createA2uiRuntimeState() : { ...state };
|
|
@@ -4130,7 +4219,7 @@ function reduceA2uiRuntimeMessages(state, messages) {
|
|
|
4130
4219
|
const effects = shouldReplayAll ? [{ type: "reset-model-store" }] : [];
|
|
4131
4220
|
const deletedSurfaceIds = /* @__PURE__ */ new Set();
|
|
4132
4221
|
const nextWizardSteps = {};
|
|
4133
|
-
|
|
4222
|
+
pendingItems.forEach(({ item, messageIndex, messageId }) => {
|
|
4134
4223
|
if (item?.type === "a2uiSchema") {
|
|
4135
4224
|
const schema = normalizeWizardSchema(item.schema);
|
|
4136
4225
|
if (schema) {
|
|
@@ -4299,11 +4388,9 @@ var A2uiRuntimeContext = React10__namespace.default.createContext({
|
|
|
4299
4388
|
function useA2uiRuntimeView() {
|
|
4300
4389
|
return React10__namespace.default.useContext(A2uiRuntimeContext);
|
|
4301
4390
|
}
|
|
4302
|
-
function A2uiMessageCards({ messageIndex
|
|
4391
|
+
function A2uiMessageCards({ messageIndex }) {
|
|
4303
4392
|
const { surfaceIdsByMessageIndex } = useA2uiRuntimeView();
|
|
4304
|
-
const
|
|
4305
|
-
const inlineSurfaceIds = message3 ? extractInlineSurfaceIdsFromMessage(message3) : /* @__PURE__ */ new Set();
|
|
4306
|
-
const surfaceIds = allSurfaceIds.filter((id) => !inlineSurfaceIds.has(id));
|
|
4393
|
+
const surfaceIds = surfaceIdsByMessageIndex[messageIndex] || [];
|
|
4307
4394
|
if (!surfaceIds.length) return null;
|
|
4308
4395
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: surfaceIds.map((surfaceId) => /* @__PURE__ */ jsxRuntime.jsx(XCard.Card, { id: surfaceId }, surfaceId)) });
|
|
4309
4396
|
}
|
|
@@ -4509,16 +4596,14 @@ function buildLatestCommandIndexBySurface(messages) {
|
|
|
4509
4596
|
if (surfaceId) indexBySurface[surfaceId] = commandIndex;
|
|
4510
4597
|
continue;
|
|
4511
4598
|
}
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
for (const
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
if (surfaceId) indexBySurface[surfaceId] = commandIndex;
|
|
4521
|
-
}
|
|
4599
|
+
const text = extractItemTextForA2ui(item);
|
|
4600
|
+
if (typeof text !== "string" || !text.includes("<A2UI")) continue;
|
|
4601
|
+
const tags = parseA2uiTagsFromText(text);
|
|
4602
|
+
for (const tag of tags) {
|
|
4603
|
+
for (const cmd of tag.commands) {
|
|
4604
|
+
commandIndex += 1;
|
|
4605
|
+
const surfaceId = extractSurfaceId3(cmd);
|
|
4606
|
+
if (surfaceId) indexBySurface[surfaceId] = commandIndex;
|
|
4522
4607
|
}
|
|
4523
4608
|
}
|
|
4524
4609
|
}
|
|
@@ -4622,7 +4707,8 @@ var FilesNode = React10__namespace.default.memo(({ item }) => {
|
|
|
4622
4707
|
|
|
4623
4708
|
// src/components/CustomComponents/MessageNode/style.module.less
|
|
4624
4709
|
var style_module_default2 = {
|
|
4625
|
-
runStartedNode: "style_module_runStartedNode"
|
|
4710
|
+
runStartedNode: "style_module_runStartedNode",
|
|
4711
|
+
dot: "style_module_dot"};
|
|
4626
4712
|
var QuoteMsgNode = React10__namespace.default.memo(({ quoteMsg, role }) => {
|
|
4627
4713
|
if (!quoteMsg || !quoteMsg.messageContent) return null;
|
|
4628
4714
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4653,9 +4739,12 @@ var QuoteMsgNode = React10__namespace.default.memo(({ quoteMsg, role }) => {
|
|
|
4653
4739
|
}
|
|
4654
4740
|
);
|
|
4655
4741
|
});
|
|
4656
|
-
var RunStartedNode = React10__namespace.default.memo((
|
|
4657
|
-
|
|
4658
|
-
|
|
4742
|
+
var RunStartedNode = React10__namespace.default.memo(() => {
|
|
4743
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: style_module_default2.runStartedNode, children: [
|
|
4744
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: style_module_default2.dot }),
|
|
4745
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: style_module_default2.dot }),
|
|
4746
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: style_module_default2.dot })
|
|
4747
|
+
] });
|
|
4659
4748
|
});
|
|
4660
4749
|
var RESOURCE_MARKDOWN_TAG = "resourcetag";
|
|
4661
4750
|
var RESOURCE_TOKEN_REGEX = /(\w+):\/\/([^?\s]+)\?name=([^&\s]+)&label=([^\s]+)/g;
|
|
@@ -4687,39 +4776,20 @@ var TextNode2 = React10__namespace.default.memo(
|
|
|
4687
4776
|
item,
|
|
4688
4777
|
role,
|
|
4689
4778
|
customComponents,
|
|
4690
|
-
message: message3
|
|
4691
|
-
messageIndex = -1
|
|
4779
|
+
message: message3
|
|
4692
4780
|
}) => {
|
|
4693
|
-
const
|
|
4694
|
-
const rawContent = toA2uiDisplayText(role, item?.messageContent);
|
|
4695
|
-
const segments = splitA2uiTextSegments(rawContent);
|
|
4781
|
+
const content = toA2uiDisplayText(role, item?.messageContent);
|
|
4696
4782
|
const markdownComponents = {
|
|
4697
4783
|
[RESOURCE_MARKDOWN_TAG]: MessageResourceTag,
|
|
4698
4784
|
...customComponents
|
|
4699
4785
|
};
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
const isPureText = segments.length === 0 || segments.length === 1 && firstSeg.type === "text";
|
|
4703
|
-
if (isPureText) {
|
|
4704
|
-
const content = firstSeg && firstSeg.type === "text" ? firstSeg.content : "";
|
|
4705
|
-
if (typeof content === "string" && content.startsWith("Question:")) {
|
|
4706
|
-
return /* @__PURE__ */ jsxRuntime.jsx(QuestionSummary, { content });
|
|
4707
|
-
}
|
|
4708
|
-
const markdownContent = typeof content === "string" ? transformResourceText(content) : content;
|
|
4709
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4710
|
-
!!item.reasoningContent && /* @__PURE__ */ jsxRuntime.jsx(xV2.Think, { title: "\u6DF1\u5EA6\u601D\u8003", children: item.reasoningContent }),
|
|
4711
|
-
!!markdownContent && /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message3, components: markdownComponents, content: markdownContent })
|
|
4712
|
-
] });
|
|
4786
|
+
if (typeof content === "string" && content.startsWith("Question:")) {
|
|
4787
|
+
return /* @__PURE__ */ jsxRuntime.jsx(QuestionSummary, { content });
|
|
4713
4788
|
}
|
|
4789
|
+
const markdownContent = typeof content === "string" ? transformResourceText(content) : content;
|
|
4714
4790
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4715
4791
|
!!item.reasoningContent && /* @__PURE__ */ jsxRuntime.jsx(xV2.Think, { title: "\u6DF1\u5EA6\u601D\u8003", children: item.reasoningContent }),
|
|
4716
|
-
|
|
4717
|
-
if (seg.type === "text") {
|
|
4718
|
-
const markdownContent = transformResourceText(seg.content);
|
|
4719
|
-
return seg.content.trim() ? /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message3, components: markdownComponents, content: markdownContent }, `text-${i}`) : null;
|
|
4720
|
-
}
|
|
4721
|
-
return seg.surfaceIds.filter((sid) => !visibleSurfaceIds || visibleSurfaceIds.has(sid)).map((sid) => /* @__PURE__ */ jsxRuntime.jsx(XCard.Card, { id: sid }, `a2ui-${i}-${sid}`));
|
|
4722
|
-
})
|
|
4792
|
+
!!markdownContent && /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message3, components: markdownComponents, content: markdownContent })
|
|
4723
4793
|
] });
|
|
4724
4794
|
}
|
|
4725
4795
|
);
|
|
@@ -4728,11 +4798,17 @@ var TextNode2 = React10__namespace.default.memo(
|
|
|
4728
4798
|
var index_module_default2 = {
|
|
4729
4799
|
iconContainer: "index_module_iconContainer",
|
|
4730
4800
|
toolName: "index_module_toolName",
|
|
4801
|
+
toolNamePending: "index_module_toolNamePending",
|
|
4802
|
+
dot: "index_module_dot",
|
|
4731
4803
|
duration: "index_module_duration",
|
|
4732
4804
|
statusIcon: "index_module_statusIcon",
|
|
4805
|
+
expandIcon: "index_module_expandIcon",
|
|
4806
|
+
expanded: "index_module_expanded",
|
|
4733
4807
|
sectionLabel: "index_module_sectionLabel",
|
|
4808
|
+
plainTextContainer: "index_module_plainTextContainer",
|
|
4734
4809
|
markdownContainer: "index_module_markdownContainer",
|
|
4735
4810
|
sectionBlock: "index_module_sectionBlock",
|
|
4811
|
+
contentScrollContainer: "index_module_contentScrollContainer",
|
|
4736
4812
|
todoList: "index_module_todoList",
|
|
4737
4813
|
todoItem: "index_module_todoItem",
|
|
4738
4814
|
statusIconWrapper: "index_module_statusIconWrapper",
|
|
@@ -4742,6 +4818,9 @@ var index_module_default2 = {
|
|
|
4742
4818
|
emptyText: "index_module_emptyText"
|
|
4743
4819
|
};
|
|
4744
4820
|
var DefaultToolRender = ({ argsContent, resultContent, errorMessage, item }) => {
|
|
4821
|
+
if (item.display) {
|
|
4822
|
+
return /* @__PURE__ */ jsxRuntime.jsx("pre", { className: index_module_default2.plainTextContainer, children: item.display });
|
|
4823
|
+
}
|
|
4745
4824
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4746
4825
|
(item.content || item.arguments) && argsContent && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: index_module_default2.sectionBlock, children: [
|
|
4747
4826
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: index_module_default2.sectionLabel, children: "\u8F93\u5165\u53C2\u6570" }),
|
|
@@ -4817,6 +4896,15 @@ var getToolRenderConfig = (toolName) => {
|
|
|
4817
4896
|
alwaysShowContent: false
|
|
4818
4897
|
};
|
|
4819
4898
|
};
|
|
4899
|
+
function stripA2uiTagsFromResult(result) {
|
|
4900
|
+
if (!result || typeof result !== "object" || Array.isArray(result)) return result;
|
|
4901
|
+
const cleaned = {};
|
|
4902
|
+
for (const [key, value] of Object.entries(result)) {
|
|
4903
|
+
cleaned[key] = typeof value === "string" && value.includes("<A2UI") ? stripA2uiTags(value) : value;
|
|
4904
|
+
}
|
|
4905
|
+
const hasVisible = Object.values(cleaned).some((v) => v !== "" && v !== null && v !== void 0);
|
|
4906
|
+
return hasVisible ? cleaned : null;
|
|
4907
|
+
}
|
|
4820
4908
|
var formatContent = (content) => {
|
|
4821
4909
|
try {
|
|
4822
4910
|
if (!content) return { text: "", isJson: false, parsed: null };
|
|
@@ -4827,14 +4915,16 @@ var formatContent = (content) => {
|
|
|
4827
4915
|
if (typeof parsed === "object" && parsed !== null) {
|
|
4828
4916
|
return { text: JSON.stringify(parsed, null, 2), isJson: true, parsed };
|
|
4829
4917
|
}
|
|
4830
|
-
|
|
4918
|
+
const stripped = content.includes("<A2UI") ? stripA2uiTags(content) : content;
|
|
4919
|
+
return { text: stripped, isJson: false, parsed: null };
|
|
4831
4920
|
} catch {
|
|
4832
|
-
|
|
4921
|
+
const text = typeof content === "string" ? content.includes("<A2UI") ? stripA2uiTags(content) : content : "";
|
|
4922
|
+
return { text, isJson: false, parsed: null };
|
|
4833
4923
|
}
|
|
4834
4924
|
};
|
|
4835
4925
|
var ToolCallItem = ({ item }) => {
|
|
4836
4926
|
const { token } = antd.theme.useToken();
|
|
4837
|
-
const renderConfig = getToolRenderConfig(item
|
|
4927
|
+
const renderConfig = getToolRenderConfig(item);
|
|
4838
4928
|
const CustomRender = renderConfig.component;
|
|
4839
4929
|
const status = React10.useMemo(() => {
|
|
4840
4930
|
if (item.status) return item.status;
|
|
@@ -4843,7 +4933,12 @@ var ToolCallItem = ({ item }) => {
|
|
|
4843
4933
|
return "running";
|
|
4844
4934
|
}, [item.status, item.errorMessage, item.result]);
|
|
4845
4935
|
const argsContent = React10.useMemo(() => formatContent(item.arguments || item.content), [item.arguments, item.content]);
|
|
4846
|
-
const resultContent = React10.useMemo(() =>
|
|
4936
|
+
const resultContent = React10.useMemo(() => {
|
|
4937
|
+
if (!item.result) return null;
|
|
4938
|
+
const cleanedResult = stripA2uiTagsFromResult(item.result);
|
|
4939
|
+
if (!cleanedResult) return null;
|
|
4940
|
+
return formatContent(cleanedResult);
|
|
4941
|
+
}, [item.result]);
|
|
4847
4942
|
const hasContent = React10.useMemo(() => {
|
|
4848
4943
|
if (renderConfig.disableExpandOnError && status === "error") return false;
|
|
4849
4944
|
let alwaysShow = false;
|
|
@@ -4853,35 +4948,30 @@ var ToolCallItem = ({ item }) => {
|
|
|
4853
4948
|
alwaysShow = renderConfig.alwaysShowContent;
|
|
4854
4949
|
}
|
|
4855
4950
|
if (alwaysShow) return true;
|
|
4856
|
-
|
|
4857
|
-
|
|
4951
|
+
if (item.display) return true;
|
|
4952
|
+
if (item.errorMessage) return true;
|
|
4953
|
+
if (argsContent.text) return true;
|
|
4954
|
+
if (resultContent?.text) return true;
|
|
4955
|
+
return false;
|
|
4956
|
+
}, [
|
|
4957
|
+
renderConfig.disableExpandOnError,
|
|
4958
|
+
renderConfig.alwaysShowContent,
|
|
4959
|
+
item.display,
|
|
4960
|
+
item.errorMessage,
|
|
4961
|
+
status,
|
|
4962
|
+
argsContent.parsed,
|
|
4963
|
+
resultContent?.parsed,
|
|
4964
|
+
argsContent.text,
|
|
4965
|
+
resultContent?.text
|
|
4966
|
+
]);
|
|
4858
4967
|
const isDefaultExpanded = React10.useMemo(() => {
|
|
4859
4968
|
if (typeof renderConfig.defaultExpanded === "function") {
|
|
4860
4969
|
return renderConfig.defaultExpanded(argsContent.parsed, resultContent?.parsed);
|
|
4861
4970
|
}
|
|
4862
4971
|
return renderConfig.defaultExpanded;
|
|
4863
4972
|
}, [renderConfig.defaultExpanded, argsContent.parsed, resultContent?.parsed]);
|
|
4864
|
-
const
|
|
4865
|
-
|
|
4866
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.LoadingOutlined, {}),
|
|
4867
|
-
color: token.colorPrimary
|
|
4868
|
-
},
|
|
4869
|
-
success: {
|
|
4870
|
-
icon: null,
|
|
4871
|
-
color: token.colorSuccess
|
|
4872
|
-
},
|
|
4873
|
-
error: {
|
|
4874
|
-
icon: null,
|
|
4875
|
-
color: token.colorSuccess
|
|
4876
|
-
},
|
|
4877
|
-
pending: {
|
|
4878
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.LoadingOutlined, {}),
|
|
4879
|
-
color: token.colorTextSecondary
|
|
4880
|
-
}
|
|
4881
|
-
}[status] || {
|
|
4882
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.LoadingOutlined, {}),
|
|
4883
|
-
color: token.colorPrimary
|
|
4884
|
-
};
|
|
4973
|
+
const showLoading = status === "running" || status === "pending";
|
|
4974
|
+
const displayName = item.title || (showLoading ? "" : item.toolName || "Unknown Tool");
|
|
4885
4975
|
const renderIcon = () => {
|
|
4886
4976
|
if (!item.toolIcon) {
|
|
4887
4977
|
return /* @__PURE__ */ jsxRuntime.jsx(icons.ToolOutlined, { style: { fontSize: 14, color: token.colorTextSecondary } });
|
|
@@ -4899,9 +4989,11 @@ var ToolCallItem = ({ item }) => {
|
|
|
4899
4989
|
collapsible: hasContent ? void 0 : "disabled",
|
|
4900
4990
|
defaultActiveKey: isDefaultExpanded && hasContent ? [item.toolCallId || "fallback-key"] : void 0,
|
|
4901
4991
|
expandIconPlacement: "end",
|
|
4992
|
+
expandIcon: ({ isActive }) => hasContent ? /* @__PURE__ */ jsxRuntime.jsx(icons.RightOutlined, { className: `${index_module_default2.expandIcon} ${isActive ? index_module_default2.expanded : ""}` }) : null,
|
|
4902
4993
|
styles: {
|
|
4903
4994
|
header: {
|
|
4904
|
-
padding: "6px 10px"
|
|
4995
|
+
padding: "6px 10px",
|
|
4996
|
+
overflow: "hidden"
|
|
4905
4997
|
}
|
|
4906
4998
|
},
|
|
4907
4999
|
items: [
|
|
@@ -4910,14 +5002,18 @@ var ToolCallItem = ({ item }) => {
|
|
|
4910
5002
|
showArrow: hasContent,
|
|
4911
5003
|
label: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", gap: 8, style: { flex: 1, minWidth: 0 }, children: [
|
|
4912
5004
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.iconContainer, children: renderIcon() }),
|
|
4913
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.toolName, children:
|
|
4914
|
-
|
|
5005
|
+
displayName ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.toolName, children: displayName }) : /* @__PURE__ */ jsxRuntime.jsxs("span", { className: index_module_default2.toolNamePending, children: [
|
|
5006
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.dot }),
|
|
5007
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.dot }),
|
|
5008
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: index_module_default2.dot })
|
|
5009
|
+
] }),
|
|
5010
|
+
showLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.statusIcon, style: { color: token.colorPrimary }, children: /* @__PURE__ */ jsxRuntime.jsx(icons.LoadingOutlined, {}) }),
|
|
4915
5011
|
item.duration && /* @__PURE__ */ jsxRuntime.jsxs(antd.Typography.Text, { className: index_module_default2.duration, children: [
|
|
4916
5012
|
item.duration,
|
|
4917
5013
|
"ms"
|
|
4918
5014
|
] })
|
|
4919
5015
|
] }),
|
|
4920
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5016
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.contentScrollContainer, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4921
5017
|
CustomRender,
|
|
4922
5018
|
{
|
|
4923
5019
|
item,
|
|
@@ -4927,35 +5023,30 @@ var ToolCallItem = ({ item }) => {
|
|
|
4927
5023
|
resultContent,
|
|
4928
5024
|
errorMessage: item.errorMessage
|
|
4929
5025
|
}
|
|
4930
|
-
)
|
|
5026
|
+
) })
|
|
4931
5027
|
}
|
|
4932
5028
|
]
|
|
4933
5029
|
}
|
|
4934
5030
|
);
|
|
4935
5031
|
};
|
|
4936
5032
|
var tool_call_item_default = ToolCallItem;
|
|
4937
|
-
var RENDERABLE_MESSAGE_TYPES = ["runStarted", "toolCall", "toolResult", "text", "stepError", "files", "plan"];
|
|
5033
|
+
var RENDERABLE_MESSAGE_TYPES = ["runStarted", "toolCall", "toolResult", "text", "stepError", "runFailed", "files", "plan"];
|
|
4938
5034
|
var MessageRender_default = React10__namespace.default.memo(({ role, message: message3, messageIndex = -1, loading, containerRef, customComponents }) => {
|
|
4939
5035
|
const content = React10.useMemo(() => {
|
|
4940
5036
|
return (message3.content || []).filter((item) => {
|
|
4941
5037
|
if (!RENDERABLE_MESSAGE_TYPES.includes(item.type)) {
|
|
4942
5038
|
return false;
|
|
4943
5039
|
}
|
|
4944
|
-
if (item.type === "runStarted") {
|
|
4945
|
-
return !!loading;
|
|
4946
|
-
}
|
|
4947
5040
|
if (item.type === "plan") {
|
|
4948
5041
|
return !shouldHideA2uiPlan(item);
|
|
4949
5042
|
}
|
|
4950
5043
|
if (item.type === "text") {
|
|
4951
5044
|
const rawText = item.messageContent || item.text || "";
|
|
4952
|
-
|
|
4953
|
-
const hasA2uiTag2 = typeof rawText === "string" && rawText.includes("<A2UI");
|
|
4954
|
-
return !!visibleText.trim() || !!item.reasoningContent || hasA2uiTag2;
|
|
5045
|
+
return !!rawText.trim() || !!item.reasoningContent;
|
|
4955
5046
|
}
|
|
4956
5047
|
return true;
|
|
4957
5048
|
});
|
|
4958
|
-
}, [
|
|
5049
|
+
}, [message3.content]);
|
|
4959
5050
|
const quoteMsg = React10.useMemo(() => {
|
|
4960
5051
|
const quoteMsg2 = {};
|
|
4961
5052
|
if (message3.params) {
|
|
@@ -4969,29 +5060,46 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
|
|
|
4969
5060
|
}
|
|
4970
5061
|
return common.isEmptyObj(quoteMsg2) ? null : quoteMsg2;
|
|
4971
5062
|
}, [message3.params, message3.quoteMsg]);
|
|
4972
|
-
|
|
5063
|
+
const showPending = loading && (content.length === 0 || content[content.length - 1].type !== "text");
|
|
5064
|
+
if (content.length === 0 && !showPending) return null;
|
|
5065
|
+
const lastToolCallIndex = (() => {
|
|
5066
|
+
let lastIdx = -1;
|
|
5067
|
+
content.forEach((item, i) => {
|
|
5068
|
+
if (item.type === "toolCall" || item.type === "toolResult") lastIdx = i;
|
|
5069
|
+
});
|
|
5070
|
+
return lastIdx;
|
|
5071
|
+
})();
|
|
4973
5072
|
return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { ref: containerRef, vertical: true, gap: 8, children: [
|
|
4974
|
-
content.map((item, index) => {
|
|
4975
|
-
|
|
5073
|
+
content.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs(React10__namespace.default.Fragment, { children: [
|
|
5074
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4976
5075
|
xV2.Bubble,
|
|
4977
5076
|
{
|
|
4978
5077
|
role: role.user,
|
|
4979
5078
|
placement: role.placement,
|
|
4980
5079
|
variant: item.type === "files" ? "borderless" : void 0,
|
|
4981
5080
|
content: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4982
|
-
item.type === "runStarted" && /* @__PURE__ */ jsxRuntime.jsx(RunStartedNode, { loading }, `flow-start-${index}`),
|
|
4983
5081
|
(item.type === "toolCall" || item.type === "toolResult") && /* @__PURE__ */ jsxRuntime.jsx(tool_call_item_default, { item }, `tool-call-${item.toolCallId || index}`),
|
|
4984
|
-
item.type === "text" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4985
|
-
|
|
5082
|
+
item.type === "text" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5083
|
+
TextNode2,
|
|
5084
|
+
{
|
|
5085
|
+
item,
|
|
5086
|
+
role: message3.role,
|
|
5087
|
+
customComponents,
|
|
5088
|
+
message: message3,
|
|
5089
|
+
messageIndex
|
|
5090
|
+
},
|
|
5091
|
+
`message-${index}`
|
|
5092
|
+
),
|
|
5093
|
+
(item.type === "stepError" || item.type === "runFailed") && (item.errorMessage ? /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message3, components: customComponents, content: item.errorMessage }) : null),
|
|
4986
5094
|
item.type === "files" && /* @__PURE__ */ jsxRuntime.jsx(FilesNode, { item }, `files-${index}`),
|
|
4987
5095
|
item.type === "plan" && /* @__PURE__ */ jsxRuntime.jsx(A2uiPlanNode, { item }, `plan-${index}`)
|
|
4988
5096
|
] })
|
|
4989
|
-
}
|
|
4990
|
-
|
|
4991
|
-
)
|
|
4992
|
-
}),
|
|
4993
|
-
|
|
4994
|
-
|
|
5097
|
+
}
|
|
5098
|
+
),
|
|
5099
|
+
index === lastToolCallIndex && messageIndex >= 0 ? /* @__PURE__ */ jsxRuntime.jsx(A2uiMessageCards, { messageIndex, message: message3 }) : null
|
|
5100
|
+
] }, `message-${index}`)),
|
|
5101
|
+
showPending && /* @__PURE__ */ jsxRuntime.jsx(xV2.Bubble, { role: role.user, placement: role.placement, content: /* @__PURE__ */ jsxRuntime.jsx(RunStartedNode, {}) }),
|
|
5102
|
+
quoteMsg && /* @__PURE__ */ jsxRuntime.jsx(QuoteMsgNode, { quoteMsg, role })
|
|
4995
5103
|
] });
|
|
4996
5104
|
});
|
|
4997
5105
|
var WelcomeItem_default = ({ icon = true, title = true, description = true, prompts = true }) => {
|