@zero-library/chat-copilot 3.1.11 → 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 +207 -96
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +182 -30
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +71 -7
- package/dist/index.d.ts +71 -7
- package/dist/index.esm.js +207 -96
- 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 || "",
|
|
@@ -1623,36 +1623,34 @@ function createChatStore() {
|
|
|
1623
1623
|
messages.push(finalMsg);
|
|
1624
1624
|
} else {
|
|
1625
1625
|
const contents = messages[idx].content;
|
|
1626
|
-
|
|
1626
|
+
let existingItemIndex = contents.findIndex(
|
|
1627
1627
|
(item) => item.type === "toolCall" && item.toolCallId === contentItem.toolCallId
|
|
1628
1628
|
);
|
|
1629
|
+
if (existingItemIndex === -1 && contentItem.toolCallId) {
|
|
1630
|
+
existingItemIndex = contents.findIndex(
|
|
1631
|
+
(item) => item.type === "toolCall" && !item.toolCallId && item._streamingIndex !== void 0
|
|
1632
|
+
);
|
|
1633
|
+
}
|
|
1629
1634
|
if (existingItemIndex !== -1) {
|
|
1630
|
-
const
|
|
1635
|
+
const nextItem = { ...contents[existingItemIndex] };
|
|
1631
1636
|
const newContent = contentItem.content || contentItem.arguments;
|
|
1632
|
-
const nextItem = { ...existingItem };
|
|
1633
1637
|
if (typeof newContent === "string") {
|
|
1634
|
-
nextItem.content = (
|
|
1638
|
+
nextItem.content = (nextItem.content || "") + newContent;
|
|
1635
1639
|
} else if (newContent !== void 0) {
|
|
1636
1640
|
nextItem.arguments = newContent;
|
|
1637
1641
|
}
|
|
1638
|
-
if (contentItem.toolName)
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
if (contentItem.
|
|
1642
|
-
|
|
1643
|
-
}
|
|
1644
|
-
if (contentItem.status) {
|
|
1645
|
-
nextItem.status = contentItem.status;
|
|
1646
|
-
}
|
|
1647
|
-
if (contentItem.toolIcon) {
|
|
1648
|
-
nextItem.toolIcon = contentItem.toolIcon;
|
|
1649
|
-
}
|
|
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;
|
|
1650
1647
|
if (contentItem.display) {
|
|
1651
|
-
nextItem.
|
|
1648
|
+
nextItem.argsDisplay = contentItem.display;
|
|
1649
|
+
nextItem.displayProtocol = true;
|
|
1652
1650
|
}
|
|
1653
1651
|
messages[idx].content = contents.map((item, i) => i === existingItemIndex ? nextItem : item);
|
|
1654
1652
|
} else {
|
|
1655
|
-
messages[idx].content = [...contents, contentItem];
|
|
1653
|
+
messages[idx].content = [...contents, { ...contentItem, displayProtocol: !!contentItem.display }];
|
|
1656
1654
|
}
|
|
1657
1655
|
}
|
|
1658
1656
|
if (isMain) conversation.messages[msg.conversationId].loading = true;
|
|
@@ -1671,25 +1669,20 @@ function createChatStore() {
|
|
|
1671
1669
|
const contents = messages[idx].content;
|
|
1672
1670
|
const toolCallIndex = contents.findIndex((item) => item.type === "toolCall" && item.toolCallId === contentItem.toolCallId);
|
|
1673
1671
|
if (toolCallIndex !== -1) {
|
|
1674
|
-
const toolCallItem = contents[toolCallIndex];
|
|
1675
1672
|
const nextToolCallItem = {
|
|
1676
|
-
...
|
|
1673
|
+
...contents[toolCallIndex],
|
|
1677
1674
|
result: contentItem.result ?? contentItem.content
|
|
1678
1675
|
};
|
|
1679
|
-
if (contentItem.status)
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
if (contentItem.
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
nextToolCallItem.title = contentItem.title;
|
|
1690
|
-
}
|
|
1691
|
-
if (contentItem.display !== void 0) {
|
|
1692
|
-
nextToolCallItem.display = contentItem.display;
|
|
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;
|
|
1693
1686
|
}
|
|
1694
1687
|
messages[idx].content = contents.map((item, i) => i === toolCallIndex ? nextToolCallItem : item);
|
|
1695
1688
|
} else {
|
|
@@ -1716,59 +1709,74 @@ function createChatStore() {
|
|
|
1716
1709
|
let idx = -1;
|
|
1717
1710
|
if (contentItem.toolCallId) {
|
|
1718
1711
|
idx = messages.findLastIndex(
|
|
1719
|
-
(m) => m.content?.some((c) =>
|
|
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)
|
|
1720
1718
|
);
|
|
1721
1719
|
}
|
|
1722
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
|
+
};
|
|
1723
1744
|
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
|
-
});
|
|
1745
|
+
messages.push({ ...msg, content: [buildNewItem()], generating: true });
|
|
1740
1746
|
} else {
|
|
1741
1747
|
const contents = messages[idx].content;
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
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
|
+
}
|
|
1745
1755
|
if (itemIdx !== -1) {
|
|
1746
1756
|
const existing = contents[itemIdx];
|
|
1747
1757
|
const nextItem = {
|
|
1748
1758
|
...existing,
|
|
1749
1759
|
type: "toolCall",
|
|
1750
|
-
content: (existing.content || "") + (contentItem.argumentsDelta || "")
|
|
1760
|
+
content: contentItem.displayDelta ? existing.content || "" : (existing.content || "") + (contentItem.argumentsDelta || "")
|
|
1751
1761
|
};
|
|
1762
|
+
if (contentItem.toolCallId && !existing.toolCallId) nextItem.toolCallId = contentItem.toolCallId;
|
|
1752
1763
|
if (contentItem.toolName) nextItem.toolName = contentItem.toolName;
|
|
1753
1764
|
if (contentItem.title) nextItem.title = contentItem.title;
|
|
1754
1765
|
if (contentItem.status) nextItem.status = contentItem.status;
|
|
1755
1766
|
if (contentItem.toolIcon) nextItem.toolIcon = contentItem.toolIcon;
|
|
1756
|
-
if (contentItem.
|
|
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
|
+
}
|
|
1757
1777
|
messages[idx].content = contents.map((c, i) => i === itemIdx ? nextItem : c);
|
|
1758
1778
|
} 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
|
-
];
|
|
1779
|
+
messages[idx].content = [...contents, buildNewItem()];
|
|
1772
1780
|
}
|
|
1773
1781
|
}
|
|
1774
1782
|
if (isMain) conversation.messages[msg.conversationId].loading = true;
|
|
@@ -1998,6 +2006,11 @@ function createChatStore() {
|
|
|
1998
2006
|
const dealedParams = await config.hooks?.onHandleSendParams?.(sendParams);
|
|
1999
2007
|
await config.services.request.sendMessageStream(dealedParams || sendParams, agent.agentInfo?.id || "");
|
|
2000
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;
|
|
2001
2014
|
} finally {
|
|
2002
2015
|
}
|
|
2003
2016
|
};
|
|
@@ -4796,10 +4809,12 @@ var TextNode2 = React10__namespace.default.memo(
|
|
|
4796
4809
|
|
|
4797
4810
|
// src/components/CustomComponents/ToolRenders/index.module.less
|
|
4798
4811
|
var index_module_default2 = {
|
|
4812
|
+
toolCollapse: "index_module_toolCollapse",
|
|
4799
4813
|
iconContainer: "index_module_iconContainer",
|
|
4800
4814
|
toolName: "index_module_toolName",
|
|
4801
4815
|
toolNamePending: "index_module_toolNamePending",
|
|
4802
4816
|
dot: "index_module_dot",
|
|
4817
|
+
dotBlink: "index_module_dotBlink",
|
|
4803
4818
|
duration: "index_module_duration",
|
|
4804
4819
|
statusIcon: "index_module_statusIcon",
|
|
4805
4820
|
expandIcon: "index_module_expandIcon",
|
|
@@ -4807,8 +4822,30 @@ var index_module_default2 = {
|
|
|
4807
4822
|
sectionLabel: "index_module_sectionLabel",
|
|
4808
4823
|
plainTextContainer: "index_module_plainTextContainer",
|
|
4809
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",
|
|
4810
4842
|
sectionBlock: "index_module_sectionBlock",
|
|
4843
|
+
compactSectionBlock: "index_module_compactSectionBlock",
|
|
4811
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",
|
|
4812
4849
|
todoList: "index_module_todoList",
|
|
4813
4850
|
todoItem: "index_module_todoItem",
|
|
4814
4851
|
statusIconWrapper: "index_module_statusIconWrapper",
|
|
@@ -4817,28 +4854,89 @@ var index_module_default2 = {
|
|
|
4817
4854
|
completed: "index_module_completed",
|
|
4818
4855
|
emptyText: "index_module_emptyText"
|
|
4819
4856
|
};
|
|
4820
|
-
var
|
|
4821
|
-
if (
|
|
4822
|
-
|
|
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}`);
|
|
4823
4871
|
}
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: index_module_default2.sectionLabel, children:
|
|
4827
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.
|
|
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
|
|
4828
4931
|
${argsContent.text}
|
|
4829
4932
|
\`\`\`` : argsContent.text }) })
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
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
|
|
4834
4937
|
${resultContent.text}
|
|
4835
4938
|
\`\`\`` : resultContent.text }) })
|
|
4836
|
-
|
|
4837
|
-
errorMessage && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: index_module_default2.sectionBlock, children: [
|
|
4838
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { className: index_module_default2.sectionLabel, children: "\u9519\u8BEF\u4FE1\u606F" }),
|
|
4839
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default2.markdownContainer, children: /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { content: `\`\`\`
|
|
4840
|
-
${errorMessage}
|
|
4841
|
-
\`\`\`` }) })
|
|
4939
|
+
] })
|
|
4842
4940
|
] })
|
|
4843
4941
|
] });
|
|
4844
4942
|
};
|
|
@@ -4922,6 +5020,9 @@ var formatContent = (content) => {
|
|
|
4922
5020
|
return { text, isJson: false, parsed: null };
|
|
4923
5021
|
}
|
|
4924
5022
|
};
|
|
5023
|
+
var hasDisplayViewBody = (view) => {
|
|
5024
|
+
return !!(view?.summary || view?.blocks?.length || view?.meta?.length);
|
|
5025
|
+
};
|
|
4925
5026
|
var ToolCallItem = ({ item }) => {
|
|
4926
5027
|
const { token } = antd.theme.useToken();
|
|
4927
5028
|
const renderConfig = getToolRenderConfig(item);
|
|
@@ -4948,16 +5049,22 @@ var ToolCallItem = ({ item }) => {
|
|
|
4948
5049
|
alwaysShow = renderConfig.alwaysShowContent;
|
|
4949
5050
|
}
|
|
4950
5051
|
if (alwaysShow) return true;
|
|
4951
|
-
if (item.
|
|
4952
|
-
|
|
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
|
+
}
|
|
4953
5058
|
if (argsContent.text) return true;
|
|
4954
5059
|
if (resultContent?.text) return true;
|
|
4955
5060
|
return false;
|
|
4956
5061
|
}, [
|
|
4957
5062
|
renderConfig.disableExpandOnError,
|
|
4958
5063
|
renderConfig.alwaysShowContent,
|
|
4959
|
-
item.
|
|
4960
|
-
item.
|
|
5064
|
+
item.displayProtocol,
|
|
5065
|
+
item.streamingArgsDisplay,
|
|
5066
|
+
item.argsDisplay,
|
|
5067
|
+
item.resultDisplay,
|
|
4961
5068
|
status,
|
|
4962
5069
|
argsContent.parsed,
|
|
4963
5070
|
resultContent?.parsed,
|
|
@@ -4985,15 +5092,19 @@ var ToolCallItem = ({ item }) => {
|
|
|
4985
5092
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4986
5093
|
antd.Collapse,
|
|
4987
5094
|
{
|
|
4988
|
-
|
|
5095
|
+
className: index_module_default2.toolCollapse,
|
|
5096
|
+
style: { width: "100%" },
|
|
4989
5097
|
collapsible: hasContent ? void 0 : "disabled",
|
|
4990
5098
|
defaultActiveKey: isDefaultExpanded && hasContent ? [item.toolCallId || "fallback-key"] : void 0,
|
|
4991
5099
|
expandIconPlacement: "end",
|
|
4992
5100
|
expandIcon: ({ isActive }) => hasContent ? /* @__PURE__ */ jsxRuntime.jsx(icons.RightOutlined, { className: `${index_module_default2.expandIcon} ${isActive ? index_module_default2.expanded : ""}` }) : null,
|
|
4993
5101
|
styles: {
|
|
4994
5102
|
header: {
|
|
4995
|
-
padding: "
|
|
5103
|
+
padding: "4px 8px",
|
|
4996
5104
|
overflow: "hidden"
|
|
5105
|
+
},
|
|
5106
|
+
body: {
|
|
5107
|
+
padding: "0 8px 8px"
|
|
4997
5108
|
}
|
|
4998
5109
|
},
|
|
4999
5110
|
items: [
|
|
@@ -5398,7 +5509,7 @@ var ResourceSelectorModal_default = ({ open, type, onCancel }) => {
|
|
|
5398
5509
|
setCategories([{ id: ALL_CATEGORY_ID, name: "\u5168\u90E8" }, ...tagsRes.data || []]);
|
|
5399
5510
|
setResources(fetchedResources);
|
|
5400
5511
|
const spec = conversationState.active.spec;
|
|
5401
|
-
const initialItems = isSkill ? spec?.skills?.items : spec?.
|
|
5512
|
+
const initialItems = isSkill ? spec?.skills?.items : spec?.knowledges?.items;
|
|
5402
5513
|
const validIds = new Set(fetchedResources.map((r) => r.id));
|
|
5403
5514
|
const validSelectedIds = (initialItems || []).map((item) => item.id).filter((id) => validIds.has(id));
|
|
5404
5515
|
setSelectedIds(validSelectedIds);
|
|
@@ -5445,7 +5556,7 @@ var ResourceSelectorModal_default = ({ open, type, onCancel }) => {
|
|
|
5445
5556
|
items: ids.map((id) => ({ id }))
|
|
5446
5557
|
};
|
|
5447
5558
|
} else {
|
|
5448
|
-
nextSpec.
|
|
5559
|
+
nextSpec.knowledges = {
|
|
5449
5560
|
items: ids.map((id) => {
|
|
5450
5561
|
const resource = resourceList.find((r) => r.id === id);
|
|
5451
5562
|
return { id, name: resource?.name || "" };
|
|
@@ -5592,7 +5703,7 @@ var KnowledgeBtn_default = ({}) => {
|
|
|
5592
5703
|
const chatStore = useChatStore();
|
|
5593
5704
|
const conversationState = valtio.useSnapshot(chatStore.conversation);
|
|
5594
5705
|
const [modalOpen, setModalOpen] = React10.useState(false);
|
|
5595
|
-
const knowledgeCount = conversationState.active.spec?.
|
|
5706
|
+
const knowledgeCount = conversationState.active.spec?.knowledges?.items?.length ?? 0;
|
|
5596
5707
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5597
5708
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: style_module_default.resourceBtn, onClick: () => setModalOpen(true), children: [
|
|
5598
5709
|
/* @__PURE__ */ jsxRuntime.jsx(IconFont_default, { type: "icon-remark" }),
|