@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.cjs.js
CHANGED
|
@@ -74,7 +74,7 @@ var styles_module_default = {
|
|
|
74
74
|
chatAttachments: "styles_module_chatAttachments",
|
|
75
75
|
chatSender: "styles_module_chatSender"};
|
|
76
76
|
var Attachments_default = React10.forwardRef(({ fileUpload, fileUploadConfig, fileList = [], onChange, extraParams }, ref) => {
|
|
77
|
-
const { message:
|
|
77
|
+
const { message: message4 } = antd.App.useApp();
|
|
78
78
|
const chatStore = useChatStore();
|
|
79
79
|
const configState = valtio.useSnapshot(chatStore.config);
|
|
80
80
|
const fileListRef = React10.useRef([]);
|
|
@@ -102,7 +102,7 @@ var Attachments_default = React10.forwardRef(({ fileUpload, fileUploadConfig, fi
|
|
|
102
102
|
onChange(files);
|
|
103
103
|
}, [attachedFiles]);
|
|
104
104
|
const onErrorTip = common.useDebounce((errorMsg) => {
|
|
105
|
-
|
|
105
|
+
message4.error(errorMsg);
|
|
106
106
|
}, 300);
|
|
107
107
|
const findConfig = (file) => {
|
|
108
108
|
return fileUploadConfig?.allowedTypes?.find((type) => type === common.getFileSuffixName(file.name)) || "";
|
|
@@ -267,9 +267,19 @@ var index_module_default = {
|
|
|
267
267
|
};
|
|
268
268
|
|
|
269
269
|
// src/core/constants.ts
|
|
270
|
+
var WorkspaceTypeEnum = /* @__PURE__ */ ((WorkspaceTypeEnum2) => {
|
|
271
|
+
WorkspaceTypeEnum2["GLOBAL"] = "global";
|
|
272
|
+
WorkspaceTypeEnum2["SKILL"] = "skill";
|
|
273
|
+
WorkspaceTypeEnum2["CONVERSATION"] = "conversation";
|
|
274
|
+
WorkspaceTypeEnum2["KNOWLEDGE"] = "knowledge";
|
|
275
|
+
WorkspaceTypeEnum2["PROJECT"] = "project";
|
|
276
|
+
WorkspaceTypeEnum2["DEV_SKILL"] = "devSkill";
|
|
277
|
+
return WorkspaceTypeEnum2;
|
|
278
|
+
})(WorkspaceTypeEnum || {});
|
|
270
279
|
var CONV_MODE = {
|
|
271
280
|
PROD: 1};
|
|
272
281
|
var TOKEN_KEY = "NS-TOKEN";
|
|
282
|
+
var SHARE_KEY = "SHARE-TOKEN";
|
|
273
283
|
var tokenManager = common.createTokenManager({
|
|
274
284
|
key: TOKEN_KEY
|
|
275
285
|
});
|
|
@@ -361,8 +371,9 @@ var getFileIcon = (extension, fontSize = 24) => {
|
|
|
361
371
|
return createIcon(icons.FileUnknownOutlined, "#94a3b8");
|
|
362
372
|
};
|
|
363
373
|
var getFileUrl = (params, baseUrl, url) => {
|
|
374
|
+
const authParams = baseUrl === "/luya/share" ? { [SHARE_KEY]: localStorage.getItem(SHARE_KEY) || "" } : { [TOKEN_KEY]: tokenManager.get() };
|
|
364
375
|
const data = {
|
|
365
|
-
|
|
376
|
+
...authParams,
|
|
366
377
|
workspaceType: "conversation" /* CONVERSATION */,
|
|
367
378
|
...params
|
|
368
379
|
};
|
|
@@ -851,7 +862,7 @@ var ChatInput = React10__namespace.forwardRef(
|
|
|
851
862
|
}
|
|
852
863
|
}
|
|
853
864
|
),
|
|
854
|
-
placeholder: !stringValue
|
|
865
|
+
placeholder: !stringValue ? /* @__PURE__ */ jsxRuntime.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,
|
|
855
866
|
ErrorBoundary: LexicalErrorBoundary.LexicalErrorBoundary
|
|
856
867
|
}
|
|
857
868
|
),
|
|
@@ -865,6 +876,7 @@ var ChatInput = React10__namespace.forwardRef(
|
|
|
865
876
|
var ChatInput_default = ChatInput;
|
|
866
877
|
var ChatSender_default = React10.forwardRef(
|
|
867
878
|
({
|
|
879
|
+
placeholder,
|
|
868
880
|
content,
|
|
869
881
|
commandConfig = {},
|
|
870
882
|
fileList = [],
|
|
@@ -937,6 +949,7 @@ var ChatSender_default = React10.forwardRef(
|
|
|
937
949
|
className: styles_module_default.chatSender,
|
|
938
950
|
ref: senderRef,
|
|
939
951
|
value: inputValue,
|
|
952
|
+
placeholder,
|
|
940
953
|
header: senderHeader,
|
|
941
954
|
onSubmit,
|
|
942
955
|
onChange: setInputValue,
|
|
@@ -1032,6 +1045,9 @@ var createChatService = (request, config) => {
|
|
|
1032
1045
|
const conversationFavorite = (conversationId, isFavorite) => {
|
|
1033
1046
|
return request.put("/agents/conversations/favorite", { conversationIds: [conversationId], favorite: isFavorite });
|
|
1034
1047
|
};
|
|
1048
|
+
const shareConversation = (conversationId) => {
|
|
1049
|
+
return request.get(`/agents/conversations/${conversationId}/share/url`);
|
|
1050
|
+
};
|
|
1035
1051
|
return {
|
|
1036
1052
|
fetchModelList,
|
|
1037
1053
|
fetchAgentInfo,
|
|
@@ -1051,7 +1067,8 @@ var createChatService = (request, config) => {
|
|
|
1051
1067
|
listDataSources,
|
|
1052
1068
|
listTags,
|
|
1053
1069
|
getAgentAvatar,
|
|
1054
|
-
conversationFavorite
|
|
1070
|
+
conversationFavorite,
|
|
1071
|
+
shareConversation
|
|
1055
1072
|
};
|
|
1056
1073
|
};
|
|
1057
1074
|
|
|
@@ -1097,7 +1114,13 @@ function createChatStore() {
|
|
|
1097
1114
|
return await config.services.request.fetchModelList();
|
|
1098
1115
|
};
|
|
1099
1116
|
const setServices = ({ http, websocket } = {}) => {
|
|
1100
|
-
const
|
|
1117
|
+
const baseURL = http?.config?.baseURL || "/luya/v1";
|
|
1118
|
+
const headers = baseURL === "/luya/share" ? { [SHARE_KEY]: localStorage.getItem(SHARE_KEY) || "" } : { [TOKEN_KEY]: tokenManager.get() };
|
|
1119
|
+
const httpConfig = {
|
|
1120
|
+
baseURL,
|
|
1121
|
+
headers,
|
|
1122
|
+
...http?.config
|
|
1123
|
+
};
|
|
1101
1124
|
const request = common.createRequest(httpConfig);
|
|
1102
1125
|
if (config.hooks?.onRequestInterceptor) {
|
|
1103
1126
|
request.instance.interceptors.request.use(...config.hooks.onRequestInterceptor);
|
|
@@ -1118,9 +1141,9 @@ function createChatStore() {
|
|
|
1118
1141
|
config.services.request = { ...createChatService(request, httpConfig), ...http?.request };
|
|
1119
1142
|
config.services.websocketUrls = ["", ""];
|
|
1120
1143
|
if (common.isArray(websocket?.baseURLs)) {
|
|
1121
|
-
websocket.baseURLs.forEach((
|
|
1122
|
-
if (common.isString(
|
|
1123
|
-
config.services.websocketUrls[index] = getChatSocketUrl(
|
|
1144
|
+
websocket.baseURLs.forEach((baseURL2, index) => {
|
|
1145
|
+
if (common.isString(baseURL2)) {
|
|
1146
|
+
config.services.websocketUrls[index] = getChatSocketUrl(baseURL2, websocket?.params || httpConfig.headers);
|
|
1124
1147
|
}
|
|
1125
1148
|
});
|
|
1126
1149
|
} else {
|
|
@@ -1623,7 +1646,7 @@ function createChatStore() {
|
|
|
1623
1646
|
}
|
|
1624
1647
|
if (isMain) config.hooks?.onStepMessage?.(msg);
|
|
1625
1648
|
}
|
|
1626
|
-
function doneCallback(msg,
|
|
1649
|
+
function doneCallback(msg, message4, isMain) {
|
|
1627
1650
|
conversation.messages[msg.conversationId].loading = false;
|
|
1628
1651
|
const messages = conversation.messages[msg.conversationId]?.message;
|
|
1629
1652
|
if (messages) {
|
|
@@ -1916,9 +1939,9 @@ function createChatStore() {
|
|
|
1916
1939
|
}
|
|
1917
1940
|
}
|
|
1918
1941
|
}
|
|
1919
|
-
function processMessageContent(
|
|
1942
|
+
function processMessageContent(message4, targetMessages) {
|
|
1920
1943
|
const newMessage = {
|
|
1921
|
-
...
|
|
1944
|
+
...message4,
|
|
1922
1945
|
agentId: agent.agentInfo.id
|
|
1923
1946
|
};
|
|
1924
1947
|
const isMain = !targetMessages;
|
|
@@ -1986,13 +2009,13 @@ function createChatStore() {
|
|
|
1986
2009
|
}
|
|
1987
2010
|
processMessageContent(newMessage);
|
|
1988
2011
|
};
|
|
1989
|
-
const sendMessage = async (
|
|
2012
|
+
const sendMessage = async (message4, msgFiles = [], params) => {
|
|
1990
2013
|
const conversationId = conversation.active.id;
|
|
1991
2014
|
if (conversation.messages[conversationId].loading) return;
|
|
1992
2015
|
let msgContent = "", files;
|
|
1993
2016
|
const references = conversation.messages[conversationId].references;
|
|
1994
|
-
if (
|
|
1995
|
-
msgContent =
|
|
2017
|
+
if (message4) {
|
|
2018
|
+
msgContent = message4;
|
|
1996
2019
|
files = [...msgFiles, ...conversation.messages[conversationId].files || []];
|
|
1997
2020
|
} else {
|
|
1998
2021
|
if (references?.type === 1 && references?.content?.msgContent) {
|
|
@@ -2039,9 +2062,9 @@ function createChatStore() {
|
|
|
2039
2062
|
};
|
|
2040
2063
|
const extraParams = common.deepCopy(config.params?.params || {});
|
|
2041
2064
|
const userInputParams = variablesToObject(conversation.active.userInput || []);
|
|
2042
|
-
Object.assign(extraParams,
|
|
2065
|
+
Object.assign(extraParams, message4 ? {} : { ...references?.params }, params, userInputParams);
|
|
2043
2066
|
sendParams.params = extraParams;
|
|
2044
|
-
if (!
|
|
2067
|
+
if (!message4) {
|
|
2045
2068
|
setContent("");
|
|
2046
2069
|
setContentParams();
|
|
2047
2070
|
setReferences();
|
|
@@ -2242,7 +2265,7 @@ var ConversationFavoritesBtn_default = ({ icon, ...rest }) => {
|
|
|
2242
2265
|
const activeConversation = React10.useMemo(() => {
|
|
2243
2266
|
return conversationsState.list.items.find((item) => item.id === conversationState.active.id);
|
|
2244
2267
|
}, [conversationsState.list.items, conversationState.active.id]);
|
|
2245
|
-
const isFavorite =
|
|
2268
|
+
const isFavorite = activeConversation?.isFavorite === true;
|
|
2246
2269
|
const handleToggleFavorite = () => {
|
|
2247
2270
|
if (!conversationState.active.id) return;
|
|
2248
2271
|
chatStore.collectConversation(conversationState.active.id, !isFavorite);
|
|
@@ -2252,7 +2275,7 @@ var ConversationFavoritesBtn_default = ({ icon, ...rest }) => {
|
|
|
2252
2275
|
{
|
|
2253
2276
|
title: isFavorite ? "\u53D6\u6D88\u6536\u85CF" : "\u6536\u85CF",
|
|
2254
2277
|
type: "text",
|
|
2255
|
-
size: "
|
|
2278
|
+
size: "large",
|
|
2256
2279
|
disabled: !conversationState.active.id,
|
|
2257
2280
|
icon: icon?.() || (isFavorite ? /* @__PURE__ */ jsxRuntime.jsx(icons.StarFilled, { className: "primary-text" }) : /* @__PURE__ */ jsxRuntime.jsx(icons.StarOutlined, {})),
|
|
2258
2281
|
onClick: handleToggleFavorite,
|
|
@@ -2260,9 +2283,37 @@ var ConversationFavoritesBtn_default = ({ icon, ...rest }) => {
|
|
|
2260
2283
|
}
|
|
2261
2284
|
);
|
|
2262
2285
|
};
|
|
2286
|
+
var ConversationShareBtn_default = ({ icon, ...rest }) => {
|
|
2287
|
+
const chatStore = useChatStore();
|
|
2288
|
+
const conversationState = valtio.useSnapshot(chatStore.conversation);
|
|
2289
|
+
const configState = valtio.useSnapshot(chatStore.config);
|
|
2290
|
+
const handleShareConversation = async () => {
|
|
2291
|
+
try {
|
|
2292
|
+
const { data } = await configState.services.request.shareConversation(conversationState.active.id);
|
|
2293
|
+
if (data) {
|
|
2294
|
+
common.copyText(data);
|
|
2295
|
+
antd.message.success("\u5206\u4EAB\u94FE\u63A5\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F");
|
|
2296
|
+
}
|
|
2297
|
+
} catch (error) {
|
|
2298
|
+
antd.message.error("\u5206\u4EAB\u4F1A\u8BDD\u5931\u8D25");
|
|
2299
|
+
}
|
|
2300
|
+
};
|
|
2301
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2302
|
+
antd.Button,
|
|
2303
|
+
{
|
|
2304
|
+
title: "\u5206\u4EAB",
|
|
2305
|
+
type: "text",
|
|
2306
|
+
size: "large",
|
|
2307
|
+
disabled: !conversationState.active.id,
|
|
2308
|
+
icon: icon?.() || /* @__PURE__ */ jsxRuntime.jsx(icons.ShareAltOutlined, {}),
|
|
2309
|
+
...rest,
|
|
2310
|
+
onClick: handleShareConversation
|
|
2311
|
+
}
|
|
2312
|
+
);
|
|
2313
|
+
};
|
|
2263
2314
|
var CreateBtn_default = ({ icon, ...rest }) => {
|
|
2264
2315
|
const chatStore = useChatStore();
|
|
2265
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { title: "\u65B0\u5EFA\u4F1A\u8BDD", size: "
|
|
2316
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { title: "\u65B0\u5EFA\u4F1A\u8BDD", size: "large", type: "text", icon: icon?.() || /* @__PURE__ */ jsxRuntime.jsx(icons.PlusOutlined, {}), onClick: () => chatStore.createConversation(), ...rest });
|
|
2266
2317
|
};
|
|
2267
2318
|
|
|
2268
2319
|
// src/ui/common/styles.module.less
|
|
@@ -2360,7 +2411,7 @@ var ConversationList_default = () => {
|
|
|
2360
2411
|
antd.Button,
|
|
2361
2412
|
{
|
|
2362
2413
|
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.DeleteOutlined, {}),
|
|
2363
|
-
title: "\
|
|
2414
|
+
title: "\u53D6\u6D88\u6536\u85CF",
|
|
2364
2415
|
type: "text",
|
|
2365
2416
|
onClick: (e) => {
|
|
2366
2417
|
e.stopPropagation();
|
|
@@ -2481,7 +2532,7 @@ var HistoryBtn_default = ({ icon, ...rest }) => {
|
|
|
2481
2532
|
classNames: { container: style_module_default.popover },
|
|
2482
2533
|
content: /* @__PURE__ */ jsxRuntime.jsx(ConversationList_default, {}),
|
|
2483
2534
|
trigger: ["click"],
|
|
2484
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { title: "\u5386\u53F2\u4F1A\u8BDD", size: "
|
|
2535
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { title: "\u5386\u53F2\u4F1A\u8BDD", size: "large", type: "text", icon: icon?.() || /* @__PURE__ */ jsxRuntime.jsx(icons.CommentOutlined, {}), ...rest })
|
|
2485
2536
|
}
|
|
2486
2537
|
);
|
|
2487
2538
|
};
|
|
@@ -2491,7 +2542,8 @@ var ChatHeader_default = ({
|
|
|
2491
2542
|
closeBtn = false,
|
|
2492
2543
|
newConversationBtn = true,
|
|
2493
2544
|
conversationListBtn = true,
|
|
2494
|
-
conversationFavoriteBtn = true
|
|
2545
|
+
conversationFavoriteBtn = true,
|
|
2546
|
+
conversationShareBtn = true
|
|
2495
2547
|
}) => {
|
|
2496
2548
|
const chatStore = useChatStore();
|
|
2497
2549
|
const agentState = valtio.useSnapshot(chatStore.agent);
|
|
@@ -2512,7 +2564,8 @@ var ChatHeader_default = ({
|
|
|
2512
2564
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default2.chatHeaderBtnGroup, children: [
|
|
2513
2565
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: newConversationBtn, DefaultComponent: CreateBtn_default }),
|
|
2514
2566
|
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: conversationListBtn, DefaultComponent: HistoryBtn_default }),
|
|
2515
|
-
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: conversationFavoriteBtn, DefaultComponent: ConversationFavoritesBtn_default })
|
|
2567
|
+
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: conversationFavoriteBtn, DefaultComponent: ConversationFavoritesBtn_default }),
|
|
2568
|
+
/* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: conversationShareBtn, DefaultComponent: ConversationShareBtn_default })
|
|
2516
2569
|
] }),
|
|
2517
2570
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2518
2571
|
common.RenderWrapper,
|
|
@@ -3120,12 +3173,12 @@ var DocDrawer_default = ({ title, open, onClose, paramsStr }) => {
|
|
|
3120
3173
|
}, [paramsStr]);
|
|
3121
3174
|
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" }) }) });
|
|
3122
3175
|
};
|
|
3123
|
-
var IndexQuote_default = ({ data, loading, message:
|
|
3176
|
+
var IndexQuote_default = ({ data, loading, message: message4 }) => {
|
|
3124
3177
|
const [open, setOpen] = React10.useState(false);
|
|
3125
3178
|
const citation = React10.useMemo(() => {
|
|
3126
|
-
const citations =
|
|
3179
|
+
const citations = message4.content?.find((item) => item.type === "citation")?.citations ?? [];
|
|
3127
3180
|
return citations?.find((item) => String(item.citationId) === String(data.citationId));
|
|
3128
|
-
}, [data.citationId,
|
|
3181
|
+
}, [data.citationId, message4.content]);
|
|
3129
3182
|
const onClick = () => {
|
|
3130
3183
|
if (!citation?.citationUrl) return;
|
|
3131
3184
|
if (common.isExternal(citation.citationUrl)) {
|
|
@@ -3140,7 +3193,7 @@ var IndexQuote_default = ({ data, loading, message: message3 }) => {
|
|
|
3140
3193
|
open && /* @__PURE__ */ jsxRuntime.jsx(DocDrawer_default, { paramsStr: citation?.citationUrl, title: citation?.citationName, open, onClose: () => setOpen(false) })
|
|
3141
3194
|
] });
|
|
3142
3195
|
};
|
|
3143
|
-
var MarkImg_default = ({ data, loading, message:
|
|
3196
|
+
var MarkImg_default = ({ data, loading, message: message4, ...rest }) => {
|
|
3144
3197
|
const getPreviewFileUrl = (src) => {
|
|
3145
3198
|
return common.buildUrlParams({ [TOKEN_KEY]: tokenManager.get() || "" }, src);
|
|
3146
3199
|
};
|
|
@@ -3167,8 +3220,9 @@ var MdEdit_default = ({ data, loading }) => {
|
|
|
3167
3220
|
!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 }) })
|
|
3168
3221
|
] });
|
|
3169
3222
|
};
|
|
3170
|
-
var PreviewLink_default = ({ data, loading, message:
|
|
3223
|
+
var PreviewLink_default = ({ data, loading, message: message4, ...rest }) => {
|
|
3171
3224
|
const chatStore = useChatStore();
|
|
3225
|
+
const conversationWorkspacePrefix = "/workspace/conversation/";
|
|
3172
3226
|
const getLinkFileName = (path) => {
|
|
3173
3227
|
const lastSegment = path.split("/").pop();
|
|
3174
3228
|
if (!lastSegment) {
|
|
@@ -3180,13 +3234,27 @@ var PreviewLink_default = ({ data, loading, message: message3, ...rest }) => {
|
|
|
3180
3234
|
return lastSegment;
|
|
3181
3235
|
}
|
|
3182
3236
|
};
|
|
3183
|
-
const
|
|
3237
|
+
const normalizePreviewPath = (path) => {
|
|
3238
|
+
if (!path) {
|
|
3239
|
+
return path;
|
|
3240
|
+
}
|
|
3241
|
+
if (path.startsWith(conversationWorkspacePrefix)) {
|
|
3242
|
+
return path;
|
|
3243
|
+
}
|
|
3244
|
+
if (path.startsWith(conversationWorkspacePrefix.slice(1))) {
|
|
3245
|
+
return `/${path}`;
|
|
3246
|
+
}
|
|
3184
3247
|
const fileName = getLinkFileName(path);
|
|
3248
|
+
return `${conversationWorkspacePrefix}${fileName}`;
|
|
3249
|
+
};
|
|
3250
|
+
const handlePreviewByPath = (path) => {
|
|
3251
|
+
const normalizedPath = normalizePreviewPath(path);
|
|
3252
|
+
const fileName = getLinkFileName(normalizedPath);
|
|
3185
3253
|
const suffix = common.getFileSuffixName(fileName);
|
|
3186
3254
|
chatStore.setPreview({
|
|
3187
3255
|
fileUrl: chatStore.config.services.request.getPreviewUrl({
|
|
3188
|
-
path,
|
|
3189
|
-
workspaceId:
|
|
3256
|
+
path: normalizedPath,
|
|
3257
|
+
workspaceId: message4.conversationId
|
|
3190
3258
|
}),
|
|
3191
3259
|
fileName,
|
|
3192
3260
|
suffix
|
|
@@ -3299,7 +3367,7 @@ var adaptMarkdownComponent = (Component, payloadMapRef, messageRef) => {
|
|
|
3299
3367
|
return WrappedComponent;
|
|
3300
3368
|
};
|
|
3301
3369
|
var adaptMarkdownComponents = (components, payloadMapRef, messageRef) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component, payloadMapRef, messageRef)]));
|
|
3302
|
-
var XMarkdown_default = React10.memo(({ message:
|
|
3370
|
+
var XMarkdown_default = React10.memo(({ message: message4, components = {}, content = "", ...rest }) => {
|
|
3303
3371
|
const config = React10.useMemo(() => getMarkdownConfig(), []);
|
|
3304
3372
|
const formattedContent = React10.useMemo(() => formatMixedContent(content), [content]);
|
|
3305
3373
|
const newComponents = React10.useMemo(
|
|
@@ -3325,9 +3393,9 @@ var XMarkdown_default = React10.memo(({ message: message3, components = {}, cont
|
|
|
3325
3393
|
[formattedContent, payloadTagPattern]
|
|
3326
3394
|
);
|
|
3327
3395
|
const payloadMapRef = React10.useRef(payloadMap);
|
|
3328
|
-
const messageRef = React10.useRef(
|
|
3396
|
+
const messageRef = React10.useRef(message4);
|
|
3329
3397
|
payloadMapRef.current = payloadMap;
|
|
3330
|
-
messageRef.current =
|
|
3398
|
+
messageRef.current = message4;
|
|
3331
3399
|
const markdownComponents = React10.useMemo(() => adaptMarkdownComponents(newComponents, payloadMapRef, messageRef), [payloadTagPattern]);
|
|
3332
3400
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3333
3401
|
XMarkdown__default.default,
|
|
@@ -3677,7 +3745,7 @@ var Switch = ({ id, label, value, bind_path_token, onChange, onDataChange }) =>
|
|
|
3677
3745
|
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 13, color: "#555" }, children: label })
|
|
3678
3746
|
] });
|
|
3679
3747
|
};
|
|
3680
|
-
var
|
|
3748
|
+
var Button12 = ({ label, variant = "default", onClick, action, onAction }) => {
|
|
3681
3749
|
const handleClick = () => {
|
|
3682
3750
|
if (onClick) {
|
|
3683
3751
|
onClick();
|
|
@@ -3707,7 +3775,7 @@ var A2uiComponents = {
|
|
|
3707
3775
|
TextField,
|
|
3708
3776
|
Select,
|
|
3709
3777
|
Switch,
|
|
3710
|
-
Button:
|
|
3778
|
+
Button: Button12,
|
|
3711
3779
|
Divider,
|
|
3712
3780
|
Tag: Tag3,
|
|
3713
3781
|
Progress,
|
|
@@ -3754,10 +3822,10 @@ function extractDismissedSurfaceIdsFromMessages(messages) {
|
|
|
3754
3822
|
const lastCreateIndexBySurface = /* @__PURE__ */ new Map();
|
|
3755
3823
|
const lastActionIndexBySurface = /* @__PURE__ */ new Map();
|
|
3756
3824
|
for (let messageIndex = 0; messageIndex < messages.length; messageIndex++) {
|
|
3757
|
-
const
|
|
3758
|
-
const items = Array.isArray(
|
|
3825
|
+
const message4 = messages[messageIndex];
|
|
3826
|
+
const items = Array.isArray(message4?.content) ? message4.content : [];
|
|
3759
3827
|
for (const item of items) {
|
|
3760
|
-
if (
|
|
3828
|
+
if (message4?.role !== 1) {
|
|
3761
3829
|
if (item?.type === "a2uiCommand" && item.command) {
|
|
3762
3830
|
const surfaceId = String(item.command?.createSurface?.surfaceId || "").trim();
|
|
3763
3831
|
if (surfaceId) lastCreateIndexBySurface.set(surfaceId, messageIndex);
|
|
@@ -3773,7 +3841,7 @@ function extractDismissedSurfaceIdsFromMessages(messages) {
|
|
|
3773
3841
|
}
|
|
3774
3842
|
}
|
|
3775
3843
|
}
|
|
3776
|
-
if (
|
|
3844
|
+
if (message4?.role === 1 && item?.type === "text") {
|
|
3777
3845
|
const text = item.messageContent || item.text || "";
|
|
3778
3846
|
if (typeof text !== "string" || !text.includes("a2ui_action.v1")) continue;
|
|
3779
3847
|
try {
|
|
@@ -4356,9 +4424,9 @@ function diffConversationMessages(messages, prevCursors) {
|
|
|
4356
4424
|
const nextCursors = [];
|
|
4357
4425
|
const pendingItems = [];
|
|
4358
4426
|
for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
|
|
4359
|
-
const
|
|
4360
|
-
const messageId = String(
|
|
4361
|
-
const items = Array.isArray(
|
|
4427
|
+
const message4 = messages[messageIndex];
|
|
4428
|
+
const messageId = String(message4?.messageId ?? messageIndex);
|
|
4429
|
+
const items = Array.isArray(message4?.content) ? message4.content : [];
|
|
4362
4430
|
const prevCursor = prevCursors[messageIndex];
|
|
4363
4431
|
const startIndex = prevCursor ? prevCursor.contentLength : 0;
|
|
4364
4432
|
if (prevCursor && (prevCursor.messageId !== messageId || items.length < prevCursor.contentLength)) {
|
|
@@ -4375,9 +4443,9 @@ function scanA2uiTagsFromMessages(messages, processedTagIds) {
|
|
|
4375
4443
|
const newTags = [];
|
|
4376
4444
|
const newTagIds = [];
|
|
4377
4445
|
for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
|
|
4378
|
-
const
|
|
4379
|
-
const messageId = String(
|
|
4380
|
-
const items = Array.isArray(
|
|
4446
|
+
const message4 = messages[messageIndex];
|
|
4447
|
+
const messageId = String(message4?.messageId ?? messageIndex);
|
|
4448
|
+
const items = Array.isArray(message4?.content) ? message4.content : [];
|
|
4381
4449
|
for (const item of items) {
|
|
4382
4450
|
const text = extractItemTextForA2ui(item);
|
|
4383
4451
|
if (typeof text !== "string" || !text.includes("<A2UI")) continue;
|
|
@@ -4433,9 +4501,9 @@ function reduceA2uiRuntimeMessages(state, messages) {
|
|
|
4433
4501
|
processA2uiCommand(cmd, messageIndex, messageId, nextState, effects, deletedSurfaceIds, nextWizardSteps);
|
|
4434
4502
|
}
|
|
4435
4503
|
});
|
|
4436
|
-
nextState.processedMessageCursors = shouldReplayAll ? messages.map((
|
|
4437
|
-
messageId: String(
|
|
4438
|
-
contentLength: Array.isArray(
|
|
4504
|
+
nextState.processedMessageCursors = shouldReplayAll ? messages.map((message4, messageIndex) => ({
|
|
4505
|
+
messageId: String(message4?.messageId ?? messageIndex),
|
|
4506
|
+
contentLength: Array.isArray(message4?.content) ? message4.content.length : 0
|
|
4439
4507
|
})) : nextCursors;
|
|
4440
4508
|
nextState.wizardStepBySurface = { ...nextState.wizardStepBySurface, ...nextWizardSteps };
|
|
4441
4509
|
if (deletedSurfaceIds.size) {
|
|
@@ -4783,8 +4851,8 @@ function readContextModelPath(context) {
|
|
|
4783
4851
|
function buildLatestCommandIndexBySurface(messages) {
|
|
4784
4852
|
const indexBySurface = {};
|
|
4785
4853
|
let commandIndex = -1;
|
|
4786
|
-
for (const
|
|
4787
|
-
const items = Array.isArray(
|
|
4854
|
+
for (const message4 of messages) {
|
|
4855
|
+
const items = Array.isArray(message4?.content) ? message4.content : [];
|
|
4788
4856
|
for (const item of items) {
|
|
4789
4857
|
if (item?.type === "a2uiCommand" && item.command) {
|
|
4790
4858
|
commandIndex += 1;
|
|
@@ -4972,7 +5040,7 @@ var TextNode2 = React10__namespace.default.memo(
|
|
|
4972
5040
|
item,
|
|
4973
5041
|
role,
|
|
4974
5042
|
customComponents,
|
|
4975
|
-
message:
|
|
5043
|
+
message: message4
|
|
4976
5044
|
}) => {
|
|
4977
5045
|
const content = toA2uiDisplayText(role, item?.messageContent);
|
|
4978
5046
|
const markdownComponents = {
|
|
@@ -4985,7 +5053,7 @@ var TextNode2 = React10__namespace.default.memo(
|
|
|
4985
5053
|
const markdownContent = typeof content === "string" ? transformResourceText(content) : content;
|
|
4986
5054
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4987
5055
|
!!item.reasoningContent && /* @__PURE__ */ jsxRuntime.jsx(xV2.Think, { title: "\u6DF1\u5EA6\u601D\u8003", style: { marginBottom: "16px" }, children: item.reasoningContent }),
|
|
4988
|
-
!!markdownContent && /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message:
|
|
5056
|
+
!!markdownContent && /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message4, components: markdownComponents, content: markdownContent })
|
|
4989
5057
|
] });
|
|
4990
5058
|
}
|
|
4991
5059
|
);
|
|
@@ -5313,9 +5381,9 @@ var ToolCallItem = ({ item }) => {
|
|
|
5313
5381
|
};
|
|
5314
5382
|
var tool_call_item_default = ToolCallItem;
|
|
5315
5383
|
var RENDERABLE_MESSAGE_TYPES = ["runStarted", "toolCall", "toolResult", "text", "stepError", "runFailed", "files", "plan"];
|
|
5316
|
-
var MessageRender_default = React10__namespace.default.memo(({ role, message:
|
|
5384
|
+
var MessageRender_default = React10__namespace.default.memo(({ role, message: message4, messageIndex = -1, loading, containerRef, customComponents }) => {
|
|
5317
5385
|
const content = React10.useMemo(() => {
|
|
5318
|
-
return (
|
|
5386
|
+
return (message4.content || []).filter((item) => {
|
|
5319
5387
|
if (!RENDERABLE_MESSAGE_TYPES.includes(item.type)) {
|
|
5320
5388
|
return false;
|
|
5321
5389
|
}
|
|
@@ -5328,12 +5396,12 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
|
|
|
5328
5396
|
}
|
|
5329
5397
|
return true;
|
|
5330
5398
|
});
|
|
5331
|
-
}, [
|
|
5399
|
+
}, [message4.content]);
|
|
5332
5400
|
const quoteMsg = React10.useMemo(() => {
|
|
5333
5401
|
const quoteMsg2 = {};
|
|
5334
|
-
if (
|
|
5402
|
+
if (message4.params) {
|
|
5335
5403
|
try {
|
|
5336
|
-
const citation = JSON.parse(
|
|
5404
|
+
const citation = JSON.parse(message4.params).citation;
|
|
5337
5405
|
if (citation) {
|
|
5338
5406
|
quoteMsg2.messageContent = citation;
|
|
5339
5407
|
}
|
|
@@ -5341,7 +5409,7 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
|
|
|
5341
5409
|
}
|
|
5342
5410
|
}
|
|
5343
5411
|
return common.isEmptyObj(quoteMsg2) ? null : quoteMsg2;
|
|
5344
|
-
}, [
|
|
5412
|
+
}, [message4.params, message4.quoteMsg]);
|
|
5345
5413
|
const showPending = loading && (content.length === 0 || content[content.length - 1].type !== "text");
|
|
5346
5414
|
if (content.length === 0 && !showPending) return null;
|
|
5347
5415
|
const lastToolCallIndex = (() => {
|
|
@@ -5365,20 +5433,20 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
|
|
|
5365
5433
|
TextNode2,
|
|
5366
5434
|
{
|
|
5367
5435
|
item,
|
|
5368
|
-
role:
|
|
5436
|
+
role: message4.role,
|
|
5369
5437
|
customComponents,
|
|
5370
|
-
message:
|
|
5438
|
+
message: message4,
|
|
5371
5439
|
messageIndex
|
|
5372
5440
|
},
|
|
5373
5441
|
`message-${index}`
|
|
5374
5442
|
),
|
|
5375
|
-
(item.type === "stepError" || item.type === "runFailed") && (item.errorMessage ? /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message:
|
|
5443
|
+
(item.type === "stepError" || item.type === "runFailed") && (item.errorMessage ? /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message4, components: customComponents, content: item.errorMessage }) : null),
|
|
5376
5444
|
item.type === "files" && /* @__PURE__ */ jsxRuntime.jsx(FilesNode, { item }, `files-${index}`),
|
|
5377
5445
|
item.type === "plan" && /* @__PURE__ */ jsxRuntime.jsx(A2uiPlanNode, { item }, `plan-${index}`)
|
|
5378
5446
|
] })
|
|
5379
5447
|
}
|
|
5380
5448
|
),
|
|
5381
|
-
index === lastToolCallIndex && messageIndex >= 0 ? /* @__PURE__ */ jsxRuntime.jsx(A2uiMessageCards, { messageIndex, message:
|
|
5449
|
+
index === lastToolCallIndex && messageIndex >= 0 ? /* @__PURE__ */ jsxRuntime.jsx(A2uiMessageCards, { messageIndex, message: message4 }) : null
|
|
5382
5450
|
] }, `message-${index}`)),
|
|
5383
5451
|
showPending && role.user === "agent" && /* @__PURE__ */ jsxRuntime.jsx(xV2.Bubble, { role: role.user, placement: role.placement, content: /* @__PURE__ */ jsxRuntime.jsx(RunStartedNode, {}) }),
|
|
5384
5452
|
quoteMsg && /* @__PURE__ */ jsxRuntime.jsx(QuoteMsgNode, { quoteMsg, role })
|
|
@@ -5474,13 +5542,13 @@ var BubbleListItems_default = ({
|
|
|
5474
5542
|
const messageRefs = React10.useRef({});
|
|
5475
5543
|
const chatRecords = React10.useMemo(() => {
|
|
5476
5544
|
const chatRecords2 = [];
|
|
5477
|
-
conversationMessages.forEach((
|
|
5478
|
-
const role = getRole(
|
|
5545
|
+
conversationMessages.forEach((message4, messageIndex) => {
|
|
5546
|
+
const role = getRole(message4.role);
|
|
5479
5547
|
const isLeftBubble = role.user === "agent";
|
|
5480
|
-
const isMessageLoading = !!
|
|
5481
|
-
const baseKey = `${
|
|
5548
|
+
const isMessageLoading = !!message4.generating;
|
|
5549
|
+
const baseKey = `${message4.executionId}-${messageIndex}`;
|
|
5482
5550
|
const footerNode = !isMessageLoading ? /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", gap: 8, children: [
|
|
5483
|
-
|
|
5551
|
+
message4.stopFlag && isLeftBubble && /* @__PURE__ */ jsxRuntime.jsx(Text3, { type: "secondary", style: { flex: "none" }, children: "\u5DF2\u505C\u6B62" }),
|
|
5484
5552
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { align: "center", gap: 4, children: role.user === "agent" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5485
5553
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5486
5554
|
antd.Button,
|
|
@@ -5500,21 +5568,21 @@ var BubbleListItems_default = ({
|
|
|
5500
5568
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5501
5569
|
antd.Button,
|
|
5502
5570
|
{
|
|
5503
|
-
color:
|
|
5571
|
+
color: message4.feedback === 1 ? "primary" : "default",
|
|
5504
5572
|
size: "small",
|
|
5505
5573
|
variant: "text",
|
|
5506
5574
|
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.LikeOutlined, {}),
|
|
5507
|
-
onClick: () => chatStore.feedback(
|
|
5575
|
+
onClick: () => chatStore.feedback(message4.executionId, 1, messageIndex)
|
|
5508
5576
|
}
|
|
5509
5577
|
),
|
|
5510
5578
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5511
5579
|
antd.Button,
|
|
5512
5580
|
{
|
|
5513
|
-
color:
|
|
5581
|
+
color: message4.feedback === 2 ? "primary" : "default",
|
|
5514
5582
|
size: "small",
|
|
5515
5583
|
variant: "text",
|
|
5516
5584
|
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.DislikeOutlined, {}),
|
|
5517
|
-
onClick: () => chatStore.feedback(
|
|
5585
|
+
onClick: () => chatStore.feedback(message4.executionId, 2, messageIndex)
|
|
5518
5586
|
}
|
|
5519
5587
|
),
|
|
5520
5588
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5522,7 +5590,7 @@ var BubbleListItems_default = ({
|
|
|
5522
5590
|
{
|
|
5523
5591
|
control: agentActions,
|
|
5524
5592
|
ctx: {
|
|
5525
|
-
message:
|
|
5593
|
+
message: message4,
|
|
5526
5594
|
get dom() {
|
|
5527
5595
|
return messageRefs.current[baseKey];
|
|
5528
5596
|
}
|
|
@@ -5540,7 +5608,7 @@ var BubbleListItems_default = ({
|
|
|
5540
5608
|
MessageRender_default,
|
|
5541
5609
|
{
|
|
5542
5610
|
role,
|
|
5543
|
-
message:
|
|
5611
|
+
message: message4,
|
|
5544
5612
|
messageIndex,
|
|
5545
5613
|
customComponents,
|
|
5546
5614
|
loading: isMessageLoading,
|
|
@@ -6593,6 +6661,8 @@ var layouts_default = React10.forwardRef(({ theme: theme5, params, hooks, layout
|
|
|
6593
6661
|
common.useDeepEffect(() => {
|
|
6594
6662
|
if (agentState.agentInfo.id) {
|
|
6595
6663
|
chatStore.initConversation(config);
|
|
6664
|
+
} else if (config.conversationId) {
|
|
6665
|
+
chatStore.switchConversation(config.conversationId);
|
|
6596
6666
|
}
|
|
6597
6667
|
}, [agentState.agentInfo.id, config.conversationId]);
|
|
6598
6668
|
const hasPreView = React10.useMemo(() => {
|
|
@@ -6611,13 +6681,13 @@ var layouts_default = React10.forwardRef(({ theme: theme5, params, hooks, layout
|
|
|
6611
6681
|
}, [hasPreView]);
|
|
6612
6682
|
common.useWebSocket({
|
|
6613
6683
|
url: configState.services.websocketUrls?.[0],
|
|
6614
|
-
onMessage: (
|
|
6684
|
+
onMessage: (message4) => chatStore.acceptMessage(message4.payload),
|
|
6615
6685
|
clientHeartbeat: false,
|
|
6616
6686
|
reconnectInterval: 1e4
|
|
6617
6687
|
});
|
|
6618
6688
|
common.useWebSocket({
|
|
6619
6689
|
url: configState.services.websocketUrls?.[1],
|
|
6620
|
-
onMessage: (
|
|
6690
|
+
onMessage: (message4) => chatStore.acceptMessage(message4.payload),
|
|
6621
6691
|
clientHeartbeat: false,
|
|
6622
6692
|
reconnectInterval: 1e4
|
|
6623
6693
|
});
|
|
@@ -6640,6 +6710,7 @@ var layouts_default = React10.forwardRef(({ theme: theme5, params, hooks, layout
|
|
|
6640
6710
|
exports.Attachments = Attachments_default;
|
|
6641
6711
|
exports.ChatCopilot = layouts_default;
|
|
6642
6712
|
exports.ChatSender = ChatSender_default;
|
|
6713
|
+
exports.WorkspaceTypeEnum = WorkspaceTypeEnum;
|
|
6643
6714
|
exports.getFileIcon = getFileIcon;
|
|
6644
6715
|
exports.getFileUrl = getFileUrl;
|
|
6645
6716
|
//# sourceMappingURL=index.cjs.js.map
|