@zero-library/chat-copilot 3.1.8 → 3.1.9
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 +513 -80
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.esm.js +515 -82
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -72,7 +72,7 @@ var styles_module_default = {
|
|
|
72
72
|
chatAttachments: "styles_module_chatAttachments",
|
|
73
73
|
chatSender: "styles_module_chatSender"};
|
|
74
74
|
var Attachments_default = React10.forwardRef(({ fileUpload, fileUploadConfig, fileList = [], onChange, extraParams }, ref) => {
|
|
75
|
-
const { message:
|
|
75
|
+
const { message: message3 } = antd.App.useApp();
|
|
76
76
|
const chatStore = useChatStore();
|
|
77
77
|
valtio.useSnapshot(chatStore.agent);
|
|
78
78
|
const fileListRef = React10.useRef([]);
|
|
@@ -100,7 +100,7 @@ var Attachments_default = React10.forwardRef(({ fileUpload, fileUploadConfig, fi
|
|
|
100
100
|
onChange(files);
|
|
101
101
|
}, [attachedFiles]);
|
|
102
102
|
const onErrorTip = common.useDebounce((errorMsg) => {
|
|
103
|
-
|
|
103
|
+
message3.error(errorMsg);
|
|
104
104
|
}, 300);
|
|
105
105
|
const findConfig = (file) => {
|
|
106
106
|
return fileUploadConfig?.allowedTypes?.find((type) => type === common.getFileSuffixName(file.name)) || "";
|
|
@@ -294,6 +294,41 @@ var classifyTime = (timestamp) => {
|
|
|
294
294
|
return "\u66F4\u65E9";
|
|
295
295
|
}
|
|
296
296
|
};
|
|
297
|
+
var variablesToObject = (variables) => {
|
|
298
|
+
if (!common.isArray(variables)) return {};
|
|
299
|
+
const jsonTypes = ["OBJECT", "ARRAY", "ARRAY_STRING", "ARRAY_NUMBER", "ARRAY_DECIMAL", "ARRAY_BOOLEAN", "ARRAY_OBJECT"];
|
|
300
|
+
return variables.reduce(
|
|
301
|
+
(acc, cur) => {
|
|
302
|
+
if (cur.type === "BOOLEAN") {
|
|
303
|
+
if (common.isDef(cur.value) && !common.isNull(cur.value)) {
|
|
304
|
+
acc[cur.name] = cur.value;
|
|
305
|
+
}
|
|
306
|
+
} else if (jsonTypes.includes(cur.type)) {
|
|
307
|
+
if (common.isDef(cur.value) && !common.isNull(cur.value)) {
|
|
308
|
+
if (typeof cur.value === "string") {
|
|
309
|
+
if (cur.value === "") {
|
|
310
|
+
acc[cur.name] = cur.type === "OBJECT" ? {} : [];
|
|
311
|
+
} else {
|
|
312
|
+
try {
|
|
313
|
+
acc[cur.name] = JSON.parse(cur.value);
|
|
314
|
+
} catch (e) {
|
|
315
|
+
acc[cur.name] = cur.type === "OBJECT" ? {} : [];
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
} else {
|
|
319
|
+
acc[cur.name] = cur.value;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
} else {
|
|
323
|
+
if (common.isDef(cur.value) && !common.isNull(cur.value) && cur.value !== "") {
|
|
324
|
+
acc[cur.name] = cur.value;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return acc;
|
|
328
|
+
},
|
|
329
|
+
{}
|
|
330
|
+
);
|
|
331
|
+
};
|
|
297
332
|
var getChatSocketUrl = (baseURL, params) => {
|
|
298
333
|
return common.buildUrlParams(params, common.getWebSocketUrl(`${baseURL}/ws`), "comma");
|
|
299
334
|
};
|
|
@@ -331,6 +366,15 @@ var getFileUrl = (params, baseUrl, url) => {
|
|
|
331
366
|
};
|
|
332
367
|
return common.buildUrlParams(data, url || `${baseUrl}/files/access`);
|
|
333
368
|
};
|
|
369
|
+
var formatFileSize = (size = 0) => {
|
|
370
|
+
if (size < 1024) return `${size} B`;
|
|
371
|
+
const kb = size / 1024;
|
|
372
|
+
if (kb < 1024) return `${kb.toFixed(2)} KB`;
|
|
373
|
+
const mb = kb / 1024;
|
|
374
|
+
if (mb < 1024) return `${mb.toFixed(2)} MB`;
|
|
375
|
+
const gb = mb / 1024;
|
|
376
|
+
return `${gb.toFixed(2)} GB`;
|
|
377
|
+
};
|
|
334
378
|
function GroupPicker({
|
|
335
379
|
groups,
|
|
336
380
|
selectedIndex,
|
|
@@ -401,6 +445,13 @@ function formatResourceName(resourceName) {
|
|
|
401
445
|
if (name.length <= 6) return `${name}${extension}`;
|
|
402
446
|
return `${name.slice(0, 3)}***${name.slice(-3)}${extension}`;
|
|
403
447
|
}
|
|
448
|
+
function ReadonlyResourceTag({ resource }) {
|
|
449
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default.resourceTag, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Tag, { color: "blue", children: [
|
|
450
|
+
resource.resourceLabel,
|
|
451
|
+
"\uFF1A",
|
|
452
|
+
formatResourceName(resource.resourceName)
|
|
453
|
+
] }) });
|
|
454
|
+
}
|
|
404
455
|
function ResourceTag({ resource }) {
|
|
405
456
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
406
457
|
const handleClose = (event) => {
|
|
@@ -488,7 +539,7 @@ var VariableNode = class _VariableNode extends lexical.DecoratorNode {
|
|
|
488
539
|
* 生成节点的纯文本表达,便于发送、存储和重新初始化编辑器内容。
|
|
489
540
|
*/
|
|
490
541
|
getTextContent() {
|
|
491
|
-
return
|
|
542
|
+
return ` ${this.__resourceType}://${this.__resourceId}?name=${this.__resourceName}&label=${this.__resourceLabel} `;
|
|
492
543
|
}
|
|
493
544
|
/**
|
|
494
545
|
* 将变量节点渲染为可交互的资源标签组件。
|
|
@@ -556,6 +607,7 @@ function VariablePickerPlugin({ commandConfig = {} }) {
|
|
|
556
607
|
React10.useEffect(() => {
|
|
557
608
|
setCommandDataSource(commandConfig);
|
|
558
609
|
}, [commandConfig]);
|
|
610
|
+
const commandKeys = React10.useMemo(() => Object.keys(commandConfig), [commandConfig]);
|
|
559
611
|
const commandKey = queryString?.[0] || "";
|
|
560
612
|
const searchKeyword = queryString?.slice(commandKey.length).trim().toLocaleLowerCase() || "";
|
|
561
613
|
const categoryConfig = React10.useMemo(
|
|
@@ -668,15 +720,15 @@ function VariablePickerPlugin({ commandConfig = {} }) {
|
|
|
668
720
|
onQueryChange: (query) => setQueryString(query),
|
|
669
721
|
onSelectOption,
|
|
670
722
|
triggerFn: (text) => {
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
).exec(text);
|
|
723
|
+
if (!commandKeys.length) return null;
|
|
724
|
+
const match = new RegExp(`(?:${commandKeys.map((key) => key.replace(/[.*+?^${}()|[\\]\\]/g, "\\$&")).join("|")})([^\\s]*)$`).exec(text);
|
|
674
725
|
if (!match) return null;
|
|
675
726
|
return { leadOffset: match.index, matchingString: match[0], replaceableString: match[0] };
|
|
676
727
|
},
|
|
677
728
|
options: commandOptions,
|
|
678
729
|
menuRenderFn: (anchorElementRef, { selectedIndex, setHighlightedIndex, selectOptionAndCleanUp }) => {
|
|
679
|
-
if (!isEditorFocused || !anchorElementRef.current ||
|
|
730
|
+
if (!isEditorFocused || !anchorElementRef.current || !commandKeys.length || !commandGroups.length && !searchKeyword) return null;
|
|
731
|
+
if (searchKeyword && !commandGroups.length) return null;
|
|
680
732
|
return ReactDOM__namespace.createPortal(
|
|
681
733
|
/* @__PURE__ */ jsxRuntime.jsx(ResourcePickerMenu, { anchorElementRef, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
682
734
|
GroupPicker,
|
|
@@ -1006,7 +1058,8 @@ var defaultLayout = {
|
|
|
1006
1058
|
messageList: true,
|
|
1007
1059
|
senderHeader: false,
|
|
1008
1060
|
senderFooter: false,
|
|
1009
|
-
disclaimerNotice: true
|
|
1061
|
+
disclaimerNotice: true,
|
|
1062
|
+
userInput: false
|
|
1010
1063
|
};
|
|
1011
1064
|
function createChatStore() {
|
|
1012
1065
|
const config = valtio.proxy({
|
|
@@ -1119,6 +1172,17 @@ function createChatStore() {
|
|
|
1119
1172
|
agent.model = { ...agent.model, ...model };
|
|
1120
1173
|
config.hooks?.onAfterSwitchModel?.(model);
|
|
1121
1174
|
};
|
|
1175
|
+
const getUserInput = async (agentId) => {
|
|
1176
|
+
agent.loading = true;
|
|
1177
|
+
try {
|
|
1178
|
+
const { data } = await config.services.request.getAgentUserInput(agentId);
|
|
1179
|
+
if (data?.inputs && !agent.agentInfo.userInput?.length) {
|
|
1180
|
+
agent.agentInfo.userInput = data.inputs.filter((item) => item.enableEdit);
|
|
1181
|
+
}
|
|
1182
|
+
} finally {
|
|
1183
|
+
agent.loading = false;
|
|
1184
|
+
}
|
|
1185
|
+
};
|
|
1122
1186
|
const setAgent = (agentInfo) => {
|
|
1123
1187
|
agent.agentInfo = agentInfo;
|
|
1124
1188
|
if (agentInfo.agentType === 2 /* AUTONOMOUS */) {
|
|
@@ -1126,6 +1190,13 @@ function createChatStore() {
|
|
|
1126
1190
|
modelName: agent.agentInfo.spec?.model?.modelName || "",
|
|
1127
1191
|
providerName: agent.agentInfo.spec?.model?.providerName || ""
|
|
1128
1192
|
});
|
|
1193
|
+
} else if (config.layout.userInput) {
|
|
1194
|
+
getUserInput(agent.agentInfo.id);
|
|
1195
|
+
}
|
|
1196
|
+
};
|
|
1197
|
+
const setUserInput = (userInput) => {
|
|
1198
|
+
if (agent.agentInfo.agentType === 1 /* FLOW */) {
|
|
1199
|
+
agent.agentInfo.userInput = userInput;
|
|
1129
1200
|
}
|
|
1130
1201
|
};
|
|
1131
1202
|
const getAgentInfo = async (id) => {
|
|
@@ -1252,7 +1323,8 @@ function createChatStore() {
|
|
|
1252
1323
|
/** 当前激活的会话信息 */
|
|
1253
1324
|
active: {
|
|
1254
1325
|
id: "",
|
|
1255
|
-
spec: {}
|
|
1326
|
+
spec: {},
|
|
1327
|
+
userInput: []
|
|
1256
1328
|
},
|
|
1257
1329
|
/** 每个会话的消息存储,以会话ID为键 */
|
|
1258
1330
|
messages: {},
|
|
@@ -1287,6 +1359,9 @@ function createChatStore() {
|
|
|
1287
1359
|
Object.assign(conversation.active.spec, spec);
|
|
1288
1360
|
}
|
|
1289
1361
|
};
|
|
1362
|
+
const setConversationUserInput = (userInput) => {
|
|
1363
|
+
conversation.active.userInput = userInput;
|
|
1364
|
+
};
|
|
1290
1365
|
const feedback = async (executionId, feedback2, index) => {
|
|
1291
1366
|
try {
|
|
1292
1367
|
conversation.feedback.loading = true;
|
|
@@ -1671,9 +1746,9 @@ function createChatStore() {
|
|
|
1671
1746
|
}
|
|
1672
1747
|
}
|
|
1673
1748
|
}
|
|
1674
|
-
function processMessageContent(
|
|
1749
|
+
function processMessageContent(message3) {
|
|
1675
1750
|
const newMessage = {
|
|
1676
|
-
...
|
|
1751
|
+
...message3,
|
|
1677
1752
|
agentId: agent.agentInfo.id
|
|
1678
1753
|
};
|
|
1679
1754
|
const contentList = Array.isArray(newMessage.content) ? newMessage.content : [];
|
|
@@ -1721,14 +1796,14 @@ function createChatStore() {
|
|
|
1721
1796
|
}
|
|
1722
1797
|
processMessageContent(newMessage);
|
|
1723
1798
|
};
|
|
1724
|
-
const sendMessage = async (
|
|
1799
|
+
const sendMessage = async (message3, msgFiles = [], params) => {
|
|
1725
1800
|
const conversationId = conversation.active.id;
|
|
1726
1801
|
if (conversation.messages[conversationId].loading) return;
|
|
1727
1802
|
let msgContent = "", files;
|
|
1728
1803
|
const references = conversation.messages[conversationId].references;
|
|
1729
|
-
if (
|
|
1730
|
-
msgContent =
|
|
1731
|
-
files = msgFiles;
|
|
1804
|
+
if (message3) {
|
|
1805
|
+
msgContent = message3;
|
|
1806
|
+
files = [...msgFiles, ...conversation.messages[conversationId].files || []];
|
|
1732
1807
|
} else {
|
|
1733
1808
|
if (references?.type === 1 && references?.content?.msgContent) {
|
|
1734
1809
|
msgContent = references.content.msgContent + "\n\n";
|
|
@@ -1739,6 +1814,22 @@ function createChatStore() {
|
|
|
1739
1814
|
if (!msgContent) return;
|
|
1740
1815
|
const canProceed = await config.hooks?.onBeforeSend?.(msgContent, files || []);
|
|
1741
1816
|
if (canProceed === false) return;
|
|
1817
|
+
if (conversation.active.userInput?.length) {
|
|
1818
|
+
const invalid = conversation.active.userInput.some((item) => {
|
|
1819
|
+
const isRequired = item.rules?.some((r) => r.type === "required");
|
|
1820
|
+
if (isRequired) {
|
|
1821
|
+
if (item.type === "BOOLEAN") {
|
|
1822
|
+
return common.isNullOrUnDef(item.value);
|
|
1823
|
+
}
|
|
1824
|
+
return common.isNullOrUnDef(item.value) || item.value === "";
|
|
1825
|
+
}
|
|
1826
|
+
return false;
|
|
1827
|
+
});
|
|
1828
|
+
if (invalid) {
|
|
1829
|
+
antd.message.error("\u8BF7\u68C0\u67E5\u8F93\u5165\u53C2\u6570");
|
|
1830
|
+
return;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1742
1833
|
conversation.messages[conversationId].loading = true;
|
|
1743
1834
|
const idx = conversations.list.items.findIndex((item) => item.id === conversationId);
|
|
1744
1835
|
if (idx !== -1 && !conversations.list.items[idx].label) {
|
|
@@ -1757,15 +1848,16 @@ function createChatStore() {
|
|
|
1757
1848
|
responseMode: 2
|
|
1758
1849
|
};
|
|
1759
1850
|
const extraParams = common.deepCopy(config.params?.params || {});
|
|
1760
|
-
|
|
1851
|
+
const userInputParams = variablesToObject(conversation.active.userInput || []);
|
|
1852
|
+
Object.assign(extraParams, message3 ? {} : { ...references?.params }, params, userInputParams);
|
|
1761
1853
|
sendParams.params = extraParams;
|
|
1762
|
-
if (!
|
|
1854
|
+
if (!message3) {
|
|
1763
1855
|
setContent("");
|
|
1764
1856
|
setContentParams();
|
|
1765
|
-
setFileList([]);
|
|
1766
1857
|
setReferences();
|
|
1767
|
-
setHeaderOpen(false);
|
|
1768
1858
|
}
|
|
1859
|
+
setFileList([]);
|
|
1860
|
+
setHeaderOpen(false);
|
|
1769
1861
|
try {
|
|
1770
1862
|
const dealedParams = await config.hooks?.onHandleSendParams?.(sendParams);
|
|
1771
1863
|
await config.services.request.sendMessageStream(dealedParams || sendParams, agent.agentInfo?.id || "");
|
|
@@ -1823,7 +1915,7 @@ function createChatStore() {
|
|
|
1823
1915
|
/** 设置智能体 */
|
|
1824
1916
|
setAgent,
|
|
1825
1917
|
/** 设置智能体用户输入 */
|
|
1826
|
-
|
|
1918
|
+
setUserInput,
|
|
1827
1919
|
/** 设置会话配置 */
|
|
1828
1920
|
setConversationSpec,
|
|
1829
1921
|
/** 历史会话状态 */
|
|
@@ -1857,9 +1949,11 @@ function createChatStore() {
|
|
|
1857
1949
|
/** 接收消息 */
|
|
1858
1950
|
acceptMessage,
|
|
1859
1951
|
/** 获取智能体用户输入 */
|
|
1860
|
-
|
|
1952
|
+
getUserInput,
|
|
1861
1953
|
/** 消息反馈 */
|
|
1862
|
-
feedback
|
|
1954
|
+
feedback,
|
|
1955
|
+
/** 设置会话用户输入 */
|
|
1956
|
+
setConversationUserInput
|
|
1863
1957
|
};
|
|
1864
1958
|
}
|
|
1865
1959
|
var AuthImage = ({ path, size, shape = "square" }) => {
|
|
@@ -1953,6 +2047,7 @@ var styles_module_default2 = {
|
|
|
1953
2047
|
chatWelcome: "styles_module_chatWelcome",
|
|
1954
2048
|
promptItem: "styles_module_promptItem",
|
|
1955
2049
|
bubbleList: "styles_module_bubbleList",
|
|
2050
|
+
userInputCollapse: "styles_module_userInputCollapse",
|
|
1956
2051
|
logoArea: "styles_module_logoArea",
|
|
1957
2052
|
logoContainer: "styles_module_logoContainer",
|
|
1958
2053
|
staticHalo: "styles_module_staticHalo",
|
|
@@ -2686,12 +2781,12 @@ var DocDrawer_default = ({ title, open, onClose, paramsStr }) => {
|
|
|
2686
2781
|
}, [paramsStr]);
|
|
2687
2782
|
return /* @__PURE__ */ jsxRuntime.jsx(antd.Drawer, { title, push: false, size: "100%", open, onClose, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, children: content ? /* @__PURE__ */ jsxRuntime.jsx(XMarkdown__default.default, { content }) : /* @__PURE__ */ jsxRuntime.jsx(antd.Empty, { className: "m-t-32" }) }) });
|
|
2688
2783
|
};
|
|
2689
|
-
var IndexQuote_default = ({ data, loading, message:
|
|
2784
|
+
var IndexQuote_default = ({ data, loading, message: message3 }) => {
|
|
2690
2785
|
const [open, setOpen] = React10.useState(false);
|
|
2691
2786
|
const citation = React10.useMemo(() => {
|
|
2692
|
-
const citations =
|
|
2787
|
+
const citations = message3.content?.find((item) => item.type === "citation")?.citations ?? [];
|
|
2693
2788
|
return citations?.find((item) => String(item.citationId) === String(data.citationId));
|
|
2694
|
-
}, [data.citationId,
|
|
2789
|
+
}, [data.citationId, message3.content]);
|
|
2695
2790
|
const onClick = () => {
|
|
2696
2791
|
if (!citation?.citationUrl) return;
|
|
2697
2792
|
if (common.isExternal(citation.citationUrl)) {
|
|
@@ -2706,7 +2801,7 @@ var IndexQuote_default = ({ data, loading, message: message2 }) => {
|
|
|
2706
2801
|
open && /* @__PURE__ */ jsxRuntime.jsx(DocDrawer_default, { paramsStr: citation?.citationUrl, title: citation?.citationName, open, onClose: () => setOpen(false) })
|
|
2707
2802
|
] });
|
|
2708
2803
|
};
|
|
2709
|
-
var MarkImg_default = ({ data, loading, message:
|
|
2804
|
+
var MarkImg_default = ({ data, loading, message: message3, ...rest }) => {
|
|
2710
2805
|
const getPreviewFileUrl = (src) => {
|
|
2711
2806
|
return common.buildUrlParams({ [TOKEN_KEY]: tokenManager.get() || "" }, src);
|
|
2712
2807
|
};
|
|
@@ -2733,7 +2828,7 @@ var MdEdit_default = ({ data, loading }) => {
|
|
|
2733
2828
|
!loading && /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { justify: "end", className: "m-t-16", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { color: "primary", variant: "outlined", onClick: onOk, children: btnText }) })
|
|
2734
2829
|
] });
|
|
2735
2830
|
};
|
|
2736
|
-
var PreviewLink_default = ({ data, loading, message:
|
|
2831
|
+
var PreviewLink_default = ({ data, loading, message: message3, ...rest }) => {
|
|
2737
2832
|
const chatStore = useChatStore();
|
|
2738
2833
|
const getLinkFileName = (href) => {
|
|
2739
2834
|
const url = new URL(href, window.location.origin);
|
|
@@ -2766,7 +2861,7 @@ var PreviewLink_default = ({ data, loading, message: message2, ...rest }) => {
|
|
|
2766
2861
|
chatStore.setPreview({
|
|
2767
2862
|
fileUrl: chatStore.config.services.request.getPreviewUrl({
|
|
2768
2863
|
path: href,
|
|
2769
|
-
workspaceId:
|
|
2864
|
+
workspaceId: message3.conversationId
|
|
2770
2865
|
}),
|
|
2771
2866
|
fileName,
|
|
2772
2867
|
suffix
|
|
@@ -2873,7 +2968,7 @@ var adaptMarkdownComponent = (Component, payloadMapRef, messageRef) => {
|
|
|
2873
2968
|
return WrappedComponent;
|
|
2874
2969
|
};
|
|
2875
2970
|
var adaptMarkdownComponents = (components, payloadMapRef, messageRef) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component, payloadMapRef, messageRef)]));
|
|
2876
|
-
var XMarkdown_default = React10.memo(({ message:
|
|
2971
|
+
var XMarkdown_default = React10.memo(({ message: message3, components = {}, content = "", ...rest }) => {
|
|
2877
2972
|
const config = React10.useMemo(() => getMarkdownConfig(), []);
|
|
2878
2973
|
const formattedContent = React10.useMemo(() => formatMixedContent(content), [content]);
|
|
2879
2974
|
const newComponents = React10.useMemo(
|
|
@@ -2899,9 +2994,9 @@ var XMarkdown_default = React10.memo(({ message: message2, components = {}, cont
|
|
|
2899
2994
|
[formattedContent, payloadTagPattern]
|
|
2900
2995
|
);
|
|
2901
2996
|
const payloadMapRef = React10.useRef(payloadMap);
|
|
2902
|
-
const messageRef = React10.useRef(
|
|
2997
|
+
const messageRef = React10.useRef(message3);
|
|
2903
2998
|
payloadMapRef.current = payloadMap;
|
|
2904
|
-
messageRef.current =
|
|
2999
|
+
messageRef.current = message3;
|
|
2905
3000
|
const markdownComponents = React10.useMemo(() => adaptMarkdownComponents(newComponents, payloadMapRef, messageRef), [payloadTagPattern]);
|
|
2906
3001
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2907
3002
|
XMarkdown__default.default,
|
|
@@ -3354,9 +3449,9 @@ function splitA2uiTextSegments(text) {
|
|
|
3354
3449
|
}
|
|
3355
3450
|
return segments.length ? segments : [];
|
|
3356
3451
|
}
|
|
3357
|
-
function extractInlineSurfaceIdsFromMessage(
|
|
3452
|
+
function extractInlineSurfaceIdsFromMessage(message3) {
|
|
3358
3453
|
const surfaceIds = /* @__PURE__ */ new Set();
|
|
3359
|
-
const items = Array.isArray(
|
|
3454
|
+
const items = Array.isArray(message3?.content) ? message3.content : [];
|
|
3360
3455
|
for (const item of items) {
|
|
3361
3456
|
if (item?.type !== "text") continue;
|
|
3362
3457
|
const text = item.messageContent || item.text || "";
|
|
@@ -3375,10 +3470,10 @@ function extractDismissedSurfaceIdsFromMessages(messages) {
|
|
|
3375
3470
|
const lastCreateIndexBySurface = /* @__PURE__ */ new Map();
|
|
3376
3471
|
const lastActionIndexBySurface = /* @__PURE__ */ new Map();
|
|
3377
3472
|
for (let messageIndex = 0; messageIndex < messages.length; messageIndex++) {
|
|
3378
|
-
const
|
|
3379
|
-
const items = Array.isArray(
|
|
3473
|
+
const message3 = messages[messageIndex];
|
|
3474
|
+
const items = Array.isArray(message3?.content) ? message3.content : [];
|
|
3380
3475
|
for (const item of items) {
|
|
3381
|
-
if (
|
|
3476
|
+
if (message3?.role !== 1) {
|
|
3382
3477
|
if (item?.type === "a2uiCommand" && item.command) {
|
|
3383
3478
|
const surfaceId = String(item.command?.createSurface?.surfaceId || "").trim();
|
|
3384
3479
|
if (surfaceId) lastCreateIndexBySurface.set(surfaceId, messageIndex);
|
|
@@ -3396,7 +3491,7 @@ function extractDismissedSurfaceIdsFromMessages(messages) {
|
|
|
3396
3491
|
}
|
|
3397
3492
|
}
|
|
3398
3493
|
}
|
|
3399
|
-
if (
|
|
3494
|
+
if (message3?.role === 1 && item?.type === "text") {
|
|
3400
3495
|
const text = item.messageContent || item.text || "";
|
|
3401
3496
|
if (typeof text !== "string" || !text.includes("a2ui_action.v1")) continue;
|
|
3402
3497
|
try {
|
|
@@ -3925,9 +4020,9 @@ function diffConversationMessages(messages, prevCursors) {
|
|
|
3925
4020
|
const nextCursors = [];
|
|
3926
4021
|
const pendingItems = [];
|
|
3927
4022
|
for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
|
|
3928
|
-
const
|
|
3929
|
-
const messageId = String(
|
|
3930
|
-
const items = Array.isArray(
|
|
4023
|
+
const message3 = messages[messageIndex];
|
|
4024
|
+
const messageId = String(message3?.messageId ?? messageIndex);
|
|
4025
|
+
const items = Array.isArray(message3?.content) ? message3.content : [];
|
|
3931
4026
|
const prevCursor = prevCursors[messageIndex];
|
|
3932
4027
|
const startIndex = prevCursor ? prevCursor.contentLength : 0;
|
|
3933
4028
|
if (prevCursor && (prevCursor.messageId !== messageId || items.length < prevCursor.contentLength)) {
|
|
@@ -3989,9 +4084,9 @@ function scanA2uiTagsFromMessages(messages, processedTagIds) {
|
|
|
3989
4084
|
const newTags = [];
|
|
3990
4085
|
const newTagIds = [];
|
|
3991
4086
|
for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
|
|
3992
|
-
const
|
|
3993
|
-
const messageId = String(
|
|
3994
|
-
const items = Array.isArray(
|
|
4087
|
+
const message3 = messages[messageIndex];
|
|
4088
|
+
const messageId = String(message3?.messageId ?? messageIndex);
|
|
4089
|
+
const items = Array.isArray(message3?.content) ? message3.content : [];
|
|
3995
4090
|
for (const item of items) {
|
|
3996
4091
|
if (item?.type !== "text") continue;
|
|
3997
4092
|
const text = item.messageContent || item.text || "";
|
|
@@ -4009,9 +4104,9 @@ function scanA2uiTagsFromMessages(messages, processedTagIds) {
|
|
|
4009
4104
|
}
|
|
4010
4105
|
function reduceA2uiRuntimeMessages(state, messages) {
|
|
4011
4106
|
const { shouldReplayAll, pendingItems, nextCursors } = diffConversationMessages(messages || [], state.processedMessageCursors);
|
|
4012
|
-
const itemsToProcess = shouldReplayAll ? messages.flatMap((
|
|
4013
|
-
const messageId = String(
|
|
4014
|
-
const items = Array.isArray(
|
|
4107
|
+
const itemsToProcess = shouldReplayAll ? messages.flatMap((message3, messageIndex) => {
|
|
4108
|
+
const messageId = String(message3?.messageId ?? messageIndex);
|
|
4109
|
+
const items = Array.isArray(message3?.content) ? message3.content : [];
|
|
4015
4110
|
return items.map((item) => ({ messageIndex, messageId, item }));
|
|
4016
4111
|
}) : pendingItems;
|
|
4017
4112
|
const tagProcessedSet = new Set(shouldReplayAll ? [] : state.processedTagIds);
|
|
@@ -4053,9 +4148,9 @@ function reduceA2uiRuntimeMessages(state, messages) {
|
|
|
4053
4148
|
processA2uiCommand(cmd, messageIndex, messageId, nextState, effects, deletedSurfaceIds, nextWizardSteps);
|
|
4054
4149
|
}
|
|
4055
4150
|
});
|
|
4056
|
-
nextState.processedMessageCursors = shouldReplayAll ? messages.map((
|
|
4057
|
-
messageId: String(
|
|
4058
|
-
contentLength: Array.isArray(
|
|
4151
|
+
nextState.processedMessageCursors = shouldReplayAll ? messages.map((message3, messageIndex) => ({
|
|
4152
|
+
messageId: String(message3?.messageId ?? messageIndex),
|
|
4153
|
+
contentLength: Array.isArray(message3?.content) ? message3.content.length : 0
|
|
4059
4154
|
})) : nextCursors;
|
|
4060
4155
|
nextState.wizardStepBySurface = { ...nextState.wizardStepBySurface, ...nextWizardSteps };
|
|
4061
4156
|
if (deletedSurfaceIds.size) {
|
|
@@ -4204,10 +4299,10 @@ var A2uiRuntimeContext = React10__namespace.default.createContext({
|
|
|
4204
4299
|
function useA2uiRuntimeView() {
|
|
4205
4300
|
return React10__namespace.default.useContext(A2uiRuntimeContext);
|
|
4206
4301
|
}
|
|
4207
|
-
function A2uiMessageCards({ messageIndex, message:
|
|
4302
|
+
function A2uiMessageCards({ messageIndex, message: message3 }) {
|
|
4208
4303
|
const { surfaceIdsByMessageIndex } = useA2uiRuntimeView();
|
|
4209
4304
|
const allSurfaceIds = surfaceIdsByMessageIndex[messageIndex] || [];
|
|
4210
|
-
const inlineSurfaceIds =
|
|
4305
|
+
const inlineSurfaceIds = message3 ? extractInlineSurfaceIdsFromMessage(message3) : /* @__PURE__ */ new Set();
|
|
4211
4306
|
const surfaceIds = allSurfaceIds.filter((id) => !inlineSurfaceIds.has(id));
|
|
4212
4307
|
if (!surfaceIds.length) return null;
|
|
4213
4308
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: surfaceIds.map((surfaceId) => /* @__PURE__ */ jsxRuntime.jsx(XCard.Card, { id: surfaceId }, surfaceId)) });
|
|
@@ -4405,8 +4500,8 @@ function readContextModelPath(context) {
|
|
|
4405
4500
|
function buildLatestCommandIndexBySurface(messages) {
|
|
4406
4501
|
const indexBySurface = {};
|
|
4407
4502
|
let commandIndex = -1;
|
|
4408
|
-
for (const
|
|
4409
|
-
const items = Array.isArray(
|
|
4503
|
+
for (const message3 of messages) {
|
|
4504
|
+
const items = Array.isArray(message3?.content) ? message3.content : [];
|
|
4410
4505
|
for (const item of items) {
|
|
4411
4506
|
if (item?.type === "a2uiCommand" && item.command) {
|
|
4412
4507
|
commandIndex += 1;
|
|
@@ -4562,6 +4657,8 @@ var RunStartedNode = React10__namespace.default.memo(({ loading }) => {
|
|
|
4562
4657
|
if (!loading) return null;
|
|
4563
4658
|
return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { gap: 8, align: "center", className: style_module_default2.runStartedNode, children: /* @__PURE__ */ jsxRuntime.jsx(icons.LoadingOutlined, { style: { color: "#1677ff" } }) });
|
|
4564
4659
|
});
|
|
4660
|
+
var RESOURCE_MARKDOWN_TAG = "resourcetag";
|
|
4661
|
+
var RESOURCE_TOKEN_REGEX = /(\w+):\/\/([^?\s]+)\?name=([^&\s]+)&label=([^\s]+)/g;
|
|
4565
4662
|
function QuestionSummary({ content }) {
|
|
4566
4663
|
const answer = content.replace(/^Question:\s*/, "").trim() || "\u5DF2\u56DE\u7B54";
|
|
4567
4664
|
return /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { display: "inline-flex", flexDirection: "column", gap: 4 }, children: [
|
|
@@ -4569,17 +4666,37 @@ function QuestionSummary({ content }) {
|
|
|
4569
4666
|
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 13, color: "#262626", lineHeight: 1.6, whiteSpace: "pre-wrap" }, children: answer })
|
|
4570
4667
|
] });
|
|
4571
4668
|
}
|
|
4669
|
+
function MessageResourceTag({ data }) {
|
|
4670
|
+
const resource = data;
|
|
4671
|
+
if (!resource) return null;
|
|
4672
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ReadonlyResourceTag, { resource });
|
|
4673
|
+
}
|
|
4674
|
+
function transformResourceText(content) {
|
|
4675
|
+
return content.replace(RESOURCE_TOKEN_REGEX, (_, resourceType, resourceId, resourceName, resourceLabel) => {
|
|
4676
|
+
const resource = {
|
|
4677
|
+
resourceType: decodeURIComponent(resourceType),
|
|
4678
|
+
resourceId: decodeURIComponent(resourceId),
|
|
4679
|
+
resourceName: decodeURIComponent(resourceName),
|
|
4680
|
+
resourceLabel: decodeURIComponent(resourceLabel)
|
|
4681
|
+
};
|
|
4682
|
+
return `<${RESOURCE_MARKDOWN_TAG}>${JSON.stringify(resource)}</${RESOURCE_MARKDOWN_TAG}>`;
|
|
4683
|
+
});
|
|
4684
|
+
}
|
|
4572
4685
|
var TextNode2 = React10__namespace.default.memo(
|
|
4573
4686
|
({
|
|
4574
4687
|
item,
|
|
4575
4688
|
role,
|
|
4576
4689
|
customComponents,
|
|
4577
|
-
message:
|
|
4690
|
+
message: message3,
|
|
4578
4691
|
messageIndex = -1
|
|
4579
4692
|
}) => {
|
|
4580
4693
|
const { surfaceIdsByMessageIndex } = useA2uiRuntimeView();
|
|
4581
4694
|
const rawContent = toA2uiDisplayText(role, item?.messageContent);
|
|
4582
4695
|
const segments = splitA2uiTextSegments(rawContent);
|
|
4696
|
+
const markdownComponents = {
|
|
4697
|
+
[RESOURCE_MARKDOWN_TAG]: MessageResourceTag,
|
|
4698
|
+
...customComponents
|
|
4699
|
+
};
|
|
4583
4700
|
const visibleSurfaceIds = messageIndex >= 0 ? new Set(surfaceIdsByMessageIndex[messageIndex] || []) : null;
|
|
4584
4701
|
const firstSeg = segments[0];
|
|
4585
4702
|
const isPureText = segments.length === 0 || segments.length === 1 && firstSeg.type === "text";
|
|
@@ -4588,16 +4705,18 @@ var TextNode2 = React10__namespace.default.memo(
|
|
|
4588
4705
|
if (typeof content === "string" && content.startsWith("Question:")) {
|
|
4589
4706
|
return /* @__PURE__ */ jsxRuntime.jsx(QuestionSummary, { content });
|
|
4590
4707
|
}
|
|
4708
|
+
const markdownContent = typeof content === "string" ? transformResourceText(content) : content;
|
|
4591
4709
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4592
4710
|
!!item.reasoningContent && /* @__PURE__ */ jsxRuntime.jsx(xV2.Think, { title: "\u6DF1\u5EA6\u601D\u8003", children: item.reasoningContent }),
|
|
4593
|
-
!!
|
|
4711
|
+
!!markdownContent && /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message3, components: markdownComponents, content: markdownContent })
|
|
4594
4712
|
] });
|
|
4595
4713
|
}
|
|
4596
4714
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4597
4715
|
!!item.reasoningContent && /* @__PURE__ */ jsxRuntime.jsx(xV2.Think, { title: "\u6DF1\u5EA6\u601D\u8003", children: item.reasoningContent }),
|
|
4598
4716
|
segments.map((seg, i) => {
|
|
4599
4717
|
if (seg.type === "text") {
|
|
4600
|
-
|
|
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;
|
|
4601
4720
|
}
|
|
4602
4721
|
return seg.surfaceIds.filter((sid) => !visibleSurfaceIds || visibleSurfaceIds.has(sid)).map((sid) => /* @__PURE__ */ jsxRuntime.jsx(XCard.Card, { id: sid }, `a2ui-${i}-${sid}`));
|
|
4603
4722
|
})
|
|
@@ -4816,9 +4935,9 @@ var ToolCallItem = ({ item }) => {
|
|
|
4816
4935
|
};
|
|
4817
4936
|
var tool_call_item_default = ToolCallItem;
|
|
4818
4937
|
var RENDERABLE_MESSAGE_TYPES = ["runStarted", "toolCall", "toolResult", "text", "stepError", "files", "plan"];
|
|
4819
|
-
var MessageRender_default = React10__namespace.default.memo(({ role, message:
|
|
4938
|
+
var MessageRender_default = React10__namespace.default.memo(({ role, message: message3, messageIndex = -1, loading, containerRef, customComponents }) => {
|
|
4820
4939
|
const content = React10.useMemo(() => {
|
|
4821
|
-
return (
|
|
4940
|
+
return (message3.content || []).filter((item) => {
|
|
4822
4941
|
if (!RENDERABLE_MESSAGE_TYPES.includes(item.type)) {
|
|
4823
4942
|
return false;
|
|
4824
4943
|
}
|
|
@@ -4836,12 +4955,12 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
|
|
|
4836
4955
|
}
|
|
4837
4956
|
return true;
|
|
4838
4957
|
});
|
|
4839
|
-
}, [loading,
|
|
4958
|
+
}, [loading, message3.content]);
|
|
4840
4959
|
const quoteMsg = React10.useMemo(() => {
|
|
4841
4960
|
const quoteMsg2 = {};
|
|
4842
|
-
if (
|
|
4961
|
+
if (message3.params) {
|
|
4843
4962
|
try {
|
|
4844
|
-
const citation = JSON.parse(
|
|
4963
|
+
const citation = JSON.parse(message3.params).citation;
|
|
4845
4964
|
if (citation) {
|
|
4846
4965
|
quoteMsg2.messageContent = citation;
|
|
4847
4966
|
}
|
|
@@ -4849,7 +4968,7 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
|
|
|
4849
4968
|
}
|
|
4850
4969
|
}
|
|
4851
4970
|
return common.isEmptyObj(quoteMsg2) ? null : quoteMsg2;
|
|
4852
|
-
}, [
|
|
4971
|
+
}, [message3.params, message3.quoteMsg]);
|
|
4853
4972
|
if (content.length === 0) return null;
|
|
4854
4973
|
return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { ref: containerRef, vertical: true, gap: 8, children: [
|
|
4855
4974
|
content.map((item, index) => {
|
|
@@ -4862,8 +4981,8 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
|
|
|
4862
4981
|
content: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4863
4982
|
item.type === "runStarted" && /* @__PURE__ */ jsxRuntime.jsx(RunStartedNode, { loading }, `flow-start-${index}`),
|
|
4864
4983
|
(item.type === "toolCall" || item.type === "toolResult") && /* @__PURE__ */ jsxRuntime.jsx(tool_call_item_default, { item }, `tool-call-${item.toolCallId || index}`),
|
|
4865
|
-
item.type === "text" && /* @__PURE__ */ jsxRuntime.jsx(TextNode2, { item, role:
|
|
4866
|
-
item.type === "stepError" && (item.errorMessage ? /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message:
|
|
4984
|
+
item.type === "text" && /* @__PURE__ */ jsxRuntime.jsx(TextNode2, { item, role: message3.role, customComponents, message: message3, messageIndex }, `message-${index}`),
|
|
4985
|
+
item.type === "stepError" && (item.errorMessage ? /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message3, components: customComponents, content: item.errorMessage }) : null),
|
|
4867
4986
|
item.type === "files" && /* @__PURE__ */ jsxRuntime.jsx(FilesNode, { item }, `files-${index}`),
|
|
4868
4987
|
item.type === "plan" && /* @__PURE__ */ jsxRuntime.jsx(A2uiPlanNode, { item }, `plan-${index}`)
|
|
4869
4988
|
] })
|
|
@@ -4872,7 +4991,7 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
|
|
|
4872
4991
|
);
|
|
4873
4992
|
}),
|
|
4874
4993
|
quoteMsg && /* @__PURE__ */ jsxRuntime.jsx(QuoteMsgNode, { quoteMsg, role }),
|
|
4875
|
-
messageIndex >= 0 ? /* @__PURE__ */ jsxRuntime.jsx(A2uiMessageCards, { messageIndex, message:
|
|
4994
|
+
messageIndex >= 0 ? /* @__PURE__ */ jsxRuntime.jsx(A2uiMessageCards, { messageIndex, message: message3 }) : null
|
|
4876
4995
|
] });
|
|
4877
4996
|
});
|
|
4878
4997
|
var WelcomeItem_default = ({ icon = true, title = true, description = true, prompts = true }) => {
|
|
@@ -4965,13 +5084,13 @@ var BubbleListItems_default = ({
|
|
|
4965
5084
|
const messageRefs = React10.useRef({});
|
|
4966
5085
|
const chatRecords = React10.useMemo(() => {
|
|
4967
5086
|
const chatRecords2 = [];
|
|
4968
|
-
conversationMessages.forEach((
|
|
4969
|
-
const role = getRole(
|
|
5087
|
+
conversationMessages.forEach((message3, messageIndex) => {
|
|
5088
|
+
const role = getRole(message3.role);
|
|
4970
5089
|
const isLeftBubble = role.user === "agent";
|
|
4971
|
-
const isMessageLoading = !!
|
|
4972
|
-
const baseKey = `${
|
|
5090
|
+
const isMessageLoading = !!message3.generating;
|
|
5091
|
+
const baseKey = `${message3.executionId}-${messageIndex}`;
|
|
4973
5092
|
const footerNode = !isMessageLoading ? /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", gap: 8, children: [
|
|
4974
|
-
|
|
5093
|
+
message3.stopFlag && isLeftBubble && /* @__PURE__ */ jsxRuntime.jsx(Text3, { type: "secondary", style: { flex: "none" }, children: "\u5DF2\u505C\u6B62" }),
|
|
4975
5094
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { align: "center", gap: 4, children: role.user === "agent" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4976
5095
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4977
5096
|
antd.Button,
|
|
@@ -4991,21 +5110,21 @@ var BubbleListItems_default = ({
|
|
|
4991
5110
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4992
5111
|
antd.Button,
|
|
4993
5112
|
{
|
|
4994
|
-
color:
|
|
5113
|
+
color: message3.feedback === 1 ? "primary" : "default",
|
|
4995
5114
|
size: "small",
|
|
4996
5115
|
variant: "text",
|
|
4997
5116
|
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.LikeOutlined, {}),
|
|
4998
|
-
onClick: () => chatStore.feedback(
|
|
5117
|
+
onClick: () => chatStore.feedback(message3.executionId, 1, messageIndex)
|
|
4999
5118
|
}
|
|
5000
5119
|
),
|
|
5001
5120
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5002
5121
|
antd.Button,
|
|
5003
5122
|
{
|
|
5004
|
-
color:
|
|
5123
|
+
color: message3.feedback === 2 ? "primary" : "default",
|
|
5005
5124
|
size: "small",
|
|
5006
5125
|
variant: "text",
|
|
5007
5126
|
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.DislikeOutlined, {}),
|
|
5008
|
-
onClick: () => chatStore.feedback(
|
|
5127
|
+
onClick: () => chatStore.feedback(message3.executionId, 2, messageIndex)
|
|
5009
5128
|
}
|
|
5010
5129
|
),
|
|
5011
5130
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5013,7 +5132,7 @@ var BubbleListItems_default = ({
|
|
|
5013
5132
|
{
|
|
5014
5133
|
control: agentActions,
|
|
5015
5134
|
ctx: {
|
|
5016
|
-
message:
|
|
5135
|
+
message: message3,
|
|
5017
5136
|
get dom() {
|
|
5018
5137
|
return messageRefs.current[baseKey];
|
|
5019
5138
|
}
|
|
@@ -5031,7 +5150,7 @@ var BubbleListItems_default = ({
|
|
|
5031
5150
|
MessageRender_default,
|
|
5032
5151
|
{
|
|
5033
5152
|
role,
|
|
5034
|
-
message:
|
|
5153
|
+
message: message3,
|
|
5035
5154
|
messageIndex,
|
|
5036
5155
|
customComponents,
|
|
5037
5156
|
loading: isMessageLoading,
|
|
@@ -5610,6 +5729,313 @@ var ChatSenderHeader = () => {
|
|
|
5610
5729
|
] });
|
|
5611
5730
|
};
|
|
5612
5731
|
var ChatSenderHeader_default = ChatSenderHeader;
|
|
5732
|
+
var MonacoEditor = ({ value = "", onChange, placeholder, height = 200, readOnly = false, style }) => {
|
|
5733
|
+
const handleKeyDownCapture = React10.useCallback((e) => {
|
|
5734
|
+
if (e.key === " " || e.code === "Space") {
|
|
5735
|
+
e.stopPropagation();
|
|
5736
|
+
}
|
|
5737
|
+
}, []);
|
|
5738
|
+
const handleKeyUpCapture = React10.useCallback((e) => {
|
|
5739
|
+
if (e.key === " " || e.code === "Space") {
|
|
5740
|
+
e.stopPropagation();
|
|
5741
|
+
}
|
|
5742
|
+
}, []);
|
|
5743
|
+
const handleScriptChange = React10.useCallback(
|
|
5744
|
+
(event) => {
|
|
5745
|
+
onChange?.(event.target.value || "");
|
|
5746
|
+
},
|
|
5747
|
+
[onChange]
|
|
5748
|
+
);
|
|
5749
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { style, onKeyDownCapture: handleKeyDownCapture, onKeyUpCapture: handleKeyUpCapture, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5750
|
+
antd.Input.TextArea,
|
|
5751
|
+
{
|
|
5752
|
+
value,
|
|
5753
|
+
onChange: handleScriptChange,
|
|
5754
|
+
readOnly,
|
|
5755
|
+
placeholder,
|
|
5756
|
+
autoSize: false,
|
|
5757
|
+
style: {
|
|
5758
|
+
height,
|
|
5759
|
+
resize: "vertical",
|
|
5760
|
+
fontFamily: 'Monaco, Menlo, Consolas, "Courier New", monospace',
|
|
5761
|
+
...style
|
|
5762
|
+
}
|
|
5763
|
+
}
|
|
5764
|
+
) });
|
|
5765
|
+
};
|
|
5766
|
+
var MonacoEditor_default = MonacoEditor;
|
|
5767
|
+
var { Text: Text8 } = antd.Typography;
|
|
5768
|
+
var FormFileUpload = ({ value, onChange, multiple = false }) => {
|
|
5769
|
+
const { token } = antd.theme.useToken();
|
|
5770
|
+
const fileList = Array.isArray(value) ? value : value ? [value] : [];
|
|
5771
|
+
const chatStore = useChatStore();
|
|
5772
|
+
const conversationState = valtio.useSnapshot(chatStore.conversation);
|
|
5773
|
+
const agentState = valtio.useSnapshot(chatStore.agent);
|
|
5774
|
+
const configState = valtio.useSnapshot(chatStore.config);
|
|
5775
|
+
const customRequest = async (options) => {
|
|
5776
|
+
const { file, onSuccess, onError } = options;
|
|
5777
|
+
try {
|
|
5778
|
+
const formData = new FormData();
|
|
5779
|
+
formData.append("file", file);
|
|
5780
|
+
const params = {
|
|
5781
|
+
workspaceType: "conversation" /* CONVERSATION */,
|
|
5782
|
+
agentId: agentState.agentInfo.id,
|
|
5783
|
+
workspaceId: conversationState.active.id
|
|
5784
|
+
};
|
|
5785
|
+
const res = await configState.services.request.chatUpload(params, formData);
|
|
5786
|
+
if (res.code === 200 && res.data?.length) {
|
|
5787
|
+
const uploadedFile = res.data[0];
|
|
5788
|
+
onSuccess(uploadedFile);
|
|
5789
|
+
if (multiple) {
|
|
5790
|
+
onChange?.([...fileList, uploadedFile]);
|
|
5791
|
+
} else {
|
|
5792
|
+
onChange?.([uploadedFile]);
|
|
5793
|
+
}
|
|
5794
|
+
} else {
|
|
5795
|
+
antd.message.error(res.message || "\u4E0A\u4F20\u5931\u8D25");
|
|
5796
|
+
onError(new Error(res.message));
|
|
5797
|
+
}
|
|
5798
|
+
} catch (error) {
|
|
5799
|
+
onError(error);
|
|
5800
|
+
}
|
|
5801
|
+
};
|
|
5802
|
+
const handleRemove = (fileToRemove) => {
|
|
5803
|
+
const newList = fileList.filter((f) => f.id !== fileToRemove.id);
|
|
5804
|
+
onChange?.(newList.length > 0 ? newList : void 0);
|
|
5805
|
+
};
|
|
5806
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, gap: 12, style: { width: "100%" }, children: [
|
|
5807
|
+
!multiple && fileList.length >= 1 ? null : /* @__PURE__ */ jsxRuntime.jsx(antd.Upload, { multiple, customRequest, showUploadList: false, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CloudUploadOutlined, {}), children: "\u4ECE\u672C\u5730\u4E0A\u4F20" }) }),
|
|
5808
|
+
fileList.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, gap: 8, children: fileList.map((file) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5809
|
+
antd.Flex,
|
|
5810
|
+
{
|
|
5811
|
+
align: "center",
|
|
5812
|
+
justify: "space-between",
|
|
5813
|
+
style: {
|
|
5814
|
+
padding: "8px 12px",
|
|
5815
|
+
backgroundColor: token.colorFillAlter,
|
|
5816
|
+
borderRadius: token.borderRadiusLG || 8,
|
|
5817
|
+
border: `1px solid ${token.colorBorderSecondary}`
|
|
5818
|
+
},
|
|
5819
|
+
children: [
|
|
5820
|
+
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", gap: 12, style: { overflow: "hidden", flex: 1 }, children: [
|
|
5821
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5822
|
+
"div",
|
|
5823
|
+
{
|
|
5824
|
+
style: {
|
|
5825
|
+
width: 40,
|
|
5826
|
+
height: 40,
|
|
5827
|
+
backgroundColor: "#000",
|
|
5828
|
+
borderRadius: token.borderRadiusSM || 4,
|
|
5829
|
+
display: "flex",
|
|
5830
|
+
alignItems: "center",
|
|
5831
|
+
justifyContent: "center",
|
|
5832
|
+
flexShrink: 0
|
|
5833
|
+
},
|
|
5834
|
+
children: getFileIcon(file.extension || common.getFileSuffixName(file.name), 20)
|
|
5835
|
+
}
|
|
5836
|
+
),
|
|
5837
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { overflow: "hidden", display: "flex", flexDirection: "column", flex: 1 }, children: [
|
|
5838
|
+
/* @__PURE__ */ jsxRuntime.jsx(Text8, { ellipsis: true, style: { width: "100%", fontSize: 14, fontWeight: 500 }, children: file.name }),
|
|
5839
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Text8, { type: "secondary", style: { fontSize: 12 }, children: [
|
|
5840
|
+
(file.extension || common.getFileSuffixName(file.name)).toUpperCase(),
|
|
5841
|
+
" \u2022 ",
|
|
5842
|
+
formatFileSize(file.size)
|
|
5843
|
+
] })
|
|
5844
|
+
] })
|
|
5845
|
+
] }),
|
|
5846
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.DeleteOutlined, {}), onClick: () => handleRemove(file), style: { color: token.colorTextSecondary } })
|
|
5847
|
+
]
|
|
5848
|
+
},
|
|
5849
|
+
file.id || file.uid
|
|
5850
|
+
)) })
|
|
5851
|
+
] });
|
|
5852
|
+
};
|
|
5853
|
+
var FormMonacoEditor = ({ value, onChange }) => {
|
|
5854
|
+
const { token } = antd.theme.useToken();
|
|
5855
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { backgroundColor: token.colorFillAlter, padding: 8, borderRadius: token.borderRadius }, children: /* @__PURE__ */ jsxRuntime.jsx(MonacoEditor_default, { language: "json", placeholder: "\u8BF7\u8F93\u5165\u503C...", height: 80, value, onChange }) });
|
|
5856
|
+
};
|
|
5857
|
+
var UserInputPanel = () => {
|
|
5858
|
+
const chatStore = useChatStore();
|
|
5859
|
+
const agentState = valtio.useSnapshot(chatStore.agent);
|
|
5860
|
+
const [form] = antd.Form.useForm();
|
|
5861
|
+
const [activeKey, setActiveKey] = React10.useState(["1"]);
|
|
5862
|
+
const inputs = React10.useMemo(() => {
|
|
5863
|
+
if (agentState.agentInfo.userInput?.length > 0) {
|
|
5864
|
+
return agentState.agentInfo.userInput;
|
|
5865
|
+
}
|
|
5866
|
+
}, [agentState.agentInfo.userInput]);
|
|
5867
|
+
React10.useEffect(() => {
|
|
5868
|
+
if (inputs.length > 0) {
|
|
5869
|
+
const initialValues = inputs.reduce((acc, cur) => {
|
|
5870
|
+
let value = cur.value;
|
|
5871
|
+
acc[cur.name] = value;
|
|
5872
|
+
return acc;
|
|
5873
|
+
}, {});
|
|
5874
|
+
form.setFieldsValue(initialValues);
|
|
5875
|
+
}
|
|
5876
|
+
}, [inputs, form]);
|
|
5877
|
+
const handleValuesChange = (changedValues) => {
|
|
5878
|
+
if (agentState.agentInfo.userInput?.length > 0) {
|
|
5879
|
+
const newInput = agentState.agentInfo.userInput.map((v) => {
|
|
5880
|
+
if (v.name in changedValues) {
|
|
5881
|
+
const newValue = changedValues[v.name];
|
|
5882
|
+
return { ...v, value: newValue };
|
|
5883
|
+
}
|
|
5884
|
+
return v;
|
|
5885
|
+
});
|
|
5886
|
+
chatStore.setConversationUserInput(newInput);
|
|
5887
|
+
return;
|
|
5888
|
+
}
|
|
5889
|
+
};
|
|
5890
|
+
const handleStartChat = () => {
|
|
5891
|
+
form.validateFields().then(() => {
|
|
5892
|
+
setActiveKey([]);
|
|
5893
|
+
}).catch(() => {
|
|
5894
|
+
antd.message.error("\u8BF7\u68C0\u67E5\u8F93\u5165\u53C2\u6570");
|
|
5895
|
+
});
|
|
5896
|
+
};
|
|
5897
|
+
const renderFormItem = (item) => {
|
|
5898
|
+
const itemStyle = { marginBottom: 0 };
|
|
5899
|
+
const commonProps = {
|
|
5900
|
+
label: item.name,
|
|
5901
|
+
name: item.name,
|
|
5902
|
+
style: itemStyle,
|
|
5903
|
+
rules: item.rules?.map((r) => {
|
|
5904
|
+
const valStr = String(r.value || "");
|
|
5905
|
+
if (r.type === "required") return { required: true, message: r.message };
|
|
5906
|
+
if (r.type === "email") return { type: "email", message: r.message };
|
|
5907
|
+
if (r.type === "pattern") return { pattern: new RegExp(valStr), message: r.message };
|
|
5908
|
+
if (r.type === "max" || r.type === "min") {
|
|
5909
|
+
return {
|
|
5910
|
+
validator: (_, val) => {
|
|
5911
|
+
if (val === void 0 || val === null || val === "") return Promise.resolve();
|
|
5912
|
+
const numVal = Number(val);
|
|
5913
|
+
if (isNaN(numVal)) return Promise.resolve();
|
|
5914
|
+
if (r.type === "max" && numVal > Number(valStr)) return Promise.reject(new Error(r.message));
|
|
5915
|
+
if (r.type === "min" && numVal < Number(valStr)) return Promise.reject(new Error(r.message));
|
|
5916
|
+
return Promise.resolve();
|
|
5917
|
+
}
|
|
5918
|
+
};
|
|
5919
|
+
}
|
|
5920
|
+
if (r.type === "length") {
|
|
5921
|
+
const [min, max] = valStr.split(",").map((v) => v ? Number(v) : void 0);
|
|
5922
|
+
return {
|
|
5923
|
+
validator: (_, val) => {
|
|
5924
|
+
if (val === void 0 || val === null || val === "") return Promise.resolve();
|
|
5925
|
+
const strVal = String(val);
|
|
5926
|
+
if (min !== void 0 && strVal.length < min) return Promise.reject(new Error(r.message));
|
|
5927
|
+
if (max !== void 0 && strVal.length > max) return Promise.reject(new Error(r.message));
|
|
5928
|
+
return Promise.resolve();
|
|
5929
|
+
}
|
|
5930
|
+
};
|
|
5931
|
+
}
|
|
5932
|
+
if (r.type === "size") {
|
|
5933
|
+
const [min, max] = valStr.split(",").map((v) => v ? Number(v) : void 0);
|
|
5934
|
+
return {
|
|
5935
|
+
validator: (_, val) => {
|
|
5936
|
+
if (val === void 0 || val === null || val === "") return Promise.resolve();
|
|
5937
|
+
let len = 0;
|
|
5938
|
+
if (Array.isArray(val)) {
|
|
5939
|
+
len = val.length;
|
|
5940
|
+
} else if (typeof val === "string") {
|
|
5941
|
+
try {
|
|
5942
|
+
const parsed = JSON.parse(val);
|
|
5943
|
+
if (Array.isArray(parsed)) len = parsed.length;
|
|
5944
|
+
else return Promise.resolve();
|
|
5945
|
+
} catch (e) {
|
|
5946
|
+
return Promise.resolve();
|
|
5947
|
+
}
|
|
5948
|
+
} else {
|
|
5949
|
+
return Promise.resolve();
|
|
5950
|
+
}
|
|
5951
|
+
if (min !== void 0 && len < min) return Promise.reject(new Error(r.message));
|
|
5952
|
+
if (max !== void 0 && len > max) return Promise.reject(new Error(r.message));
|
|
5953
|
+
return Promise.resolve();
|
|
5954
|
+
}
|
|
5955
|
+
};
|
|
5956
|
+
}
|
|
5957
|
+
if (r.type === "enum") {
|
|
5958
|
+
const options = valStr.split(",").map((s) => s.trim());
|
|
5959
|
+
return {
|
|
5960
|
+
validator: (_, val) => {
|
|
5961
|
+
if (val === void 0 || val === null || val === "") return Promise.resolve();
|
|
5962
|
+
if (options.includes(String(val))) return Promise.resolve();
|
|
5963
|
+
return Promise.reject(new Error(r.message));
|
|
5964
|
+
}
|
|
5965
|
+
};
|
|
5966
|
+
}
|
|
5967
|
+
return {};
|
|
5968
|
+
})
|
|
5969
|
+
};
|
|
5970
|
+
if (["STRING", "LONG"].includes(item.type)) {
|
|
5971
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { placeholder: "\u8BF7\u8F93\u5165\u503C" }) });
|
|
5972
|
+
}
|
|
5973
|
+
if (["NUMBER"].includes(item.type)) {
|
|
5974
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.InputNumber, { style: { width: "100%" }, placeholder: "\u8BF7\u8F93\u5165\u6570\u503C" }) });
|
|
5975
|
+
}
|
|
5976
|
+
if (item.type === "BOOLEAN") {
|
|
5977
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { style: itemStyle, name: item.name, valuePropName: "checked", children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "space-between", align: "center", children: [
|
|
5978
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: item.name }),
|
|
5979
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Switch, { size: "small" })
|
|
5980
|
+
] }) });
|
|
5981
|
+
}
|
|
5982
|
+
if (item.type === "FILE") {
|
|
5983
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(FormFileUpload, { multiple: false }) });
|
|
5984
|
+
}
|
|
5985
|
+
if (item.type === "ARRAY_FILE") {
|
|
5986
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(FormFileUpload, { multiple: true }) });
|
|
5987
|
+
}
|
|
5988
|
+
if (["OBJECT", "ARRAY", "ARRAY_STRING", "ARRAY_NUMBER", "ARRAY_DECIMAL", "ARRAY_BOOLEAN", "ARRAY_OBJECT"].includes(item.type)) {
|
|
5989
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(FormMonacoEditor, {}) });
|
|
5990
|
+
}
|
|
5991
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...commonProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { placeholder: "\u8BF7\u8F93\u5165\u503C" }) });
|
|
5992
|
+
};
|
|
5993
|
+
const genExtra = () => {
|
|
5994
|
+
if (activeKey.includes("1")) return null;
|
|
5995
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5996
|
+
antd.Button,
|
|
5997
|
+
{
|
|
5998
|
+
type: "text",
|
|
5999
|
+
size: "small",
|
|
6000
|
+
onClick: (e) => {
|
|
6001
|
+
e.stopPropagation();
|
|
6002
|
+
setActiveKey(["1"]);
|
|
6003
|
+
},
|
|
6004
|
+
children: "\u7F16\u8F91"
|
|
6005
|
+
}
|
|
6006
|
+
);
|
|
6007
|
+
};
|
|
6008
|
+
const items = [
|
|
6009
|
+
{
|
|
6010
|
+
key: "1",
|
|
6011
|
+
label: "\u53C2\u6570\u8BBE\u7F6E",
|
|
6012
|
+
extra: genExtra(),
|
|
6013
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6014
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Form, { form, layout: "vertical", onValuesChange: handleValuesChange, style: { maxHeight: 500, overflow: "auto", paddingRight: 16 }, children: inputs.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, gap: 12, children: inputs.map((item) => /* @__PURE__ */ jsxRuntime.jsx(React10__namespace.default.Fragment, { children: renderFormItem(item) }, item.name)) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "10px", color: "#999", textAlign: "center" }, children: "\u6682\u65E0\u7528\u6237\u8F93\u5165\u5B57\u6BB5" }) }),
|
|
6015
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { align: "center", justify: "center", className: "m-t-16", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "primary", onClick: handleStartChat, children: "\u5F00\u59CB\u4F1A\u8BDD" }) })
|
|
6016
|
+
] })
|
|
6017
|
+
}
|
|
6018
|
+
];
|
|
6019
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.userInputCollapse, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6020
|
+
antd.Collapse,
|
|
6021
|
+
{
|
|
6022
|
+
activeKey,
|
|
6023
|
+
onChange: (keys) => {
|
|
6024
|
+
const newKeys = typeof keys === "string" ? [keys] : keys;
|
|
6025
|
+
setActiveKey(newKeys);
|
|
6026
|
+
},
|
|
6027
|
+
items,
|
|
6028
|
+
className: "m-16",
|
|
6029
|
+
styles: {
|
|
6030
|
+
body: {
|
|
6031
|
+
paddingRight: 0,
|
|
6032
|
+
paddingBottom: 10
|
|
6033
|
+
}
|
|
6034
|
+
}
|
|
6035
|
+
}
|
|
6036
|
+
) });
|
|
6037
|
+
};
|
|
6038
|
+
var UserInputPanel_default = UserInputPanel;
|
|
5613
6039
|
|
|
5614
6040
|
// src/ui/layouts/components/styles.module.less
|
|
5615
6041
|
var styles_module_default5 = {
|
|
@@ -5634,9 +6060,11 @@ var ChatMainPanel = React10.memo(
|
|
|
5634
6060
|
[]
|
|
5635
6061
|
);
|
|
5636
6062
|
const configState = valtio.useSnapshot(chatStore.config);
|
|
6063
|
+
const agentState = valtio.useSnapshot(chatStore.agent);
|
|
5637
6064
|
return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames2__default.default("height-full"), children: [
|
|
5638
6065
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.chatHeader, DefaultComponent: ChatHeader_default }),
|
|
5639
6066
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", vertical: true, gap: 24, className: classNames2__default.default("height-full", styles_module_default5.bodyWidth), children: [
|
|
6067
|
+
common.shouldRender(agentState.agentInfo.userInput && agentState.agentInfo.userInput.length > 0) && /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.userInput, DefaultComponent: UserInputPanel_default }),
|
|
5640
6068
|
common.shouldRender(configState.layout.messageList) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "full-scroll", style: { width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.messageList, DefaultComponent: BubbleListItems_default }) }),
|
|
5641
6069
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.senderHeader, DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx(ChatSenderHeader_default, {}) }),
|
|
5642
6070
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { className: styles_module_default5.inputContainer, vertical: true, gap: 8, children: [
|
|
@@ -5715,7 +6143,7 @@ var index_module_default3 = {
|
|
|
5715
6143
|
animatedSplitter: "index_module_animatedSplitter",
|
|
5716
6144
|
hideSplitterBar: "index_module_hideSplitterBar"
|
|
5717
6145
|
};
|
|
5718
|
-
var layouts_default = React10.forwardRef(({ theme:
|
|
6146
|
+
var layouts_default = React10.forwardRef(({ theme: theme5, params, hooks, layout, config, services }, _ref) => {
|
|
5719
6147
|
const chatStore = React10.useMemo(() => createChatStore(), []);
|
|
5720
6148
|
const senderRef = React10.useRef(null);
|
|
5721
6149
|
React10.useImperativeHandle(
|
|
@@ -5762,6 +6190,11 @@ var layouts_default = React10.forwardRef(({ theme: theme4, params, hooks, layout
|
|
|
5762
6190
|
chatStore.setAgent({ ...agentState.agentInfo, config: config.agent.config || {} });
|
|
5763
6191
|
}
|
|
5764
6192
|
}, [agentState.agentInfo.id, config.agent?.config]);
|
|
6193
|
+
common.useDeepEffect(() => {
|
|
6194
|
+
if (agentState.agentInfo.id) {
|
|
6195
|
+
chatStore.setUserInput(config.agent.userInput);
|
|
6196
|
+
}
|
|
6197
|
+
}, [agentState.agentInfo.id, config.agent?.userInput]);
|
|
5765
6198
|
common.useDeepEffect(() => {
|
|
5766
6199
|
if (config?.agent?.id) {
|
|
5767
6200
|
chatStore.getAgentInfo(config.agent.id);
|
|
@@ -5788,20 +6221,20 @@ var layouts_default = React10.forwardRef(({ theme: theme4, params, hooks, layout
|
|
|
5788
6221
|
}, [hasPreView]);
|
|
5789
6222
|
common.useWebSocket({
|
|
5790
6223
|
url: configState.services.websocketUrls?.[0],
|
|
5791
|
-
onMessage: (
|
|
6224
|
+
onMessage: (message3) => chatStore.acceptMessage(message3.payload),
|
|
5792
6225
|
clientHeartbeat: false,
|
|
5793
6226
|
reconnectInterval: 1e4
|
|
5794
6227
|
});
|
|
5795
6228
|
common.useWebSocket({
|
|
5796
6229
|
url: configState.services.websocketUrls?.[1],
|
|
5797
|
-
onMessage: (
|
|
6230
|
+
onMessage: (message3) => chatStore.acceptMessage(message3.payload),
|
|
5798
6231
|
clientHeartbeat: false,
|
|
5799
6232
|
reconnectInterval: 1e4
|
|
5800
6233
|
});
|
|
5801
6234
|
React10.useEffect(() => {
|
|
5802
6235
|
hooks?.onBeforeInit?.();
|
|
5803
6236
|
}, []);
|
|
5804
|
-
return /* @__PURE__ */ jsxRuntime.jsx(xV2.XProvider, { theme: { cssVar: {}, ...
|
|
6237
|
+
return /* @__PURE__ */ jsxRuntime.jsx(xV2.XProvider, { theme: { cssVar: {}, ...theme5 }, children: /* @__PURE__ */ jsxRuntime.jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: configState.loading, classNames: { root: "full-spin" }, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames2__default.default(index_module_default3.chatLayout, "zero-chat-layout", "height-full"), children: [
|
|
5805
6238
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.globalHeader, DefaultComponent: ChatHeader_default }),
|
|
5806
6239
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { ref: containerRef, className: "full-scroll", children: [
|
|
5807
6240
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.leftPanel }),
|