@zero-library/chat-copilot 3.1.15 → 3.1.17
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 +148 -77
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +1 -5
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.esm.js +149 -79
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CloudUploadOutlined, PaperClipOutlined, createFromIconfontCN, EnterOutlined, DownloadOutlined, CloseOutlined, PlayCircleOutlined, CopyOutlined, DotChartOutlined, LoadingOutlined, RightOutlined, LikeOutlined, DislikeOutlined, ToolOutlined, SearchOutlined, UpOutlined, DownOutlined, PlusOutlined, CommentOutlined, StarFilled, StarOutlined, RedoOutlined, DeleteOutlined, ClockCircleOutlined, CheckCircleOutlined, FileImageOutlined, FilePdfOutlined, FileWordOutlined, FileExcelOutlined, FilePptOutlined, FileZipOutlined, FileTextOutlined, FileUnknownOutlined } from '@ant-design/icons';
|
|
1
|
+
import { CloudUploadOutlined, PaperClipOutlined, createFromIconfontCN, EnterOutlined, DownloadOutlined, CloseOutlined, PlayCircleOutlined, CopyOutlined, DotChartOutlined, LoadingOutlined, RightOutlined, LikeOutlined, DislikeOutlined, ToolOutlined, SearchOutlined, UpOutlined, DownOutlined, PlusOutlined, CommentOutlined, StarFilled, StarOutlined, ShareAltOutlined, RedoOutlined, DeleteOutlined, ClockCircleOutlined, CheckCircleOutlined, FileImageOutlined, FilePdfOutlined, FileWordOutlined, FileExcelOutlined, FilePptOutlined, FileZipOutlined, FileTextOutlined, FileUnknownOutlined } from '@ant-design/icons';
|
|
2
2
|
import { Attachments, Sender, FileCard, Bubble, Think, XProvider, Mermaid, CodeHighlighter, Welcome, Prompts, Conversations } from '@ant-design/x-v2';
|
|
3
3
|
import { useRefState, useDebounce, createTokenManager, useSyncInput, isEmptyObj, markdownToText, RenderWrapper, shouldRender, isFunction, downloadFile, LuyaFilePreview, MarkdownEditor, useDeepEffect, isObject, useWebSocket, isNullOrUnDef, isNumber, getFileSuffixName, emit, FileIcon, copyText, LazyComponent, isBoolean, UserAvatar, htmlToMarkdown, buildUrlParams, isExternal, deepCopy, transforms, deepMerge, createRequest, HttpStatus, isArray, isString, isDef, isNull, transform, getWebSocketUrl, safeParseJson } from '@zero-library/common';
|
|
4
4
|
import { App, Badge, Button, Flex, Typography, Tooltip, Layout, Tag, Spin, Splitter, Image as Image$1, Popover, Skeleton, Alert, theme, Collapse, Divider as Divider$1, Select as Select$1, Avatar, Space, Form, Drawer, Empty, Modal, Checkbox, Input, InputNumber, Switch as Switch$1, message, Tabs, Upload, Popconfirm, List, Card, Table, Progress as Progress$1 } from 'antd';
|
|
@@ -44,7 +44,7 @@ var styles_module_default = {
|
|
|
44
44
|
chatAttachments: "styles_module_chatAttachments",
|
|
45
45
|
chatSender: "styles_module_chatSender"};
|
|
46
46
|
var Attachments_default = forwardRef(({ fileUpload, fileUploadConfig, fileList = [], onChange, extraParams }, ref) => {
|
|
47
|
-
const { message:
|
|
47
|
+
const { message: message4 } = App.useApp();
|
|
48
48
|
const chatStore = useChatStore();
|
|
49
49
|
const configState = useSnapshot(chatStore.config);
|
|
50
50
|
const fileListRef = useRef([]);
|
|
@@ -72,7 +72,7 @@ var Attachments_default = forwardRef(({ fileUpload, fileUploadConfig, fileList =
|
|
|
72
72
|
onChange(files);
|
|
73
73
|
}, [attachedFiles]);
|
|
74
74
|
const onErrorTip = useDebounce((errorMsg) => {
|
|
75
|
-
|
|
75
|
+
message4.error(errorMsg);
|
|
76
76
|
}, 300);
|
|
77
77
|
const findConfig = (file) => {
|
|
78
78
|
return fileUploadConfig?.allowedTypes?.find((type) => type === getFileSuffixName(file.name)) || "";
|
|
@@ -237,9 +237,19 @@ var index_module_default = {
|
|
|
237
237
|
};
|
|
238
238
|
|
|
239
239
|
// src/core/constants.ts
|
|
240
|
+
var WorkspaceTypeEnum = /* @__PURE__ */ ((WorkspaceTypeEnum2) => {
|
|
241
|
+
WorkspaceTypeEnum2["GLOBAL"] = "global";
|
|
242
|
+
WorkspaceTypeEnum2["SKILL"] = "skill";
|
|
243
|
+
WorkspaceTypeEnum2["CONVERSATION"] = "conversation";
|
|
244
|
+
WorkspaceTypeEnum2["KNOWLEDGE"] = "knowledge";
|
|
245
|
+
WorkspaceTypeEnum2["PROJECT"] = "project";
|
|
246
|
+
WorkspaceTypeEnum2["DEV_SKILL"] = "devSkill";
|
|
247
|
+
return WorkspaceTypeEnum2;
|
|
248
|
+
})(WorkspaceTypeEnum || {});
|
|
240
249
|
var CONV_MODE = {
|
|
241
250
|
PROD: 1};
|
|
242
251
|
var TOKEN_KEY = "NS-TOKEN";
|
|
252
|
+
var SHARE_KEY = "SHARE-TOKEN";
|
|
243
253
|
var tokenManager = createTokenManager({
|
|
244
254
|
key: TOKEN_KEY
|
|
245
255
|
});
|
|
@@ -331,8 +341,9 @@ var getFileIcon = (extension, fontSize = 24) => {
|
|
|
331
341
|
return createIcon(FileUnknownOutlined, "#94a3b8");
|
|
332
342
|
};
|
|
333
343
|
var getFileUrl = (params, baseUrl, url) => {
|
|
344
|
+
const authParams = baseUrl === "/luya/share" ? { [SHARE_KEY]: localStorage.getItem(SHARE_KEY) || "" } : { [TOKEN_KEY]: tokenManager.get() };
|
|
334
345
|
const data = {
|
|
335
|
-
|
|
346
|
+
...authParams,
|
|
336
347
|
workspaceType: "conversation" /* CONVERSATION */,
|
|
337
348
|
...params
|
|
338
349
|
};
|
|
@@ -821,7 +832,7 @@ var ChatInput = React10.forwardRef(
|
|
|
821
832
|
}
|
|
822
833
|
}
|
|
823
834
|
),
|
|
824
|
-
placeholder: !stringValue
|
|
835
|
+
placeholder: !stringValue ? /* @__PURE__ */ jsx("div", { className: index_module_default.promptEditorPlaceholder, children: placeholder || "\u4ECA\u5929\u5E2E\u4F60\u505A\u4E9B\u4EC0\u4E48\uFF1F\u8F93\u5165 '/' \u8C03\u7528\u6280\u80FD\u4E0E\u77E5\u8BC6\u5E93" }) : null,
|
|
825
836
|
ErrorBoundary: LexicalErrorBoundary
|
|
826
837
|
}
|
|
827
838
|
),
|
|
@@ -835,6 +846,7 @@ var ChatInput = React10.forwardRef(
|
|
|
835
846
|
var ChatInput_default = ChatInput;
|
|
836
847
|
var ChatSender_default = forwardRef(
|
|
837
848
|
({
|
|
849
|
+
placeholder,
|
|
838
850
|
content,
|
|
839
851
|
commandConfig = {},
|
|
840
852
|
fileList = [],
|
|
@@ -907,6 +919,7 @@ var ChatSender_default = forwardRef(
|
|
|
907
919
|
className: styles_module_default.chatSender,
|
|
908
920
|
ref: senderRef,
|
|
909
921
|
value: inputValue,
|
|
922
|
+
placeholder,
|
|
910
923
|
header: senderHeader,
|
|
911
924
|
onSubmit,
|
|
912
925
|
onChange: setInputValue,
|
|
@@ -1002,6 +1015,9 @@ var createChatService = (request, config) => {
|
|
|
1002
1015
|
const conversationFavorite = (conversationId, isFavorite) => {
|
|
1003
1016
|
return request.put("/agents/conversations/favorite", { conversationIds: [conversationId], favorite: isFavorite });
|
|
1004
1017
|
};
|
|
1018
|
+
const shareConversation = (conversationId) => {
|
|
1019
|
+
return request.get(`/agents/conversations/${conversationId}/share/url`);
|
|
1020
|
+
};
|
|
1005
1021
|
return {
|
|
1006
1022
|
fetchModelList,
|
|
1007
1023
|
fetchAgentInfo,
|
|
@@ -1021,7 +1037,8 @@ var createChatService = (request, config) => {
|
|
|
1021
1037
|
listDataSources,
|
|
1022
1038
|
listTags,
|
|
1023
1039
|
getAgentAvatar,
|
|
1024
|
-
conversationFavorite
|
|
1040
|
+
conversationFavorite,
|
|
1041
|
+
shareConversation
|
|
1025
1042
|
};
|
|
1026
1043
|
};
|
|
1027
1044
|
|
|
@@ -1067,7 +1084,13 @@ function createChatStore() {
|
|
|
1067
1084
|
return await config.services.request.fetchModelList();
|
|
1068
1085
|
};
|
|
1069
1086
|
const setServices = ({ http, websocket } = {}) => {
|
|
1070
|
-
const
|
|
1087
|
+
const baseURL = http?.config?.baseURL || "/luya/v1";
|
|
1088
|
+
const headers = baseURL === "/luya/share" ? { [SHARE_KEY]: localStorage.getItem(SHARE_KEY) || "" } : { [TOKEN_KEY]: tokenManager.get() };
|
|
1089
|
+
const httpConfig = {
|
|
1090
|
+
baseURL,
|
|
1091
|
+
headers,
|
|
1092
|
+
...http?.config
|
|
1093
|
+
};
|
|
1071
1094
|
const request = createRequest(httpConfig);
|
|
1072
1095
|
if (config.hooks?.onRequestInterceptor) {
|
|
1073
1096
|
request.instance.interceptors.request.use(...config.hooks.onRequestInterceptor);
|
|
@@ -1088,9 +1111,9 @@ function createChatStore() {
|
|
|
1088
1111
|
config.services.request = { ...createChatService(request, httpConfig), ...http?.request };
|
|
1089
1112
|
config.services.websocketUrls = ["", ""];
|
|
1090
1113
|
if (isArray(websocket?.baseURLs)) {
|
|
1091
|
-
websocket.baseURLs.forEach((
|
|
1092
|
-
if (isString(
|
|
1093
|
-
config.services.websocketUrls[index] = getChatSocketUrl(
|
|
1114
|
+
websocket.baseURLs.forEach((baseURL2, index) => {
|
|
1115
|
+
if (isString(baseURL2)) {
|
|
1116
|
+
config.services.websocketUrls[index] = getChatSocketUrl(baseURL2, websocket?.params || httpConfig.headers);
|
|
1094
1117
|
}
|
|
1095
1118
|
});
|
|
1096
1119
|
} else {
|
|
@@ -1593,7 +1616,7 @@ function createChatStore() {
|
|
|
1593
1616
|
}
|
|
1594
1617
|
if (isMain) config.hooks?.onStepMessage?.(msg);
|
|
1595
1618
|
}
|
|
1596
|
-
function doneCallback(msg,
|
|
1619
|
+
function doneCallback(msg, message4, isMain) {
|
|
1597
1620
|
conversation.messages[msg.conversationId].loading = false;
|
|
1598
1621
|
const messages = conversation.messages[msg.conversationId]?.message;
|
|
1599
1622
|
if (messages) {
|
|
@@ -1886,9 +1909,9 @@ function createChatStore() {
|
|
|
1886
1909
|
}
|
|
1887
1910
|
}
|
|
1888
1911
|
}
|
|
1889
|
-
function processMessageContent(
|
|
1912
|
+
function processMessageContent(message4, targetMessages) {
|
|
1890
1913
|
const newMessage = {
|
|
1891
|
-
...
|
|
1914
|
+
...message4,
|
|
1892
1915
|
agentId: agent.agentInfo.id
|
|
1893
1916
|
};
|
|
1894
1917
|
const isMain = !targetMessages;
|
|
@@ -1956,13 +1979,13 @@ function createChatStore() {
|
|
|
1956
1979
|
}
|
|
1957
1980
|
processMessageContent(newMessage);
|
|
1958
1981
|
};
|
|
1959
|
-
const sendMessage = async (
|
|
1982
|
+
const sendMessage = async (message4, msgFiles = [], params) => {
|
|
1960
1983
|
const conversationId = conversation.active.id;
|
|
1961
1984
|
if (conversation.messages[conversationId].loading) return;
|
|
1962
1985
|
let msgContent = "", files;
|
|
1963
1986
|
const references = conversation.messages[conversationId].references;
|
|
1964
|
-
if (
|
|
1965
|
-
msgContent =
|
|
1987
|
+
if (message4) {
|
|
1988
|
+
msgContent = message4;
|
|
1966
1989
|
files = [...msgFiles, ...conversation.messages[conversationId].files || []];
|
|
1967
1990
|
} else {
|
|
1968
1991
|
if (references?.type === 1 && references?.content?.msgContent) {
|
|
@@ -2009,9 +2032,9 @@ function createChatStore() {
|
|
|
2009
2032
|
};
|
|
2010
2033
|
const extraParams = deepCopy(config.params?.params || {});
|
|
2011
2034
|
const userInputParams = variablesToObject(conversation.active.userInput || []);
|
|
2012
|
-
Object.assign(extraParams,
|
|
2035
|
+
Object.assign(extraParams, message4 ? {} : { ...references?.params }, params, userInputParams);
|
|
2013
2036
|
sendParams.params = extraParams;
|
|
2014
|
-
if (!
|
|
2037
|
+
if (!message4) {
|
|
2015
2038
|
setContent("");
|
|
2016
2039
|
setContentParams();
|
|
2017
2040
|
setReferences();
|
|
@@ -2212,7 +2235,7 @@ var ConversationFavoritesBtn_default = ({ icon, ...rest }) => {
|
|
|
2212
2235
|
const activeConversation = useMemo(() => {
|
|
2213
2236
|
return conversationsState.list.items.find((item) => item.id === conversationState.active.id);
|
|
2214
2237
|
}, [conversationsState.list.items, conversationState.active.id]);
|
|
2215
|
-
const isFavorite =
|
|
2238
|
+
const isFavorite = activeConversation?.isFavorite === true;
|
|
2216
2239
|
const handleToggleFavorite = () => {
|
|
2217
2240
|
if (!conversationState.active.id) return;
|
|
2218
2241
|
chatStore.collectConversation(conversationState.active.id, !isFavorite);
|
|
@@ -2222,7 +2245,7 @@ var ConversationFavoritesBtn_default = ({ icon, ...rest }) => {
|
|
|
2222
2245
|
{
|
|
2223
2246
|
title: isFavorite ? "\u53D6\u6D88\u6536\u85CF" : "\u6536\u85CF",
|
|
2224
2247
|
type: "text",
|
|
2225
|
-
size: "
|
|
2248
|
+
size: "large",
|
|
2226
2249
|
disabled: !conversationState.active.id,
|
|
2227
2250
|
icon: icon?.() || (isFavorite ? /* @__PURE__ */ jsx(StarFilled, { className: "primary-text" }) : /* @__PURE__ */ jsx(StarOutlined, {})),
|
|
2228
2251
|
onClick: handleToggleFavorite,
|
|
@@ -2230,9 +2253,37 @@ var ConversationFavoritesBtn_default = ({ icon, ...rest }) => {
|
|
|
2230
2253
|
}
|
|
2231
2254
|
);
|
|
2232
2255
|
};
|
|
2256
|
+
var ConversationShareBtn_default = ({ icon, ...rest }) => {
|
|
2257
|
+
const chatStore = useChatStore();
|
|
2258
|
+
const conversationState = useSnapshot(chatStore.conversation);
|
|
2259
|
+
const configState = useSnapshot(chatStore.config);
|
|
2260
|
+
const handleShareConversation = async () => {
|
|
2261
|
+
try {
|
|
2262
|
+
const { data } = await configState.services.request.shareConversation(conversationState.active.id);
|
|
2263
|
+
if (data) {
|
|
2264
|
+
copyText(data);
|
|
2265
|
+
message.success("\u5206\u4EAB\u94FE\u63A5\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F");
|
|
2266
|
+
}
|
|
2267
|
+
} catch (error) {
|
|
2268
|
+
message.error("\u5206\u4EAB\u4F1A\u8BDD\u5931\u8D25");
|
|
2269
|
+
}
|
|
2270
|
+
};
|
|
2271
|
+
return /* @__PURE__ */ jsx(
|
|
2272
|
+
Button,
|
|
2273
|
+
{
|
|
2274
|
+
title: "\u5206\u4EAB",
|
|
2275
|
+
type: "text",
|
|
2276
|
+
size: "large",
|
|
2277
|
+
disabled: !conversationState.active.id,
|
|
2278
|
+
icon: icon?.() || /* @__PURE__ */ jsx(ShareAltOutlined, {}),
|
|
2279
|
+
...rest,
|
|
2280
|
+
onClick: handleShareConversation
|
|
2281
|
+
}
|
|
2282
|
+
);
|
|
2283
|
+
};
|
|
2233
2284
|
var CreateBtn_default = ({ icon, ...rest }) => {
|
|
2234
2285
|
const chatStore = useChatStore();
|
|
2235
|
-
return /* @__PURE__ */ jsx(Button, { title: "\u65B0\u5EFA\u4F1A\u8BDD", size: "
|
|
2286
|
+
return /* @__PURE__ */ jsx(Button, { title: "\u65B0\u5EFA\u4F1A\u8BDD", size: "large", type: "text", icon: icon?.() || /* @__PURE__ */ jsx(PlusOutlined, {}), onClick: () => chatStore.createConversation(), ...rest });
|
|
2236
2287
|
};
|
|
2237
2288
|
|
|
2238
2289
|
// src/ui/common/styles.module.less
|
|
@@ -2330,7 +2381,7 @@ var ConversationList_default = () => {
|
|
|
2330
2381
|
Button,
|
|
2331
2382
|
{
|
|
2332
2383
|
icon: /* @__PURE__ */ jsx(DeleteOutlined, {}),
|
|
2333
|
-
title: "\
|
|
2384
|
+
title: "\u53D6\u6D88\u6536\u85CF",
|
|
2334
2385
|
type: "text",
|
|
2335
2386
|
onClick: (e) => {
|
|
2336
2387
|
e.stopPropagation();
|
|
@@ -2451,7 +2502,7 @@ var HistoryBtn_default = ({ icon, ...rest }) => {
|
|
|
2451
2502
|
classNames: { container: style_module_default.popover },
|
|
2452
2503
|
content: /* @__PURE__ */ jsx(ConversationList_default, {}),
|
|
2453
2504
|
trigger: ["click"],
|
|
2454
|
-
children: /* @__PURE__ */ jsx(Button, { title: "\u5386\u53F2\u4F1A\u8BDD", size: "
|
|
2505
|
+
children: /* @__PURE__ */ jsx(Button, { title: "\u5386\u53F2\u4F1A\u8BDD", size: "large", type: "text", icon: icon?.() || /* @__PURE__ */ jsx(CommentOutlined, {}), ...rest })
|
|
2455
2506
|
}
|
|
2456
2507
|
);
|
|
2457
2508
|
};
|
|
@@ -2461,7 +2512,8 @@ var ChatHeader_default = ({
|
|
|
2461
2512
|
closeBtn = false,
|
|
2462
2513
|
newConversationBtn = true,
|
|
2463
2514
|
conversationListBtn = true,
|
|
2464
|
-
conversationFavoriteBtn = true
|
|
2515
|
+
conversationFavoriteBtn = true,
|
|
2516
|
+
conversationShareBtn = true
|
|
2465
2517
|
}) => {
|
|
2466
2518
|
const chatStore = useChatStore();
|
|
2467
2519
|
const agentState = useSnapshot(chatStore.agent);
|
|
@@ -2482,7 +2534,8 @@ var ChatHeader_default = ({
|
|
|
2482
2534
|
/* @__PURE__ */ jsxs("div", { className: styles_module_default2.chatHeaderBtnGroup, children: [
|
|
2483
2535
|
/* @__PURE__ */ jsx(RenderWrapper, { control: newConversationBtn, DefaultComponent: CreateBtn_default }),
|
|
2484
2536
|
/* @__PURE__ */ jsx(RenderWrapper, { control: conversationListBtn, DefaultComponent: HistoryBtn_default }),
|
|
2485
|
-
/* @__PURE__ */ jsx(RenderWrapper, { control: conversationFavoriteBtn, DefaultComponent: ConversationFavoritesBtn_default })
|
|
2537
|
+
/* @__PURE__ */ jsx(RenderWrapper, { control: conversationFavoriteBtn, DefaultComponent: ConversationFavoritesBtn_default }),
|
|
2538
|
+
/* @__PURE__ */ jsx(RenderWrapper, { control: conversationShareBtn, DefaultComponent: ConversationShareBtn_default })
|
|
2486
2539
|
] }),
|
|
2487
2540
|
/* @__PURE__ */ jsx(
|
|
2488
2541
|
RenderWrapper,
|
|
@@ -3090,12 +3143,12 @@ var DocDrawer_default = ({ title, open, onClose, paramsStr }) => {
|
|
|
3090
3143
|
}, [paramsStr]);
|
|
3091
3144
|
return /* @__PURE__ */ jsx(Drawer, { title, push: false, size: "100%", open, onClose, children: /* @__PURE__ */ jsx(Spin, { spinning: loading, children: content ? /* @__PURE__ */ jsx(XMarkdown, { content }) : /* @__PURE__ */ jsx(Empty, { className: "m-t-32" }) }) });
|
|
3092
3145
|
};
|
|
3093
|
-
var IndexQuote_default = ({ data, loading, message:
|
|
3146
|
+
var IndexQuote_default = ({ data, loading, message: message4 }) => {
|
|
3094
3147
|
const [open, setOpen] = useState(false);
|
|
3095
3148
|
const citation = useMemo(() => {
|
|
3096
|
-
const citations =
|
|
3149
|
+
const citations = message4.content?.find((item) => item.type === "citation")?.citations ?? [];
|
|
3097
3150
|
return citations?.find((item) => String(item.citationId) === String(data.citationId));
|
|
3098
|
-
}, [data.citationId,
|
|
3151
|
+
}, [data.citationId, message4.content]);
|
|
3099
3152
|
const onClick = () => {
|
|
3100
3153
|
if (!citation?.citationUrl) return;
|
|
3101
3154
|
if (isExternal(citation.citationUrl)) {
|
|
@@ -3110,7 +3163,7 @@ var IndexQuote_default = ({ data, loading, message: message3 }) => {
|
|
|
3110
3163
|
open && /* @__PURE__ */ jsx(DocDrawer_default, { paramsStr: citation?.citationUrl, title: citation?.citationName, open, onClose: () => setOpen(false) })
|
|
3111
3164
|
] });
|
|
3112
3165
|
};
|
|
3113
|
-
var MarkImg_default = ({ data, loading, message:
|
|
3166
|
+
var MarkImg_default = ({ data, loading, message: message4, ...rest }) => {
|
|
3114
3167
|
const getPreviewFileUrl = (src) => {
|
|
3115
3168
|
return buildUrlParams({ [TOKEN_KEY]: tokenManager.get() || "" }, src);
|
|
3116
3169
|
};
|
|
@@ -3137,8 +3190,9 @@ var MdEdit_default = ({ data, loading }) => {
|
|
|
3137
3190
|
!loading && /* @__PURE__ */ jsx(Flex, { justify: "end", className: "m-t-16", children: /* @__PURE__ */ jsx(Button, { color: "primary", variant: "outlined", onClick: onOk, children: btnText }) })
|
|
3138
3191
|
] });
|
|
3139
3192
|
};
|
|
3140
|
-
var PreviewLink_default = ({ data, loading, message:
|
|
3193
|
+
var PreviewLink_default = ({ data, loading, message: message4, ...rest }) => {
|
|
3141
3194
|
const chatStore = useChatStore();
|
|
3195
|
+
const conversationWorkspacePrefix = "/workspace/conversation/";
|
|
3142
3196
|
const getLinkFileName = (path) => {
|
|
3143
3197
|
const lastSegment = path.split("/").pop();
|
|
3144
3198
|
if (!lastSegment) {
|
|
@@ -3150,13 +3204,27 @@ var PreviewLink_default = ({ data, loading, message: message3, ...rest }) => {
|
|
|
3150
3204
|
return lastSegment;
|
|
3151
3205
|
}
|
|
3152
3206
|
};
|
|
3153
|
-
const
|
|
3207
|
+
const normalizePreviewPath = (path) => {
|
|
3208
|
+
if (!path) {
|
|
3209
|
+
return path;
|
|
3210
|
+
}
|
|
3211
|
+
if (path.startsWith(conversationWorkspacePrefix)) {
|
|
3212
|
+
return path;
|
|
3213
|
+
}
|
|
3214
|
+
if (path.startsWith(conversationWorkspacePrefix.slice(1))) {
|
|
3215
|
+
return `/${path}`;
|
|
3216
|
+
}
|
|
3154
3217
|
const fileName = getLinkFileName(path);
|
|
3218
|
+
return `${conversationWorkspacePrefix}${fileName}`;
|
|
3219
|
+
};
|
|
3220
|
+
const handlePreviewByPath = (path) => {
|
|
3221
|
+
const normalizedPath = normalizePreviewPath(path);
|
|
3222
|
+
const fileName = getLinkFileName(normalizedPath);
|
|
3155
3223
|
const suffix = getFileSuffixName(fileName);
|
|
3156
3224
|
chatStore.setPreview({
|
|
3157
3225
|
fileUrl: chatStore.config.services.request.getPreviewUrl({
|
|
3158
|
-
path,
|
|
3159
|
-
workspaceId:
|
|
3226
|
+
path: normalizedPath,
|
|
3227
|
+
workspaceId: message4.conversationId
|
|
3160
3228
|
}),
|
|
3161
3229
|
fileName,
|
|
3162
3230
|
suffix
|
|
@@ -3269,7 +3337,7 @@ var adaptMarkdownComponent = (Component, payloadMapRef, messageRef) => {
|
|
|
3269
3337
|
return WrappedComponent;
|
|
3270
3338
|
};
|
|
3271
3339
|
var adaptMarkdownComponents = (components, payloadMapRef, messageRef) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component, payloadMapRef, messageRef)]));
|
|
3272
|
-
var XMarkdown_default = memo(({ message:
|
|
3340
|
+
var XMarkdown_default = memo(({ message: message4, components = {}, content = "", ...rest }) => {
|
|
3273
3341
|
const config = useMemo(() => getMarkdownConfig(), []);
|
|
3274
3342
|
const formattedContent = useMemo(() => formatMixedContent(content), [content]);
|
|
3275
3343
|
const newComponents = useMemo(
|
|
@@ -3295,9 +3363,9 @@ var XMarkdown_default = memo(({ message: message3, components = {}, content = ""
|
|
|
3295
3363
|
[formattedContent, payloadTagPattern]
|
|
3296
3364
|
);
|
|
3297
3365
|
const payloadMapRef = useRef(payloadMap);
|
|
3298
|
-
const messageRef = useRef(
|
|
3366
|
+
const messageRef = useRef(message4);
|
|
3299
3367
|
payloadMapRef.current = payloadMap;
|
|
3300
|
-
messageRef.current =
|
|
3368
|
+
messageRef.current = message4;
|
|
3301
3369
|
const markdownComponents = useMemo(() => adaptMarkdownComponents(newComponents, payloadMapRef, messageRef), [payloadTagPattern]);
|
|
3302
3370
|
return /* @__PURE__ */ jsx(
|
|
3303
3371
|
XMarkdown,
|
|
@@ -3647,7 +3715,7 @@ var Switch = ({ id, label, value, bind_path_token, onChange, onDataChange }) =>
|
|
|
3647
3715
|
/* @__PURE__ */ jsx("span", { style: { fontSize: 13, color: "#555" }, children: label })
|
|
3648
3716
|
] });
|
|
3649
3717
|
};
|
|
3650
|
-
var
|
|
3718
|
+
var Button12 = ({ label, variant = "default", onClick, action, onAction }) => {
|
|
3651
3719
|
const handleClick = () => {
|
|
3652
3720
|
if (onClick) {
|
|
3653
3721
|
onClick();
|
|
@@ -3677,7 +3745,7 @@ var A2uiComponents = {
|
|
|
3677
3745
|
TextField,
|
|
3678
3746
|
Select,
|
|
3679
3747
|
Switch,
|
|
3680
|
-
Button:
|
|
3748
|
+
Button: Button12,
|
|
3681
3749
|
Divider,
|
|
3682
3750
|
Tag: Tag3,
|
|
3683
3751
|
Progress,
|
|
@@ -3724,10 +3792,10 @@ function extractDismissedSurfaceIdsFromMessages(messages) {
|
|
|
3724
3792
|
const lastCreateIndexBySurface = /* @__PURE__ */ new Map();
|
|
3725
3793
|
const lastActionIndexBySurface = /* @__PURE__ */ new Map();
|
|
3726
3794
|
for (let messageIndex = 0; messageIndex < messages.length; messageIndex++) {
|
|
3727
|
-
const
|
|
3728
|
-
const items = Array.isArray(
|
|
3795
|
+
const message4 = messages[messageIndex];
|
|
3796
|
+
const items = Array.isArray(message4?.content) ? message4.content : [];
|
|
3729
3797
|
for (const item of items) {
|
|
3730
|
-
if (
|
|
3798
|
+
if (message4?.role !== 1) {
|
|
3731
3799
|
if (item?.type === "a2uiCommand" && item.command) {
|
|
3732
3800
|
const surfaceId = String(item.command?.createSurface?.surfaceId || "").trim();
|
|
3733
3801
|
if (surfaceId) lastCreateIndexBySurface.set(surfaceId, messageIndex);
|
|
@@ -3743,7 +3811,7 @@ function extractDismissedSurfaceIdsFromMessages(messages) {
|
|
|
3743
3811
|
}
|
|
3744
3812
|
}
|
|
3745
3813
|
}
|
|
3746
|
-
if (
|
|
3814
|
+
if (message4?.role === 1 && item?.type === "text") {
|
|
3747
3815
|
const text = item.messageContent || item.text || "";
|
|
3748
3816
|
if (typeof text !== "string" || !text.includes("a2ui_action.v1")) continue;
|
|
3749
3817
|
try {
|
|
@@ -4326,9 +4394,9 @@ function diffConversationMessages(messages, prevCursors) {
|
|
|
4326
4394
|
const nextCursors = [];
|
|
4327
4395
|
const pendingItems = [];
|
|
4328
4396
|
for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
|
|
4329
|
-
const
|
|
4330
|
-
const messageId = String(
|
|
4331
|
-
const items = Array.isArray(
|
|
4397
|
+
const message4 = messages[messageIndex];
|
|
4398
|
+
const messageId = String(message4?.messageId ?? messageIndex);
|
|
4399
|
+
const items = Array.isArray(message4?.content) ? message4.content : [];
|
|
4332
4400
|
const prevCursor = prevCursors[messageIndex];
|
|
4333
4401
|
const startIndex = prevCursor ? prevCursor.contentLength : 0;
|
|
4334
4402
|
if (prevCursor && (prevCursor.messageId !== messageId || items.length < prevCursor.contentLength)) {
|
|
@@ -4345,9 +4413,9 @@ function scanA2uiTagsFromMessages(messages, processedTagIds) {
|
|
|
4345
4413
|
const newTags = [];
|
|
4346
4414
|
const newTagIds = [];
|
|
4347
4415
|
for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
|
|
4348
|
-
const
|
|
4349
|
-
const messageId = String(
|
|
4350
|
-
const items = Array.isArray(
|
|
4416
|
+
const message4 = messages[messageIndex];
|
|
4417
|
+
const messageId = String(message4?.messageId ?? messageIndex);
|
|
4418
|
+
const items = Array.isArray(message4?.content) ? message4.content : [];
|
|
4351
4419
|
for (const item of items) {
|
|
4352
4420
|
const text = extractItemTextForA2ui(item);
|
|
4353
4421
|
if (typeof text !== "string" || !text.includes("<A2UI")) continue;
|
|
@@ -4403,9 +4471,9 @@ function reduceA2uiRuntimeMessages(state, messages) {
|
|
|
4403
4471
|
processA2uiCommand(cmd, messageIndex, messageId, nextState, effects, deletedSurfaceIds, nextWizardSteps);
|
|
4404
4472
|
}
|
|
4405
4473
|
});
|
|
4406
|
-
nextState.processedMessageCursors = shouldReplayAll ? messages.map((
|
|
4407
|
-
messageId: String(
|
|
4408
|
-
contentLength: Array.isArray(
|
|
4474
|
+
nextState.processedMessageCursors = shouldReplayAll ? messages.map((message4, messageIndex) => ({
|
|
4475
|
+
messageId: String(message4?.messageId ?? messageIndex),
|
|
4476
|
+
contentLength: Array.isArray(message4?.content) ? message4.content.length : 0
|
|
4409
4477
|
})) : nextCursors;
|
|
4410
4478
|
nextState.wizardStepBySurface = { ...nextState.wizardStepBySurface, ...nextWizardSteps };
|
|
4411
4479
|
if (deletedSurfaceIds.size) {
|
|
@@ -4753,8 +4821,8 @@ function readContextModelPath(context) {
|
|
|
4753
4821
|
function buildLatestCommandIndexBySurface(messages) {
|
|
4754
4822
|
const indexBySurface = {};
|
|
4755
4823
|
let commandIndex = -1;
|
|
4756
|
-
for (const
|
|
4757
|
-
const items = Array.isArray(
|
|
4824
|
+
for (const message4 of messages) {
|
|
4825
|
+
const items = Array.isArray(message4?.content) ? message4.content : [];
|
|
4758
4826
|
for (const item of items) {
|
|
4759
4827
|
if (item?.type === "a2uiCommand" && item.command) {
|
|
4760
4828
|
commandIndex += 1;
|
|
@@ -4942,7 +5010,7 @@ var TextNode2 = React10__default.memo(
|
|
|
4942
5010
|
item,
|
|
4943
5011
|
role,
|
|
4944
5012
|
customComponents,
|
|
4945
|
-
message:
|
|
5013
|
+
message: message4
|
|
4946
5014
|
}) => {
|
|
4947
5015
|
const content = toA2uiDisplayText(role, item?.messageContent);
|
|
4948
5016
|
const markdownComponents = {
|
|
@@ -4955,7 +5023,7 @@ var TextNode2 = React10__default.memo(
|
|
|
4955
5023
|
const markdownContent = typeof content === "string" ? transformResourceText(content) : content;
|
|
4956
5024
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4957
5025
|
!!item.reasoningContent && /* @__PURE__ */ jsx(Think, { title: "\u6DF1\u5EA6\u601D\u8003", style: { marginBottom: "16px" }, children: item.reasoningContent }),
|
|
4958
|
-
!!markdownContent && /* @__PURE__ */ jsx(XMarkdown_default, { message:
|
|
5026
|
+
!!markdownContent && /* @__PURE__ */ jsx(XMarkdown_default, { message: message4, components: markdownComponents, content: markdownContent })
|
|
4959
5027
|
] });
|
|
4960
5028
|
}
|
|
4961
5029
|
);
|
|
@@ -5283,9 +5351,9 @@ var ToolCallItem = ({ item }) => {
|
|
|
5283
5351
|
};
|
|
5284
5352
|
var tool_call_item_default = ToolCallItem;
|
|
5285
5353
|
var RENDERABLE_MESSAGE_TYPES = ["runStarted", "toolCall", "toolResult", "text", "stepError", "runFailed", "files", "plan"];
|
|
5286
|
-
var MessageRender_default = React10__default.memo(({ role, message:
|
|
5354
|
+
var MessageRender_default = React10__default.memo(({ role, message: message4, messageIndex = -1, loading, containerRef, customComponents }) => {
|
|
5287
5355
|
const content = useMemo(() => {
|
|
5288
|
-
return (
|
|
5356
|
+
return (message4.content || []).filter((item) => {
|
|
5289
5357
|
if (!RENDERABLE_MESSAGE_TYPES.includes(item.type)) {
|
|
5290
5358
|
return false;
|
|
5291
5359
|
}
|
|
@@ -5298,12 +5366,12 @@ var MessageRender_default = React10__default.memo(({ role, message: message3, me
|
|
|
5298
5366
|
}
|
|
5299
5367
|
return true;
|
|
5300
5368
|
});
|
|
5301
|
-
}, [
|
|
5369
|
+
}, [message4.content]);
|
|
5302
5370
|
const quoteMsg = useMemo(() => {
|
|
5303
5371
|
const quoteMsg2 = {};
|
|
5304
|
-
if (
|
|
5372
|
+
if (message4.params) {
|
|
5305
5373
|
try {
|
|
5306
|
-
const citation = JSON.parse(
|
|
5374
|
+
const citation = JSON.parse(message4.params).citation;
|
|
5307
5375
|
if (citation) {
|
|
5308
5376
|
quoteMsg2.messageContent = citation;
|
|
5309
5377
|
}
|
|
@@ -5311,7 +5379,7 @@ var MessageRender_default = React10__default.memo(({ role, message: message3, me
|
|
|
5311
5379
|
}
|
|
5312
5380
|
}
|
|
5313
5381
|
return isEmptyObj(quoteMsg2) ? null : quoteMsg2;
|
|
5314
|
-
}, [
|
|
5382
|
+
}, [message4.params, message4.quoteMsg]);
|
|
5315
5383
|
const showPending = loading && (content.length === 0 || content[content.length - 1].type !== "text");
|
|
5316
5384
|
if (content.length === 0 && !showPending) return null;
|
|
5317
5385
|
const lastToolCallIndex = (() => {
|
|
@@ -5335,20 +5403,20 @@ var MessageRender_default = React10__default.memo(({ role, message: message3, me
|
|
|
5335
5403
|
TextNode2,
|
|
5336
5404
|
{
|
|
5337
5405
|
item,
|
|
5338
|
-
role:
|
|
5406
|
+
role: message4.role,
|
|
5339
5407
|
customComponents,
|
|
5340
|
-
message:
|
|
5408
|
+
message: message4,
|
|
5341
5409
|
messageIndex
|
|
5342
5410
|
},
|
|
5343
5411
|
`message-${index}`
|
|
5344
5412
|
),
|
|
5345
|
-
(item.type === "stepError" || item.type === "runFailed") && (item.errorMessage ? /* @__PURE__ */ jsx(XMarkdown_default, { message:
|
|
5413
|
+
(item.type === "stepError" || item.type === "runFailed") && (item.errorMessage ? /* @__PURE__ */ jsx(XMarkdown_default, { message: message4, components: customComponents, content: item.errorMessage }) : null),
|
|
5346
5414
|
item.type === "files" && /* @__PURE__ */ jsx(FilesNode, { item }, `files-${index}`),
|
|
5347
5415
|
item.type === "plan" && /* @__PURE__ */ jsx(A2uiPlanNode, { item }, `plan-${index}`)
|
|
5348
5416
|
] })
|
|
5349
5417
|
}
|
|
5350
5418
|
),
|
|
5351
|
-
index === lastToolCallIndex && messageIndex >= 0 ? /* @__PURE__ */ jsx(A2uiMessageCards, { messageIndex, message:
|
|
5419
|
+
index === lastToolCallIndex && messageIndex >= 0 ? /* @__PURE__ */ jsx(A2uiMessageCards, { messageIndex, message: message4 }) : null
|
|
5352
5420
|
] }, `message-${index}`)),
|
|
5353
5421
|
showPending && role.user === "agent" && /* @__PURE__ */ jsx(Bubble, { role: role.user, placement: role.placement, content: /* @__PURE__ */ jsx(RunStartedNode, {}) }),
|
|
5354
5422
|
quoteMsg && /* @__PURE__ */ jsx(QuoteMsgNode, { quoteMsg, role })
|
|
@@ -5444,13 +5512,13 @@ var BubbleListItems_default = ({
|
|
|
5444
5512
|
const messageRefs = useRef({});
|
|
5445
5513
|
const chatRecords = useMemo(() => {
|
|
5446
5514
|
const chatRecords2 = [];
|
|
5447
|
-
conversationMessages.forEach((
|
|
5448
|
-
const role = getRole(
|
|
5515
|
+
conversationMessages.forEach((message4, messageIndex) => {
|
|
5516
|
+
const role = getRole(message4.role);
|
|
5449
5517
|
const isLeftBubble = role.user === "agent";
|
|
5450
|
-
const isMessageLoading = !!
|
|
5451
|
-
const baseKey = `${
|
|
5518
|
+
const isMessageLoading = !!message4.generating;
|
|
5519
|
+
const baseKey = `${message4.executionId}-${messageIndex}`;
|
|
5452
5520
|
const footerNode = !isMessageLoading ? /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 8, children: [
|
|
5453
|
-
|
|
5521
|
+
message4.stopFlag && isLeftBubble && /* @__PURE__ */ jsx(Text3, { type: "secondary", style: { flex: "none" }, children: "\u5DF2\u505C\u6B62" }),
|
|
5454
5522
|
/* @__PURE__ */ jsx(Flex, { align: "center", gap: 4, children: role.user === "agent" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5455
5523
|
/* @__PURE__ */ jsx(
|
|
5456
5524
|
Button,
|
|
@@ -5470,21 +5538,21 @@ var BubbleListItems_default = ({
|
|
|
5470
5538
|
/* @__PURE__ */ jsx(
|
|
5471
5539
|
Button,
|
|
5472
5540
|
{
|
|
5473
|
-
color:
|
|
5541
|
+
color: message4.feedback === 1 ? "primary" : "default",
|
|
5474
5542
|
size: "small",
|
|
5475
5543
|
variant: "text",
|
|
5476
5544
|
icon: /* @__PURE__ */ jsx(LikeOutlined, {}),
|
|
5477
|
-
onClick: () => chatStore.feedback(
|
|
5545
|
+
onClick: () => chatStore.feedback(message4.executionId, 1, messageIndex)
|
|
5478
5546
|
}
|
|
5479
5547
|
),
|
|
5480
5548
|
/* @__PURE__ */ jsx(
|
|
5481
5549
|
Button,
|
|
5482
5550
|
{
|
|
5483
|
-
color:
|
|
5551
|
+
color: message4.feedback === 2 ? "primary" : "default",
|
|
5484
5552
|
size: "small",
|
|
5485
5553
|
variant: "text",
|
|
5486
5554
|
icon: /* @__PURE__ */ jsx(DislikeOutlined, {}),
|
|
5487
|
-
onClick: () => chatStore.feedback(
|
|
5555
|
+
onClick: () => chatStore.feedback(message4.executionId, 2, messageIndex)
|
|
5488
5556
|
}
|
|
5489
5557
|
),
|
|
5490
5558
|
/* @__PURE__ */ jsx(
|
|
@@ -5492,7 +5560,7 @@ var BubbleListItems_default = ({
|
|
|
5492
5560
|
{
|
|
5493
5561
|
control: agentActions,
|
|
5494
5562
|
ctx: {
|
|
5495
|
-
message:
|
|
5563
|
+
message: message4,
|
|
5496
5564
|
get dom() {
|
|
5497
5565
|
return messageRefs.current[baseKey];
|
|
5498
5566
|
}
|
|
@@ -5510,7 +5578,7 @@ var BubbleListItems_default = ({
|
|
|
5510
5578
|
MessageRender_default,
|
|
5511
5579
|
{
|
|
5512
5580
|
role,
|
|
5513
|
-
message:
|
|
5581
|
+
message: message4,
|
|
5514
5582
|
messageIndex,
|
|
5515
5583
|
customComponents,
|
|
5516
5584
|
loading: isMessageLoading,
|
|
@@ -6563,6 +6631,8 @@ var layouts_default = forwardRef(({ theme: theme5, params, hooks, layout, config
|
|
|
6563
6631
|
useDeepEffect(() => {
|
|
6564
6632
|
if (agentState.agentInfo.id) {
|
|
6565
6633
|
chatStore.initConversation(config);
|
|
6634
|
+
} else if (config.conversationId) {
|
|
6635
|
+
chatStore.switchConversation(config.conversationId);
|
|
6566
6636
|
}
|
|
6567
6637
|
}, [agentState.agentInfo.id, config.conversationId]);
|
|
6568
6638
|
const hasPreView = useMemo(() => {
|
|
@@ -6581,13 +6651,13 @@ var layouts_default = forwardRef(({ theme: theme5, params, hooks, layout, config
|
|
|
6581
6651
|
}, [hasPreView]);
|
|
6582
6652
|
useWebSocket({
|
|
6583
6653
|
url: configState.services.websocketUrls?.[0],
|
|
6584
|
-
onMessage: (
|
|
6654
|
+
onMessage: (message4) => chatStore.acceptMessage(message4.payload),
|
|
6585
6655
|
clientHeartbeat: false,
|
|
6586
6656
|
reconnectInterval: 1e4
|
|
6587
6657
|
});
|
|
6588
6658
|
useWebSocket({
|
|
6589
6659
|
url: configState.services.websocketUrls?.[1],
|
|
6590
|
-
onMessage: (
|
|
6660
|
+
onMessage: (message4) => chatStore.acceptMessage(message4.payload),
|
|
6591
6661
|
clientHeartbeat: false,
|
|
6592
6662
|
reconnectInterval: 1e4
|
|
6593
6663
|
});
|
|
@@ -6607,6 +6677,6 @@ var layouts_default = forwardRef(({ theme: theme5, params, hooks, layout, config
|
|
|
6607
6677
|
] }) }) }) });
|
|
6608
6678
|
});
|
|
6609
6679
|
|
|
6610
|
-
export { Attachments_default as Attachments, layouts_default as ChatCopilot, ChatSender_default as ChatSender, getFileIcon, getFileUrl };
|
|
6680
|
+
export { Attachments_default as Attachments, layouts_default as ChatCopilot, ChatSender_default as ChatSender, WorkspaceTypeEnum, getFileIcon, getFileUrl };
|
|
6611
6681
|
//# sourceMappingURL=index.esm.js.map
|
|
6612
6682
|
//# sourceMappingURL=index.esm.js.map
|