@zero-library/chat-copilot 3.1.14 → 3.1.16

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.esm.js CHANGED
@@ -1,7 +1,7 @@
1
- import { CloudUploadOutlined, PaperClipOutlined, createFromIconfontCN, EnterOutlined, DownloadOutlined, CloseOutlined, PlayCircleOutlined, CopyOutlined, DotChartOutlined, LoadingOutlined, RightOutlined, LikeOutlined, DislikeOutlined, ToolOutlined, SearchOutlined, UpOutlined, DownOutlined, PlusOutlined, CommentOutlined, DeleteOutlined, StarOutlined, RedoOutlined, StarFilled, 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
- 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, Popconfirm, InputNumber, Switch as Switch$1, message, Upload, List, Card, Table, Progress as Progress$1 } from 'antd';
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';
5
5
  import * as React10 from 'react';
6
6
  import React10__default, { createContext, forwardRef, useRef, useEffect, useImperativeHandle, useMemo, memo, useState, useContext, useCallback, useLayoutEffect } from 'react';
7
7
  import { useSnapshot, proxy } from 'valtio';
@@ -18,7 +18,8 @@ import { LexicalTypeaheadMenuPlugin, MenuOption } from '@lexical/react/LexicalTy
18
18
  import { mergeRegister } from '@lexical/utils';
19
19
  import * as ReactDOM from 'react-dom';
20
20
  import dayjs from 'dayjs';
21
- import classNames from 'classnames';
21
+ import classNames2 from 'classnames';
22
+ import console2 from 'console';
22
23
  import InfiniteScroll from 'react-infinite-scroll-component';
23
24
  import { XCard as XCard$1 } from '@ant-design/x-card';
24
25
  import '@ant-design/x-markdown/themes/light.css';
@@ -43,7 +44,7 @@ var styles_module_default = {
43
44
  chatAttachments: "styles_module_chatAttachments",
44
45
  chatSender: "styles_module_chatSender"};
45
46
  var Attachments_default = forwardRef(({ fileUpload, fileUploadConfig, fileList = [], onChange, extraParams }, ref) => {
46
- const { message: message3 } = App.useApp();
47
+ const { message: message4 } = App.useApp();
47
48
  const chatStore = useChatStore();
48
49
  const configState = useSnapshot(chatStore.config);
49
50
  const fileListRef = useRef([]);
@@ -71,7 +72,7 @@ var Attachments_default = forwardRef(({ fileUpload, fileUploadConfig, fileList =
71
72
  onChange(files);
72
73
  }, [attachedFiles]);
73
74
  const onErrorTip = useDebounce((errorMsg) => {
74
- message3.error(errorMsg);
75
+ message4.error(errorMsg);
75
76
  }, 300);
76
77
  const findConfig = (file) => {
77
78
  return fileUploadConfig?.allowedTypes?.find((type) => type === getFileSuffixName(file.name)) || "";
@@ -239,6 +240,7 @@ var index_module_default = {
239
240
  var CONV_MODE = {
240
241
  PROD: 1};
241
242
  var TOKEN_KEY = "NS-TOKEN";
243
+ var SHARE_KEY = "SHARE-TOKEN";
242
244
  var tokenManager = createTokenManager({
243
245
  key: TOKEN_KEY
244
246
  });
@@ -330,8 +332,9 @@ var getFileIcon = (extension, fontSize = 24) => {
330
332
  return createIcon(FileUnknownOutlined, "#94a3b8");
331
333
  };
332
334
  var getFileUrl = (params, baseUrl, url) => {
335
+ const authParams = baseUrl === "/luya/share" ? { [SHARE_KEY]: localStorage.getItem(SHARE_KEY) || "" } : { [TOKEN_KEY]: tokenManager.get() };
333
336
  const data = {
334
- [TOKEN_KEY]: tokenManager.get(),
337
+ ...authParams,
335
338
  workspaceType: "conversation" /* CONVERSATION */,
336
339
  ...params
337
340
  };
@@ -820,7 +823,7 @@ var ChatInput = React10.forwardRef(
820
823
  }
821
824
  }
822
825
  ),
823
- placeholder: !stringValue && placeholder ? /* @__PURE__ */ jsx("div", { className: index_module_default.promptEditorPlaceholder, children: placeholder }) : /* @__PURE__ */ jsx("div", { className: index_module_default.promptEditorPlaceholder, children: "\u4ECA\u5929\u80FD\u5E2E\u4F60\u505A\u4EC0\u4E48\uFF1F" }),
826
+ 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,
824
827
  ErrorBoundary: LexicalErrorBoundary
825
828
  }
826
829
  ),
@@ -834,6 +837,7 @@ var ChatInput = React10.forwardRef(
834
837
  var ChatInput_default = ChatInput;
835
838
  var ChatSender_default = forwardRef(
836
839
  ({
840
+ placeholder,
837
841
  content,
838
842
  commandConfig = {},
839
843
  fileList = [],
@@ -906,6 +910,7 @@ var ChatSender_default = forwardRef(
906
910
  className: styles_module_default.chatSender,
907
911
  ref: senderRef,
908
912
  value: inputValue,
913
+ placeholder,
909
914
  header: senderHeader,
910
915
  onSubmit,
911
916
  onChange: setInputValue,
@@ -1001,6 +1006,9 @@ var createChatService = (request, config) => {
1001
1006
  const conversationFavorite = (conversationId, isFavorite) => {
1002
1007
  return request.put("/agents/conversations/favorite", { conversationIds: [conversationId], favorite: isFavorite });
1003
1008
  };
1009
+ const shareConversation = (conversationId) => {
1010
+ return request.get(`/agents/conversations/${conversationId}/share/url`);
1011
+ };
1004
1012
  return {
1005
1013
  fetchModelList,
1006
1014
  fetchAgentInfo,
@@ -1020,7 +1028,8 @@ var createChatService = (request, config) => {
1020
1028
  listDataSources,
1021
1029
  listTags,
1022
1030
  getAgentAvatar,
1023
- conversationFavorite
1031
+ conversationFavorite,
1032
+ shareConversation
1024
1033
  };
1025
1034
  };
1026
1035
 
@@ -1066,7 +1075,13 @@ function createChatStore() {
1066
1075
  return await config.services.request.fetchModelList();
1067
1076
  };
1068
1077
  const setServices = ({ http, websocket } = {}) => {
1069
- const httpConfig = { baseURL: "/luya/v1", headers: { [TOKEN_KEY]: tokenManager.get() }, ...http?.config };
1078
+ const baseURL = http?.config?.baseURL || "/luya/v1";
1079
+ const headers = baseURL === "/luya/share" ? { [SHARE_KEY]: localStorage.getItem(SHARE_KEY) || "" } : { [TOKEN_KEY]: tokenManager.get() };
1080
+ const httpConfig = {
1081
+ baseURL,
1082
+ headers,
1083
+ ...http?.config
1084
+ };
1070
1085
  const request = createRequest(httpConfig);
1071
1086
  if (config.hooks?.onRequestInterceptor) {
1072
1087
  request.instance.interceptors.request.use(...config.hooks.onRequestInterceptor);
@@ -1087,9 +1102,9 @@ function createChatStore() {
1087
1102
  config.services.request = { ...createChatService(request, httpConfig), ...http?.request };
1088
1103
  config.services.websocketUrls = ["", ""];
1089
1104
  if (isArray(websocket?.baseURLs)) {
1090
- websocket.baseURLs.forEach((baseURL, index) => {
1091
- if (isString(baseURL)) {
1092
- config.services.websocketUrls[index] = getChatSocketUrl(baseURL, websocket?.params || httpConfig.headers);
1105
+ websocket.baseURLs.forEach((baseURL2, index) => {
1106
+ if (isString(baseURL2)) {
1107
+ config.services.websocketUrls[index] = getChatSocketUrl(baseURL2, websocket?.params || httpConfig.headers);
1093
1108
  }
1094
1109
  });
1095
1110
  } else {
@@ -1228,6 +1243,7 @@ function createChatStore() {
1228
1243
  await config.services.request.deleteConversation(conversationId);
1229
1244
  message.success("\u5220\u9664\u6210\u529F");
1230
1245
  conversations.list.items = conversations.list.items.filter((item) => item.key !== conversationId);
1246
+ favorite.list.items = favorite.list.items.filter((item) => item.id !== conversationId);
1231
1247
  delete conversation.messages[conversationId];
1232
1248
  if (conversation.active.id === conversationId) {
1233
1249
  createConversation();
@@ -1273,6 +1289,7 @@ function createChatStore() {
1273
1289
  id: "id",
1274
1290
  label: "title",
1275
1291
  spec: "spec",
1292
+ isFavorite: "isFavorite",
1276
1293
  group: (c) => {
1277
1294
  return classifyTime(c.updatedAt);
1278
1295
  }
@@ -1327,7 +1344,9 @@ function createChatStore() {
1327
1344
  item.isFavorite = isFavorite;
1328
1345
  }
1329
1346
  }
1330
- if (!isFavorite && favorite.list.items.length) {
1347
+ if (isFavorite) {
1348
+ await getConversationFavorite();
1349
+ } else if (favorite.list.items.length) {
1331
1350
  favorite.list.items = favorite.list.items.filter((item) => item.id !== conversationId);
1332
1351
  }
1333
1352
  message.success(isFavorite ? "\u6536\u85CF\u6210\u529F" : "\u5DF2\u53D6\u6D88\u6536\u85CF");
@@ -1588,7 +1607,7 @@ function createChatStore() {
1588
1607
  }
1589
1608
  if (isMain) config.hooks?.onStepMessage?.(msg);
1590
1609
  }
1591
- function doneCallback(msg, message3, isMain) {
1610
+ function doneCallback(msg, message4, isMain) {
1592
1611
  conversation.messages[msg.conversationId].loading = false;
1593
1612
  const messages = conversation.messages[msg.conversationId]?.message;
1594
1613
  if (messages) {
@@ -1881,9 +1900,9 @@ function createChatStore() {
1881
1900
  }
1882
1901
  }
1883
1902
  }
1884
- function processMessageContent(message3, targetMessages) {
1903
+ function processMessageContent(message4, targetMessages) {
1885
1904
  const newMessage = {
1886
- ...message3,
1905
+ ...message4,
1887
1906
  agentId: agent.agentInfo.id
1888
1907
  };
1889
1908
  const isMain = !targetMessages;
@@ -1951,13 +1970,13 @@ function createChatStore() {
1951
1970
  }
1952
1971
  processMessageContent(newMessage);
1953
1972
  };
1954
- const sendMessage = async (message3, msgFiles = [], params) => {
1973
+ const sendMessage = async (message4, msgFiles = [], params) => {
1955
1974
  const conversationId = conversation.active.id;
1956
1975
  if (conversation.messages[conversationId].loading) return;
1957
1976
  let msgContent = "", files;
1958
1977
  const references = conversation.messages[conversationId].references;
1959
- if (message3) {
1960
- msgContent = message3;
1978
+ if (message4) {
1979
+ msgContent = message4;
1961
1980
  files = [...msgFiles, ...conversation.messages[conversationId].files || []];
1962
1981
  } else {
1963
1982
  if (references?.type === 1 && references?.content?.msgContent) {
@@ -2004,9 +2023,9 @@ function createChatStore() {
2004
2023
  };
2005
2024
  const extraParams = deepCopy(config.params?.params || {});
2006
2025
  const userInputParams = variablesToObject(conversation.active.userInput || []);
2007
- Object.assign(extraParams, message3 ? {} : { ...references?.params }, params, userInputParams);
2026
+ Object.assign(extraParams, message4 ? {} : { ...references?.params }, params, userInputParams);
2008
2027
  sendParams.params = extraParams;
2009
- if (!message3) {
2028
+ if (!message4) {
2010
2029
  setContent("");
2011
2030
  setContentParams();
2012
2031
  setReferences();
@@ -2200,103 +2219,56 @@ window._iconfont_svg_string_5021436 = '<svg><symbol id="icon-Ollama" viewBox="0
2200
2219
  // src/components/IconFont/index.ts
2201
2220
  var IconFont = createFromIconfontCN({});
2202
2221
  var IconFont_default = IconFont;
2203
-
2204
- // src/ui/common/FeatureComponents/style.module.less
2205
- var style_module_default = {
2206
- popover: "style_module_popover",
2207
- resourceBtn: "style_module_resourceBtn",
2208
- divider: "style_module_divider",
2209
- count: "style_module_count",
2210
- resourceBtnActive: "style_module_resourceBtnActive",
2211
- customModal: "style_module_customModal",
2212
- layout: "style_module_layout",
2213
- sider: "style_module_sider",
2214
- categoryName: "style_module_categoryName",
2215
- siderContent: "style_module_siderContent",
2216
- categoryItem: "style_module_categoryItem",
2217
- categoryActive: "style_module_categoryActive",
2218
- roundCheckbox: "style_module_roundCheckbox",
2219
- content: "style_module_content",
2220
- searchInput: "style_module_searchInput",
2221
- selectedCount: "style_module_selectedCount",
2222
- tagsArea: "style_module_tagsArea",
2223
- tagContainer: "style_module_tagContainer",
2224
- tag: "style_module_tag",
2225
- expandBtnWrapper: "style_module_expandBtnWrapper",
2226
- expandBtn: "style_module_expandBtn",
2227
- tagsExpanded: "style_module_tagsExpanded",
2228
- listArea: "style_module_listArea",
2229
- listInner: "style_module_listInner",
2230
- listItem: "style_module_listItem",
2231
- listItemSelected: "style_module_listItemSelected",
2232
- itemIconWrapper: "style_module_itemIconWrapper",
2233
- itemInfo: "style_module_itemInfo",
2234
- itemDesc: "style_module_itemDesc",
2235
- footer: "style_module_footer",
2236
- titleContainer: "style_module_titleContainer",
2237
- favoriteCard: "style_module_favoriteCard",
2238
- favoriteCardActive: "style_module_favoriteCardActive",
2239
- favoriteCardTitle: "style_module_favoriteCardTitle",
2240
- favoriteCardActions: "style_module_favoriteCardActions"};
2241
2222
  var ConversationFavoritesBtn_default = ({ icon, ...rest }) => {
2242
2223
  const chatStore = useChatStore();
2224
+ const conversationsState = useSnapshot(chatStore.conversations);
2243
2225
  const conversationState = useSnapshot(chatStore.conversation);
2244
- const favoriteState = useSnapshot(chatStore.favorite);
2245
- const getFavoriteList = useDebounce(() => {
2246
- chatStore.getConversationFavorite();
2247
- }, 300);
2248
- const renderFavoriteList = useMemo(() => {
2249
- return /* @__PURE__ */ jsx(Flex, { vertical: true, gap: 4, className: classNames("height-full", "scroll-fade-in"), children: favoriteState.list.items.length ? favoriteState.list.items.map((item) => /* @__PURE__ */ jsx(
2250
- "div",
2251
- {
2252
- className: classNames(style_module_default.favoriteCard, { [style_module_default.favoriteCardActive]: conversationState.active.id === item.id }),
2253
- onClick: () => chatStore.switchConversation(item.id),
2254
- children: /* @__PURE__ */ jsxs(Flex, { gap: 8, align: "center", children: [
2255
- /* @__PURE__ */ jsx(Flex, { flex: 1, className: classNames(style_module_default.favoriteCardTitle, "text-ellipsis"), children: item.title }),
2256
- /* @__PURE__ */ jsx(Flex, { gap: 8, align: "center", className: style_module_default.favoriteCardActions, children: /* @__PURE__ */ jsx(
2257
- Popconfirm,
2258
- {
2259
- title: "\u63D0\u793A",
2260
- okText: "\u786E\u5B9A",
2261
- cancelText: "\u53D6\u6D88",
2262
- description: "\u786E\u8BA4\u53D6\u6D88\u6536\u85CF\u8BE5\u4F1A\u8BDD\u5417\uFF1F",
2263
- onConfirm: (e) => {
2264
- e.stopPropagation();
2265
- chatStore.collectConversation(item.id, false);
2266
- },
2267
- onCancel: (e) => e.stopPropagation(),
2268
- children: /* @__PURE__ */ jsx(
2269
- Button,
2270
- {
2271
- icon: /* @__PURE__ */ jsx(DeleteOutlined, {}),
2272
- title: "\u5220\u9664",
2273
- type: "text",
2274
- onClick: (e) => {
2275
- e.stopPropagation();
2276
- }
2277
- }
2278
- )
2279
- }
2280
- ) })
2281
- ] })
2282
- },
2283
- item.id
2284
- )) : /* @__PURE__ */ jsx(Empty, { description: "\u6682\u65E0\u6536\u85CF", image: Empty.PRESENTED_IMAGE_SIMPLE }) });
2285
- }, [favoriteState.list.items, conversationState.active.id]);
2286
- const handlePopoverVisibleChange = (visible) => {
2287
- if (!visible) return;
2288
- getFavoriteList();
2226
+ const activeConversation = useMemo(() => {
2227
+ return conversationsState.list.items.find((item) => item.id === conversationState.active.id);
2228
+ }, [conversationsState.list.items, conversationState.active.id]);
2229
+ const isFavorite = activeConversation?.isFavorite === true;
2230
+ const handleToggleFavorite = () => {
2231
+ if (!conversationState.active.id) return;
2232
+ chatStore.collectConversation(conversationState.active.id, !isFavorite);
2289
2233
  };
2290
2234
  return /* @__PURE__ */ jsx(
2291
- Popover,
2235
+ Button,
2292
2236
  {
2293
- classNames: { container: style_module_default.popover },
2294
- getPopupContainer: (e) => e,
2295
- placement: "bottom",
2296
- content: renderFavoriteList,
2297
- trigger: ["click"],
2298
- onOpenChange: handlePopoverVisibleChange,
2299
- children: /* @__PURE__ */ jsx(Button, { title: "\u6536\u85CF\u5939", type: "text", size: "large", icon: icon?.() || /* @__PURE__ */ jsx(StarOutlined, {}), ...rest })
2237
+ title: isFavorite ? "\u53D6\u6D88\u6536\u85CF" : "\u6536\u85CF",
2238
+ type: "text",
2239
+ size: "large",
2240
+ disabled: !conversationState.active.id,
2241
+ icon: icon?.() || (isFavorite ? /* @__PURE__ */ jsx(StarFilled, { className: "primary-text" }) : /* @__PURE__ */ jsx(StarOutlined, {})),
2242
+ onClick: handleToggleFavorite,
2243
+ ...rest
2244
+ }
2245
+ );
2246
+ };
2247
+ var ConversationShareBtn_default = ({ icon, ...rest }) => {
2248
+ const chatStore = useChatStore();
2249
+ const conversationState = useSnapshot(chatStore.conversation);
2250
+ const configState = useSnapshot(chatStore.config);
2251
+ const handleShareConversation = async () => {
2252
+ try {
2253
+ const { data } = await configState.services.request.shareConversation(conversationState.active.id);
2254
+ if (data) {
2255
+ copyText(data);
2256
+ message.success("\u5206\u4EAB\u94FE\u63A5\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F");
2257
+ }
2258
+ } catch (error) {
2259
+ message.error("\u5206\u4EAB\u4F1A\u8BDD\u5931\u8D25");
2260
+ }
2261
+ };
2262
+ return /* @__PURE__ */ jsx(
2263
+ Button,
2264
+ {
2265
+ title: "\u5206\u4EAB",
2266
+ type: "text",
2267
+ size: "large",
2268
+ disabled: !conversationState.active.id,
2269
+ icon: icon?.() || /* @__PURE__ */ jsx(ShareAltOutlined, {}),
2270
+ ...rest,
2271
+ onClick: handleShareConversation
2300
2272
  }
2301
2273
  );
2302
2274
  };
@@ -2315,6 +2287,10 @@ var styles_module_default2 = {
2315
2287
  conversationListPanel: "styles_module_conversationListPanel",
2316
2288
  createConversationButton: "styles_module_createConversationButton",
2317
2289
  conversations: "styles_module_conversations",
2290
+ conversationTabs: "styles_module_conversationTabs",
2291
+ conversationTabPane: "styles_module_conversationTabPane",
2292
+ conversationEmpty: "styles_module_conversationEmpty",
2293
+ conversationScrollArea: "styles_module_conversationScrollArea",
2318
2294
  chatWelcomeWrap: "styles_module_chatWelcomeWrap",
2319
2295
  chatWelcome: "styles_module_chatWelcome",
2320
2296
  promptItem: "styles_module_promptItem",
@@ -2333,12 +2309,30 @@ var styles_module_default2 = {
2333
2309
  };
2334
2310
  var ConversationList_default = () => {
2335
2311
  const chatStore = useChatStore();
2312
+ const agentState = useSnapshot(chatStore.agent);
2336
2313
  const conversationsState = useSnapshot(chatStore.conversations);
2337
2314
  const conversationState = useSnapshot(chatStore.conversation);
2315
+ const favoriteState = useSnapshot(chatStore.favorite);
2316
+ const [activeTabKey, setActiveTabKey] = useState("history");
2317
+ useEffect(() => {
2318
+ if (!agentState.agentInfo.id) return;
2319
+ chatStore.getConversationFavorite();
2320
+ }, [agentState.agentInfo.id, chatStore]);
2338
2321
  const conversationList = useMemo(() => {
2339
2322
  return conversationsState.list.items.filter((item) => item.label);
2340
2323
  }, [conversationsState.list.items]);
2341
- const menuConfig = (conversation) => ({
2324
+ const favoriteConversationList = useMemo(() => {
2325
+ return favoriteState.list.items.filter((item) => item.title).map((item) => ({
2326
+ ...item,
2327
+ key: item.id,
2328
+ id: item.id,
2329
+ label: item.title,
2330
+ spec: item.spec,
2331
+ isFavorite: true,
2332
+ group: classifyTime(item.updatedAt)
2333
+ }));
2334
+ }, [favoriteState.list.items]);
2335
+ const historyMenuConfig = (conversation) => ({
2342
2336
  items: [
2343
2337
  {
2344
2338
  label: `${conversation.isFavorite ? "\u53D6\u6D88\u6536\u85CF" : "\u6536\u85CF"}`,
@@ -2361,31 +2355,135 @@ var ConversationList_default = () => {
2361
2355
  }
2362
2356
  }
2363
2357
  });
2364
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { className: "height-full scroll-fade-in", id: "scrollableDiv", children: conversationList.length ? /* @__PURE__ */ jsx(
2365
- InfiniteScroll,
2358
+ const favoriteMenuConfig = (conversation) => ({
2359
+ trigger: /* @__PURE__ */ jsx(
2360
+ Popconfirm,
2361
+ {
2362
+ title: "\u63D0\u793A",
2363
+ okText: "\u786E\u5B9A",
2364
+ cancelText: "\u53D6\u6D88",
2365
+ description: "\u786E\u8BA4\u53D6\u6D88\u6536\u85CF\u8BE5\u4F1A\u8BDD\u5417\uFF1F",
2366
+ onConfirm: (e) => {
2367
+ e.stopPropagation();
2368
+ chatStore.collectConversation(conversation.id, false);
2369
+ },
2370
+ onCancel: (e) => e.stopPropagation(),
2371
+ children: /* @__PURE__ */ jsx(
2372
+ Button,
2373
+ {
2374
+ icon: /* @__PURE__ */ jsx(DeleteOutlined, {}),
2375
+ title: "\u53D6\u6D88\u6536\u85CF",
2376
+ type: "text",
2377
+ onClick: (e) => {
2378
+ e.stopPropagation();
2379
+ }
2380
+ }
2381
+ )
2382
+ }
2383
+ ),
2384
+ items: []
2385
+ });
2386
+ return /* @__PURE__ */ jsx("div", { className: styles_module_default2.conversationTabs, children: /* @__PURE__ */ jsx(
2387
+ Tabs,
2366
2388
  {
2367
- dataLength: conversationList.length,
2368
- hasMore: false,
2369
- next: () => {
2370
- console.log("next");
2371
- },
2372
- loader: /* @__PURE__ */ jsx("div", { className: "text-center", children: /* @__PURE__ */ jsx(Spin, { indicator: /* @__PURE__ */ jsx(RedoOutlined, { spin: true }), size: "small" }) }),
2373
- style: { overflow: "hidden" },
2374
- scrollableTarget: "scrollableDiv",
2375
- children: /* @__PURE__ */ jsx(
2376
- Conversations,
2389
+ activeKey: activeTabKey,
2390
+ centered: true,
2391
+ onChange: setActiveTabKey,
2392
+ items: [
2377
2393
  {
2378
- className: styles_module_default2.conversations,
2379
- items: conversationList,
2380
- activeKey: conversationState.active.id,
2381
- onActiveChange: async (id) => chatStore.switchConversation(id),
2382
- groupable: true,
2383
- menu: menuConfig
2394
+ key: "history",
2395
+ label: "\u5386\u53F2\u4F1A\u8BDD",
2396
+ children: /* @__PURE__ */ jsx("div", { className: styles_module_default2.conversationTabPane, children: conversationList.length ? /* @__PURE__ */ jsx("div", { className: styles_module_default2.conversationScrollArea, id: "historyConversationScrollableDiv", children: /* @__PURE__ */ jsx(
2397
+ InfiniteScroll,
2398
+ {
2399
+ dataLength: conversationList.length,
2400
+ hasMore: false,
2401
+ next: () => {
2402
+ console2.log("next");
2403
+ },
2404
+ loader: /* @__PURE__ */ jsx("div", { className: "text-center", children: /* @__PURE__ */ jsx(Spin, { indicator: /* @__PURE__ */ jsx(RedoOutlined, { spin: true }), size: "small" }) }),
2405
+ style: { overflow: "hidden" },
2406
+ scrollableTarget: "historyConversationScrollableDiv",
2407
+ children: /* @__PURE__ */ jsx(
2408
+ Conversations,
2409
+ {
2410
+ className: styles_module_default2.conversations,
2411
+ items: conversationList,
2412
+ activeKey: conversationState.active.id,
2413
+ onActiveChange: async (id) => chatStore.switchConversation(id),
2414
+ groupable: true,
2415
+ menu: historyMenuConfig
2416
+ }
2417
+ )
2418
+ }
2419
+ ) }) : /* @__PURE__ */ jsx("div", { className: styles_module_default2.conversationEmpty, children: /* @__PURE__ */ jsx(Empty, { description: "\u6682\u65E0\u4F1A\u8BDD\u8BB0\u5F55", image: Empty.PRESENTED_IMAGE_SIMPLE }) }) })
2420
+ },
2421
+ {
2422
+ key: "favorite",
2423
+ label: "\u6536\u85CF\u4F1A\u8BDD",
2424
+ children: /* @__PURE__ */ jsx("div", { className: styles_module_default2.conversationTabPane, children: favoriteConversationList.length ? /* @__PURE__ */ jsx("div", { className: styles_module_default2.conversationScrollArea, id: "favoriteConversationScrollableDiv", children: /* @__PURE__ */ jsx(
2425
+ InfiniteScroll,
2426
+ {
2427
+ dataLength: favoriteConversationList.length,
2428
+ hasMore: false,
2429
+ next: () => {
2430
+ console2.log("next");
2431
+ },
2432
+ loader: /* @__PURE__ */ jsx("div", { className: "text-center", children: /* @__PURE__ */ jsx(Spin, { indicator: /* @__PURE__ */ jsx(RedoOutlined, { spin: true }), size: "small" }) }),
2433
+ style: { overflow: "hidden" },
2434
+ scrollableTarget: "favoriteConversationScrollableDiv",
2435
+ children: /* @__PURE__ */ jsx(
2436
+ Conversations,
2437
+ {
2438
+ className: styles_module_default2.conversations,
2439
+ items: favoriteConversationList,
2440
+ activeKey: conversationState.active.id,
2441
+ onActiveChange: async (id) => chatStore.switchConversation(id),
2442
+ groupable: true,
2443
+ menu: favoriteMenuConfig
2444
+ }
2445
+ )
2446
+ }
2447
+ ) }) : /* @__PURE__ */ jsx("div", { className: styles_module_default2.conversationEmpty, children: /* @__PURE__ */ jsx(Empty, { description: "\u6682\u65E0\u6536\u85CF\u4F1A\u8BDD", image: Empty.PRESENTED_IMAGE_SIMPLE }) }) })
2384
2448
  }
2385
- )
2449
+ ]
2386
2450
  }
2387
- ) : /* @__PURE__ */ jsx(Empty, { description: "\u6682\u65E0\u4F1A\u8BDD\u8BB0\u5F55", image: Empty.PRESENTED_IMAGE_SIMPLE }) }) });
2451
+ ) });
2388
2452
  };
2453
+
2454
+ // src/ui/common/FeatureComponents/style.module.less
2455
+ var style_module_default = {
2456
+ popover: "style_module_popover",
2457
+ resourceBtn: "style_module_resourceBtn",
2458
+ divider: "style_module_divider",
2459
+ count: "style_module_count",
2460
+ resourceBtnActive: "style_module_resourceBtnActive",
2461
+ customModal: "style_module_customModal",
2462
+ layout: "style_module_layout",
2463
+ sider: "style_module_sider",
2464
+ categoryName: "style_module_categoryName",
2465
+ siderContent: "style_module_siderContent",
2466
+ categoryItem: "style_module_categoryItem",
2467
+ categoryActive: "style_module_categoryActive",
2468
+ roundCheckbox: "style_module_roundCheckbox",
2469
+ content: "style_module_content",
2470
+ searchInput: "style_module_searchInput",
2471
+ selectedCount: "style_module_selectedCount",
2472
+ tagsArea: "style_module_tagsArea",
2473
+ tagContainer: "style_module_tagContainer",
2474
+ tag: "style_module_tag",
2475
+ expandBtnWrapper: "style_module_expandBtnWrapper",
2476
+ expandBtn: "style_module_expandBtn",
2477
+ tagsExpanded: "style_module_tagsExpanded",
2478
+ listArea: "style_module_listArea",
2479
+ listInner: "style_module_listInner",
2480
+ listItem: "style_module_listItem",
2481
+ listItemSelected: "style_module_listItemSelected",
2482
+ itemIconWrapper: "style_module_itemIconWrapper",
2483
+ itemInfo: "style_module_itemInfo",
2484
+ itemDesc: "style_module_itemDesc",
2485
+ footer: "style_module_footer",
2486
+ titleContainer: "style_module_titleContainer"};
2389
2487
  var HistoryBtn_default = ({ icon, ...rest }) => {
2390
2488
  return /* @__PURE__ */ jsx(
2391
2489
  Popover,
@@ -2405,12 +2503,13 @@ var ChatHeader_default = ({
2405
2503
  closeBtn = false,
2406
2504
  newConversationBtn = true,
2407
2505
  conversationListBtn = true,
2408
- conversationFavoriteBtn = true
2506
+ conversationFavoriteBtn = true,
2507
+ conversationShareBtn = true
2409
2508
  }) => {
2410
2509
  const chatStore = useChatStore();
2411
2510
  const agentState = useSnapshot(chatStore.agent);
2412
2511
  const configState = useSnapshot(chatStore.config);
2413
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: classNames(styles_module_default2.chatHeader, "zero-chat-header"), children: [
2512
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: classNames2(styles_module_default2.chatHeader, "zero-chat-header"), children: [
2414
2513
  /* @__PURE__ */ jsxs("div", { className: styles_module_default2.chatHeaderContent, children: [
2415
2514
  /* @__PURE__ */ jsx(
2416
2515
  RenderWrapper,
@@ -2426,7 +2525,8 @@ var ChatHeader_default = ({
2426
2525
  /* @__PURE__ */ jsxs("div", { className: styles_module_default2.chatHeaderBtnGroup, children: [
2427
2526
  /* @__PURE__ */ jsx(RenderWrapper, { control: newConversationBtn, DefaultComponent: CreateBtn_default }),
2428
2527
  /* @__PURE__ */ jsx(RenderWrapper, { control: conversationListBtn, DefaultComponent: HistoryBtn_default }),
2429
- /* @__PURE__ */ jsx(RenderWrapper, { control: conversationFavoriteBtn, DefaultComponent: ConversationFavoritesBtn_default })
2528
+ /* @__PURE__ */ jsx(RenderWrapper, { control: conversationFavoriteBtn, DefaultComponent: ConversationFavoritesBtn_default }),
2529
+ /* @__PURE__ */ jsx(RenderWrapper, { control: conversationShareBtn, DefaultComponent: ConversationShareBtn_default })
2430
2530
  ] }),
2431
2531
  /* @__PURE__ */ jsx(
2432
2532
  RenderWrapper,
@@ -2456,8 +2556,8 @@ var ConversationListHeader_default = ({ title = true, avatar = true, newConversa
2456
2556
  {
2457
2557
  control: title,
2458
2558
  DefaultComponent: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Flex, { vertical: true, gap: 4, flex: 1, style: { minWidth: 0 }, children: [
2459
- /* @__PURE__ */ jsx(Text, { strong: true, className: classNames("fz-16"), children: agentState.agentInfo.name }),
2460
- /* @__PURE__ */ jsx(Text, { type: "secondary", ellipsis: true, className: classNames("fz-12"), children: agentState.agentInfo.description })
2559
+ /* @__PURE__ */ jsx(Text, { strong: true, className: classNames2("fz-16"), children: agentState.agentInfo.name }),
2560
+ /* @__PURE__ */ jsx(Text, { type: "secondary", ellipsis: true, className: classNames2("fz-12"), children: agentState.agentInfo.description })
2461
2561
  ] }) })
2462
2562
  }
2463
2563
  )
@@ -2472,7 +2572,7 @@ var ConversationListHeader_default = ({ title = true, avatar = true, newConversa
2472
2572
  block: true,
2473
2573
  type: "primary",
2474
2574
  onClick: () => chatStore.createConversation(),
2475
- className: classNames(styles_module_default2.createConversationButton),
2575
+ className: classNames2(styles_module_default2.createConversationButton),
2476
2576
  icon: /* @__PURE__ */ jsx(PlusOutlined, {}),
2477
2577
  children: "\u65B0\u5EFA\u4F1A\u8BDD"
2478
2578
  }
@@ -2482,7 +2582,7 @@ var ConversationListHeader_default = ({ title = true, avatar = true, newConversa
2482
2582
  ] });
2483
2583
  };
2484
2584
  var ConversationListPanel = ({ header }) => {
2485
- return /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames("height-full", "zero-chat-conversations", styles_module_default2.conversationListPanel), children: [
2585
+ return /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames2("height-full", "zero-chat-conversations", styles_module_default2.conversationListPanel), children: [
2486
2586
  /* @__PURE__ */ jsx(RenderWrapper, { control: header, DefaultComponent: ConversationListHeader_default }),
2487
2587
  /* @__PURE__ */ jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsx(ConversationList_default, {}) })
2488
2588
  ] });
@@ -2951,7 +3051,7 @@ var CHART_COMPONENTS = Object.fromEntries(
2951
3051
  );
2952
3052
  var Charts_default = ({ data, loading }) => {
2953
3053
  const { type, config } = data;
2954
- return /* @__PURE__ */ jsx("div", { className: classNames(styles_module_default3.chart, "scroll-fade-in"), children: loading ? (
3054
+ return /* @__PURE__ */ jsx("div", { className: classNames2(styles_module_default3.chart, "scroll-fade-in"), children: loading ? (
2955
3055
  // Antd 骨架屏
2956
3056
  /* @__PURE__ */ jsx(Skeleton.Node, { active: true, className: styles_module_default3.chartSkeleton, children: /* @__PURE__ */ jsx(DotChartOutlined, { className: styles_module_default3.chartSkeletonIcon }) })
2957
3057
  ) : /* @__PURE__ */ jsx(
@@ -3034,12 +3134,12 @@ var DocDrawer_default = ({ title, open, onClose, paramsStr }) => {
3034
3134
  }, [paramsStr]);
3035
3135
  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" }) }) });
3036
3136
  };
3037
- var IndexQuote_default = ({ data, loading, message: message3 }) => {
3137
+ var IndexQuote_default = ({ data, loading, message: message4 }) => {
3038
3138
  const [open, setOpen] = useState(false);
3039
3139
  const citation = useMemo(() => {
3040
- const citations = message3.content?.find((item) => item.type === "citation")?.citations ?? [];
3140
+ const citations = message4.content?.find((item) => item.type === "citation")?.citations ?? [];
3041
3141
  return citations?.find((item) => String(item.citationId) === String(data.citationId));
3042
- }, [data.citationId, message3.content]);
3142
+ }, [data.citationId, message4.content]);
3043
3143
  const onClick = () => {
3044
3144
  if (!citation?.citationUrl) return;
3045
3145
  if (isExternal(citation.citationUrl)) {
@@ -3054,7 +3154,7 @@ var IndexQuote_default = ({ data, loading, message: message3 }) => {
3054
3154
  open && /* @__PURE__ */ jsx(DocDrawer_default, { paramsStr: citation?.citationUrl, title: citation?.citationName, open, onClose: () => setOpen(false) })
3055
3155
  ] });
3056
3156
  };
3057
- var MarkImg_default = ({ data, loading, message: message3, ...rest }) => {
3157
+ var MarkImg_default = ({ data, loading, message: message4, ...rest }) => {
3058
3158
  const getPreviewFileUrl = (src) => {
3059
3159
  return buildUrlParams({ [TOKEN_KEY]: tokenManager.get() || "" }, src);
3060
3160
  };
@@ -3081,8 +3181,9 @@ var MdEdit_default = ({ data, loading }) => {
3081
3181
  !loading && /* @__PURE__ */ jsx(Flex, { justify: "end", className: "m-t-16", children: /* @__PURE__ */ jsx(Button, { color: "primary", variant: "outlined", onClick: onOk, children: btnText }) })
3082
3182
  ] });
3083
3183
  };
3084
- var PreviewLink_default = ({ data, loading, message: message3, ...rest }) => {
3184
+ var PreviewLink_default = ({ data, loading, message: message4, ...rest }) => {
3085
3185
  const chatStore = useChatStore();
3186
+ const conversationWorkspacePrefix = "/workspace/conversation/";
3086
3187
  const getLinkFileName = (path) => {
3087
3188
  const lastSegment = path.split("/").pop();
3088
3189
  if (!lastSegment) {
@@ -3094,13 +3195,27 @@ var PreviewLink_default = ({ data, loading, message: message3, ...rest }) => {
3094
3195
  return lastSegment;
3095
3196
  }
3096
3197
  };
3097
- const handlePreviewByPath = (path) => {
3198
+ const normalizePreviewPath = (path) => {
3199
+ if (!path) {
3200
+ return path;
3201
+ }
3202
+ if (path.startsWith(conversationWorkspacePrefix)) {
3203
+ return path;
3204
+ }
3205
+ if (path.startsWith(conversationWorkspacePrefix.slice(1))) {
3206
+ return `/${path}`;
3207
+ }
3098
3208
  const fileName = getLinkFileName(path);
3209
+ return `${conversationWorkspacePrefix}${fileName}`;
3210
+ };
3211
+ const handlePreviewByPath = (path) => {
3212
+ const normalizedPath = normalizePreviewPath(path);
3213
+ const fileName = getLinkFileName(normalizedPath);
3099
3214
  const suffix = getFileSuffixName(fileName);
3100
3215
  chatStore.setPreview({
3101
3216
  fileUrl: chatStore.config.services.request.getPreviewUrl({
3102
- path,
3103
- workspaceId: message3.conversationId
3217
+ path: normalizedPath,
3218
+ workspaceId: message4.conversationId
3104
3219
  }),
3105
3220
  fileName,
3106
3221
  suffix
@@ -3213,7 +3328,7 @@ var adaptMarkdownComponent = (Component, payloadMapRef, messageRef) => {
3213
3328
  return WrappedComponent;
3214
3329
  };
3215
3330
  var adaptMarkdownComponents = (components, payloadMapRef, messageRef) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component, payloadMapRef, messageRef)]));
3216
- var XMarkdown_default = memo(({ message: message3, components = {}, content = "", ...rest }) => {
3331
+ var XMarkdown_default = memo(({ message: message4, components = {}, content = "", ...rest }) => {
3217
3332
  const config = useMemo(() => getMarkdownConfig(), []);
3218
3333
  const formattedContent = useMemo(() => formatMixedContent(content), [content]);
3219
3334
  const newComponents = useMemo(
@@ -3239,14 +3354,14 @@ var XMarkdown_default = memo(({ message: message3, components = {}, content = ""
3239
3354
  [formattedContent, payloadTagPattern]
3240
3355
  );
3241
3356
  const payloadMapRef = useRef(payloadMap);
3242
- const messageRef = useRef(message3);
3357
+ const messageRef = useRef(message4);
3243
3358
  payloadMapRef.current = payloadMap;
3244
- messageRef.current = message3;
3359
+ messageRef.current = message4;
3245
3360
  const markdownComponents = useMemo(() => adaptMarkdownComponents(newComponents, payloadMapRef, messageRef), [payloadTagPattern]);
3246
3361
  return /* @__PURE__ */ jsx(
3247
3362
  XMarkdown,
3248
3363
  {
3249
- className: classNames("x-markdown-light", styles_module_default4.xMarkdownStyle),
3364
+ className: classNames2("x-markdown-light", styles_module_default4.xMarkdownStyle),
3250
3365
  config,
3251
3366
  ...rest,
3252
3367
  content: processedContent,
@@ -3591,7 +3706,7 @@ var Switch = ({ id, label, value, bind_path_token, onChange, onDataChange }) =>
3591
3706
  /* @__PURE__ */ jsx("span", { style: { fontSize: 13, color: "#555" }, children: label })
3592
3707
  ] });
3593
3708
  };
3594
- var Button10 = ({ label, variant = "default", onClick, action, onAction }) => {
3709
+ var Button12 = ({ label, variant = "default", onClick, action, onAction }) => {
3595
3710
  const handleClick = () => {
3596
3711
  if (onClick) {
3597
3712
  onClick();
@@ -3621,7 +3736,7 @@ var A2uiComponents = {
3621
3736
  TextField,
3622
3737
  Select,
3623
3738
  Switch,
3624
- Button: Button10,
3739
+ Button: Button12,
3625
3740
  Divider,
3626
3741
  Tag: Tag3,
3627
3742
  Progress,
@@ -3668,10 +3783,10 @@ function extractDismissedSurfaceIdsFromMessages(messages) {
3668
3783
  const lastCreateIndexBySurface = /* @__PURE__ */ new Map();
3669
3784
  const lastActionIndexBySurface = /* @__PURE__ */ new Map();
3670
3785
  for (let messageIndex = 0; messageIndex < messages.length; messageIndex++) {
3671
- const message3 = messages[messageIndex];
3672
- const items = Array.isArray(message3?.content) ? message3.content : [];
3786
+ const message4 = messages[messageIndex];
3787
+ const items = Array.isArray(message4?.content) ? message4.content : [];
3673
3788
  for (const item of items) {
3674
- if (message3?.role !== 1) {
3789
+ if (message4?.role !== 1) {
3675
3790
  if (item?.type === "a2uiCommand" && item.command) {
3676
3791
  const surfaceId = String(item.command?.createSurface?.surfaceId || "").trim();
3677
3792
  if (surfaceId) lastCreateIndexBySurface.set(surfaceId, messageIndex);
@@ -3687,7 +3802,7 @@ function extractDismissedSurfaceIdsFromMessages(messages) {
3687
3802
  }
3688
3803
  }
3689
3804
  }
3690
- if (message3?.role === 1 && item?.type === "text") {
3805
+ if (message4?.role === 1 && item?.type === "text") {
3691
3806
  const text = item.messageContent || item.text || "";
3692
3807
  if (typeof text !== "string" || !text.includes("a2ui_action.v1")) continue;
3693
3808
  try {
@@ -4270,9 +4385,9 @@ function diffConversationMessages(messages, prevCursors) {
4270
4385
  const nextCursors = [];
4271
4386
  const pendingItems = [];
4272
4387
  for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
4273
- const message3 = messages[messageIndex];
4274
- const messageId = String(message3?.messageId ?? messageIndex);
4275
- const items = Array.isArray(message3?.content) ? message3.content : [];
4388
+ const message4 = messages[messageIndex];
4389
+ const messageId = String(message4?.messageId ?? messageIndex);
4390
+ const items = Array.isArray(message4?.content) ? message4.content : [];
4276
4391
  const prevCursor = prevCursors[messageIndex];
4277
4392
  const startIndex = prevCursor ? prevCursor.contentLength : 0;
4278
4393
  if (prevCursor && (prevCursor.messageId !== messageId || items.length < prevCursor.contentLength)) {
@@ -4289,9 +4404,9 @@ function scanA2uiTagsFromMessages(messages, processedTagIds) {
4289
4404
  const newTags = [];
4290
4405
  const newTagIds = [];
4291
4406
  for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
4292
- const message3 = messages[messageIndex];
4293
- const messageId = String(message3?.messageId ?? messageIndex);
4294
- const items = Array.isArray(message3?.content) ? message3.content : [];
4407
+ const message4 = messages[messageIndex];
4408
+ const messageId = String(message4?.messageId ?? messageIndex);
4409
+ const items = Array.isArray(message4?.content) ? message4.content : [];
4295
4410
  for (const item of items) {
4296
4411
  const text = extractItemTextForA2ui(item);
4297
4412
  if (typeof text !== "string" || !text.includes("<A2UI")) continue;
@@ -4347,9 +4462,9 @@ function reduceA2uiRuntimeMessages(state, messages) {
4347
4462
  processA2uiCommand(cmd, messageIndex, messageId, nextState, effects, deletedSurfaceIds, nextWizardSteps);
4348
4463
  }
4349
4464
  });
4350
- nextState.processedMessageCursors = shouldReplayAll ? messages.map((message3, messageIndex) => ({
4351
- messageId: String(message3?.messageId ?? messageIndex),
4352
- contentLength: Array.isArray(message3?.content) ? message3.content.length : 0
4465
+ nextState.processedMessageCursors = shouldReplayAll ? messages.map((message4, messageIndex) => ({
4466
+ messageId: String(message4?.messageId ?? messageIndex),
4467
+ contentLength: Array.isArray(message4?.content) ? message4.content.length : 0
4353
4468
  })) : nextCursors;
4354
4469
  nextState.wizardStepBySurface = { ...nextState.wizardStepBySurface, ...nextWizardSteps };
4355
4470
  if (deletedSurfaceIds.size) {
@@ -4697,8 +4812,8 @@ function readContextModelPath(context) {
4697
4812
  function buildLatestCommandIndexBySurface(messages) {
4698
4813
  const indexBySurface = {};
4699
4814
  let commandIndex = -1;
4700
- for (const message3 of messages) {
4701
- const items = Array.isArray(message3?.content) ? message3.content : [];
4815
+ for (const message4 of messages) {
4816
+ const items = Array.isArray(message4?.content) ? message4.content : [];
4702
4817
  for (const item of items) {
4703
4818
  if (item?.type === "a2uiCommand" && item.command) {
4704
4819
  commandIndex += 1;
@@ -4886,7 +5001,7 @@ var TextNode2 = React10__default.memo(
4886
5001
  item,
4887
5002
  role,
4888
5003
  customComponents,
4889
- message: message3
5004
+ message: message4
4890
5005
  }) => {
4891
5006
  const content = toA2uiDisplayText(role, item?.messageContent);
4892
5007
  const markdownComponents = {
@@ -4899,7 +5014,7 @@ var TextNode2 = React10__default.memo(
4899
5014
  const markdownContent = typeof content === "string" ? transformResourceText(content) : content;
4900
5015
  return /* @__PURE__ */ jsxs(Fragment, { children: [
4901
5016
  !!item.reasoningContent && /* @__PURE__ */ jsx(Think, { title: "\u6DF1\u5EA6\u601D\u8003", style: { marginBottom: "16px" }, children: item.reasoningContent }),
4902
- !!markdownContent && /* @__PURE__ */ jsx(XMarkdown_default, { message: message3, components: markdownComponents, content: markdownContent })
5017
+ !!markdownContent && /* @__PURE__ */ jsx(XMarkdown_default, { message: message4, components: markdownComponents, content: markdownContent })
4903
5018
  ] });
4904
5019
  }
4905
5020
  );
@@ -5227,9 +5342,9 @@ var ToolCallItem = ({ item }) => {
5227
5342
  };
5228
5343
  var tool_call_item_default = ToolCallItem;
5229
5344
  var RENDERABLE_MESSAGE_TYPES = ["runStarted", "toolCall", "toolResult", "text", "stepError", "runFailed", "files", "plan"];
5230
- var MessageRender_default = React10__default.memo(({ role, message: message3, messageIndex = -1, loading, containerRef, customComponents }) => {
5345
+ var MessageRender_default = React10__default.memo(({ role, message: message4, messageIndex = -1, loading, containerRef, customComponents }) => {
5231
5346
  const content = useMemo(() => {
5232
- return (message3.content || []).filter((item) => {
5347
+ return (message4.content || []).filter((item) => {
5233
5348
  if (!RENDERABLE_MESSAGE_TYPES.includes(item.type)) {
5234
5349
  return false;
5235
5350
  }
@@ -5242,12 +5357,12 @@ var MessageRender_default = React10__default.memo(({ role, message: message3, me
5242
5357
  }
5243
5358
  return true;
5244
5359
  });
5245
- }, [message3.content]);
5360
+ }, [message4.content]);
5246
5361
  const quoteMsg = useMemo(() => {
5247
5362
  const quoteMsg2 = {};
5248
- if (message3.params) {
5363
+ if (message4.params) {
5249
5364
  try {
5250
- const citation = JSON.parse(message3.params).citation;
5365
+ const citation = JSON.parse(message4.params).citation;
5251
5366
  if (citation) {
5252
5367
  quoteMsg2.messageContent = citation;
5253
5368
  }
@@ -5255,7 +5370,7 @@ var MessageRender_default = React10__default.memo(({ role, message: message3, me
5255
5370
  }
5256
5371
  }
5257
5372
  return isEmptyObj(quoteMsg2) ? null : quoteMsg2;
5258
- }, [message3.params, message3.quoteMsg]);
5373
+ }, [message4.params, message4.quoteMsg]);
5259
5374
  const showPending = loading && (content.length === 0 || content[content.length - 1].type !== "text");
5260
5375
  if (content.length === 0 && !showPending) return null;
5261
5376
  const lastToolCallIndex = (() => {
@@ -5279,20 +5394,20 @@ var MessageRender_default = React10__default.memo(({ role, message: message3, me
5279
5394
  TextNode2,
5280
5395
  {
5281
5396
  item,
5282
- role: message3.role,
5397
+ role: message4.role,
5283
5398
  customComponents,
5284
- message: message3,
5399
+ message: message4,
5285
5400
  messageIndex
5286
5401
  },
5287
5402
  `message-${index}`
5288
5403
  ),
5289
- (item.type === "stepError" || item.type === "runFailed") && (item.errorMessage ? /* @__PURE__ */ jsx(XMarkdown_default, { message: message3, components: customComponents, content: item.errorMessage }) : null),
5404
+ (item.type === "stepError" || item.type === "runFailed") && (item.errorMessage ? /* @__PURE__ */ jsx(XMarkdown_default, { message: message4, components: customComponents, content: item.errorMessage }) : null),
5290
5405
  item.type === "files" && /* @__PURE__ */ jsx(FilesNode, { item }, `files-${index}`),
5291
5406
  item.type === "plan" && /* @__PURE__ */ jsx(A2uiPlanNode, { item }, `plan-${index}`)
5292
5407
  ] })
5293
5408
  }
5294
5409
  ),
5295
- index === lastToolCallIndex && messageIndex >= 0 ? /* @__PURE__ */ jsx(A2uiMessageCards, { messageIndex, message: message3 }) : null
5410
+ index === lastToolCallIndex && messageIndex >= 0 ? /* @__PURE__ */ jsx(A2uiMessageCards, { messageIndex, message: message4 }) : null
5296
5411
  ] }, `message-${index}`)),
5297
5412
  showPending && role.user === "agent" && /* @__PURE__ */ jsx(Bubble, { role: role.user, placement: role.placement, content: /* @__PURE__ */ jsx(RunStartedNode, {}) }),
5298
5413
  quoteMsg && /* @__PURE__ */ jsx(QuoteMsgNode, { quoteMsg, role })
@@ -5311,7 +5426,7 @@ var WelcomeItem_default = ({ icon = true, title = true, description = true, prom
5311
5426
  /* @__PURE__ */ jsx(
5312
5427
  Welcome,
5313
5428
  {
5314
- className: classNames(styles_module_default2.chatWelcome, "p-t-32"),
5429
+ className: classNames2(styles_module_default2.chatWelcome, "p-t-32"),
5315
5430
  variant: "borderless",
5316
5431
  icon: /* @__PURE__ */ jsx(
5317
5432
  RenderWrapper,
@@ -5337,7 +5452,7 @@ var WelcomeItem_default = ({ icon = true, title = true, description = true, prom
5337
5452
  DefaultComponent: /* @__PURE__ */ jsx(
5338
5453
  Prompts,
5339
5454
  {
5340
- className: classNames("m-t-16", styles_module_default2.promptItem),
5455
+ className: classNames2("m-t-16", styles_module_default2.promptItem),
5341
5456
  wrap: true,
5342
5457
  onItemClick: (info) => chatStore.sendMessage(info.data.description),
5343
5458
  items: recommendQuestions
@@ -5388,13 +5503,13 @@ var BubbleListItems_default = ({
5388
5503
  const messageRefs = useRef({});
5389
5504
  const chatRecords = useMemo(() => {
5390
5505
  const chatRecords2 = [];
5391
- conversationMessages.forEach((message3, messageIndex) => {
5392
- const role = getRole(message3.role);
5506
+ conversationMessages.forEach((message4, messageIndex) => {
5507
+ const role = getRole(message4.role);
5393
5508
  const isLeftBubble = role.user === "agent";
5394
- const isMessageLoading = !!message3.generating;
5395
- const baseKey = `${message3.executionId}-${messageIndex}`;
5509
+ const isMessageLoading = !!message4.generating;
5510
+ const baseKey = `${message4.executionId}-${messageIndex}`;
5396
5511
  const footerNode = !isMessageLoading ? /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 8, children: [
5397
- message3.stopFlag && isLeftBubble && /* @__PURE__ */ jsx(Text3, { type: "secondary", style: { flex: "none" }, children: "\u5DF2\u505C\u6B62" }),
5512
+ message4.stopFlag && isLeftBubble && /* @__PURE__ */ jsx(Text3, { type: "secondary", style: { flex: "none" }, children: "\u5DF2\u505C\u6B62" }),
5398
5513
  /* @__PURE__ */ jsx(Flex, { align: "center", gap: 4, children: role.user === "agent" && /* @__PURE__ */ jsxs(Fragment, { children: [
5399
5514
  /* @__PURE__ */ jsx(
5400
5515
  Button,
@@ -5414,21 +5529,21 @@ var BubbleListItems_default = ({
5414
5529
  /* @__PURE__ */ jsx(
5415
5530
  Button,
5416
5531
  {
5417
- color: message3.feedback === 1 ? "primary" : "default",
5532
+ color: message4.feedback === 1 ? "primary" : "default",
5418
5533
  size: "small",
5419
5534
  variant: "text",
5420
5535
  icon: /* @__PURE__ */ jsx(LikeOutlined, {}),
5421
- onClick: () => chatStore.feedback(message3.executionId, 1, messageIndex)
5536
+ onClick: () => chatStore.feedback(message4.executionId, 1, messageIndex)
5422
5537
  }
5423
5538
  ),
5424
5539
  /* @__PURE__ */ jsx(
5425
5540
  Button,
5426
5541
  {
5427
- color: message3.feedback === 2 ? "primary" : "default",
5542
+ color: message4.feedback === 2 ? "primary" : "default",
5428
5543
  size: "small",
5429
5544
  variant: "text",
5430
5545
  icon: /* @__PURE__ */ jsx(DislikeOutlined, {}),
5431
- onClick: () => chatStore.feedback(message3.executionId, 2, messageIndex)
5546
+ onClick: () => chatStore.feedback(message4.executionId, 2, messageIndex)
5432
5547
  }
5433
5548
  ),
5434
5549
  /* @__PURE__ */ jsx(
@@ -5436,7 +5551,7 @@ var BubbleListItems_default = ({
5436
5551
  {
5437
5552
  control: agentActions,
5438
5553
  ctx: {
5439
- message: message3,
5554
+ message: message4,
5440
5555
  get dom() {
5441
5556
  return messageRefs.current[baseKey];
5442
5557
  }
@@ -5454,7 +5569,7 @@ var BubbleListItems_default = ({
5454
5569
  MessageRender_default,
5455
5570
  {
5456
5571
  role,
5457
- message: message3,
5572
+ message: message4,
5458
5573
  messageIndex,
5459
5574
  customComponents,
5460
5575
  loading: isMessageLoading,
@@ -5546,7 +5661,7 @@ var BubbleListItems_default = ({
5546
5661
  autoScroll: false,
5547
5662
  ref: listRef,
5548
5663
  items: bubbleListItems,
5549
- className: classNames(styles_module_default2.bubbleList, "height-full", "scroll-fade-in"),
5664
+ className: classNames2(styles_module_default2.bubbleList, "height-full", "scroll-fade-in"),
5550
5665
  onScroll: handleScroll
5551
5666
  },
5552
5667
  conversationState.active.id
@@ -5697,7 +5812,7 @@ var ResourceSelectorModal_default = ({ open, type, onCancel }) => {
5697
5812
  return /* @__PURE__ */ jsxs(
5698
5813
  Flex,
5699
5814
  {
5700
- className: classNames(style_module_default.categoryItem, { [style_module_default.categoryActive]: isChecked }),
5815
+ className: classNames2(style_module_default.categoryItem, { [style_module_default.categoryActive]: isChecked }),
5701
5816
  onClick: () => handleCategoryChange(cat.id, !isChecked),
5702
5817
  children: [
5703
5818
  /* @__PURE__ */ jsx(
@@ -5732,7 +5847,7 @@ var ResourceSelectorModal_default = ({ open, type, onCancel }) => {
5732
5847
  "\u5DF2\u9009 ",
5733
5848
  selectedIds.length
5734
5849
  ] }) }),
5735
- /* @__PURE__ */ jsxs("div", { className: classNames(style_module_default.tagsArea, { [style_module_default.tagsExpanded]: tagsExpanded }), children: [
5850
+ /* @__PURE__ */ jsxs("div", { className: classNames2(style_module_default.tagsArea, { [style_module_default.tagsExpanded]: tagsExpanded }), children: [
5736
5851
  /* @__PURE__ */ jsxs(Flex, { gap: 8, className: style_module_default.tagContainer, wrap: true, ref: tagsContainerRef, children: [
5737
5852
  selectedIds.map((id) => /* @__PURE__ */ jsx(
5738
5853
  Tag,
@@ -5762,7 +5877,7 @@ var ResourceSelectorModal_default = ({ open, type, onCancel }) => {
5762
5877
  return /* @__PURE__ */ jsxs(
5763
5878
  "div",
5764
5879
  {
5765
- className: classNames(style_module_default.listItem, { [style_module_default.listItemSelected]: isSelected }),
5880
+ className: classNames2(style_module_default.listItem, { [style_module_default.listItemSelected]: isSelected }),
5766
5881
  onClick: () => toggleItemSelection(item.id),
5767
5882
  children: [
5768
5883
  /* @__PURE__ */ jsx("div", { className: style_module_default.itemIconWrapper, children: /* @__PURE__ */ jsx(IconFont_default, { type: iconType }) }),
@@ -5892,7 +6007,7 @@ var ReasonBtn_default = ({}) => {
5892
6007
  return /* @__PURE__ */ jsxs(
5893
6008
  "div",
5894
6009
  {
5895
- className: classNames(style_module_default.resourceBtn, { [style_module_default.resourceBtnActive]: agentState.model.reasoning }),
6010
+ className: classNames2(style_module_default.resourceBtn, { [style_module_default.resourceBtnActive]: agentState.model.reasoning }),
5896
6011
  onClick: () => chatStore.setAgentModel({ ...agentState.model, reasoning: !agentState.model.reasoning }),
5897
6012
  children: [
5898
6013
  /* @__PURE__ */ jsx(IconFont_default, { type: "icon-reason" }),
@@ -6365,9 +6480,9 @@ var ChatMainPanel = memo(
6365
6480
  );
6366
6481
  const configState = useSnapshot(chatStore.config);
6367
6482
  const agentState = useSnapshot(chatStore.agent);
6368
- return /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames("height-full"), children: [
6483
+ return /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames2("height-full"), children: [
6369
6484
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.chatHeader, DefaultComponent: ChatHeader_default }),
6370
- /* @__PURE__ */ jsxs(Flex, { align: "center", vertical: true, gap: 24, className: classNames("height-full", styles_module_default5.bodyWidth), children: [
6485
+ /* @__PURE__ */ jsxs(Flex, { align: "center", vertical: true, gap: 24, className: classNames2("height-full", styles_module_default5.bodyWidth), children: [
6371
6486
  shouldRender(agentState.agentInfo.userInput && agentState.agentInfo.userInput.length > 0) && /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.userInput, DefaultComponent: UserInputPanel_default }),
6372
6487
  shouldRender(configState.layout.messageList) && /* @__PURE__ */ jsx("div", { className: "full-scroll", style: { width: "100%" }, children: /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.messageList, DefaultComponent: BubbleListItems_default }) }),
6373
6488
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.senderHeader, DefaultComponent: /* @__PURE__ */ jsx(ChatSenderHeader_default, {}) }),
@@ -6402,7 +6517,7 @@ var ChatPreviewPanel = memo(({ file }) => {
6402
6517
  return /* @__PURE__ */ jsxs(Fragment, { children: [
6403
6518
  file.fileUrl && /* @__PURE__ */ jsxs(Flex, { vertical: true, className: "height-full", children: [
6404
6519
  /* @__PURE__ */ jsxs("div", { className: styles_module_default5.previewHeader, children: [
6405
- /* @__PURE__ */ jsx("div", { className: classNames(styles_module_default5.previewHeaderTitle, "text-ellipsis"), title: file.fileName, children: file.fileName }),
6520
+ /* @__PURE__ */ jsx("div", { className: classNames2(styles_module_default5.previewHeaderTitle, "text-ellipsis"), title: file.fileName, children: file.fileName }),
6406
6521
  /* @__PURE__ */ jsxs(Flex, { gap: 8, justify: "center", align: "center", children: [
6407
6522
  /* @__PURE__ */ jsx(
6408
6523
  Button,
@@ -6507,6 +6622,8 @@ var layouts_default = forwardRef(({ theme: theme5, params, hooks, layout, config
6507
6622
  useDeepEffect(() => {
6508
6623
  if (agentState.agentInfo.id) {
6509
6624
  chatStore.initConversation(config);
6625
+ } else if (config.conversationId) {
6626
+ chatStore.switchConversation(config.conversationId);
6510
6627
  }
6511
6628
  }, [agentState.agentInfo.id, config.conversationId]);
6512
6629
  const hasPreView = useMemo(() => {
@@ -6525,25 +6642,25 @@ var layouts_default = forwardRef(({ theme: theme5, params, hooks, layout, config
6525
6642
  }, [hasPreView]);
6526
6643
  useWebSocket({
6527
6644
  url: configState.services.websocketUrls?.[0],
6528
- onMessage: (message3) => chatStore.acceptMessage(message3.payload),
6645
+ onMessage: (message4) => chatStore.acceptMessage(message4.payload),
6529
6646
  clientHeartbeat: false,
6530
6647
  reconnectInterval: 1e4
6531
6648
  });
6532
6649
  useWebSocket({
6533
6650
  url: configState.services.websocketUrls?.[1],
6534
- onMessage: (message3) => chatStore.acceptMessage(message3.payload),
6651
+ onMessage: (message4) => chatStore.acceptMessage(message4.payload),
6535
6652
  clientHeartbeat: false,
6536
6653
  reconnectInterval: 1e4
6537
6654
  });
6538
6655
  useEffect(() => {
6539
6656
  hooks?.onBeforeInit?.();
6540
6657
  }, []);
6541
- return /* @__PURE__ */ jsx(XProvider, { theme: { cssVar: {}, ...theme5 }, children: /* @__PURE__ */ jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsx(Spin, { spinning: configState.loading, classNames: { root: "full-spin" }, children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames(index_module_default3.chatLayout, "zero-chat-layout", "height-full"), children: [
6658
+ return /* @__PURE__ */ jsx(XProvider, { theme: { cssVar: {}, ...theme5 }, children: /* @__PURE__ */ jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsx(Spin, { spinning: configState.loading, classNames: { root: "full-spin" }, children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames2(index_module_default3.chatLayout, "zero-chat-layout", "height-full"), children: [
6542
6659
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.globalHeader, DefaultComponent: ChatHeader_default }),
6543
6660
  /* @__PURE__ */ jsxs(Flex, { ref: containerRef, className: "full-scroll", children: [
6544
6661
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.leftPanel }),
6545
6662
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.conversationList, DefaultComponent: ConversationListPanel_default }),
6546
- /* @__PURE__ */ jsxs(Splitter, { className: classNames("flex-1", index_module_default3.animatedSplitter, { [index_module_default3.hideSplitterBar]: !hasPreView }), children: [
6663
+ /* @__PURE__ */ jsxs(Splitter, { className: classNames2("flex-1", index_module_default3.animatedSplitter, { [index_module_default3.hideSplitterBar]: !hasPreView }), children: [
6547
6664
  /* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, max: 800, min: 400, size: sizes[1], children: /* @__PURE__ */ jsx(ChatMainPanel_default, { ref: senderRef }) }),
6548
6665
  /* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, min: 600, size: sizes[0], children: /* @__PURE__ */ jsx(ChatPreviewPanel_default, { file: configState.preview.file }) })
6549
6666
  ] })