@zero-library/chat-copilot 3.1.15 → 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,4 +1,4 @@
1
- import { CloudUploadOutlined, PaperClipOutlined, createFromIconfontCN, EnterOutlined, DownloadOutlined, CloseOutlined, PlayCircleOutlined, CopyOutlined, DotChartOutlined, LoadingOutlined, RightOutlined, LikeOutlined, DislikeOutlined, ToolOutlined, SearchOutlined, UpOutlined, DownOutlined, PlusOutlined, CommentOutlined, StarFilled, StarOutlined, RedoOutlined, DeleteOutlined, ClockCircleOutlined, CheckCircleOutlined, FileImageOutlined, FilePdfOutlined, FileWordOutlined, FileExcelOutlined, FilePptOutlined, FileZipOutlined, FileTextOutlined, FileUnknownOutlined } from '@ant-design/icons';
1
+ import { CloudUploadOutlined, PaperClipOutlined, createFromIconfontCN, EnterOutlined, DownloadOutlined, CloseOutlined, PlayCircleOutlined, CopyOutlined, DotChartOutlined, LoadingOutlined, RightOutlined, LikeOutlined, DislikeOutlined, ToolOutlined, SearchOutlined, UpOutlined, DownOutlined, PlusOutlined, CommentOutlined, StarFilled, StarOutlined, ShareAltOutlined, RedoOutlined, DeleteOutlined, ClockCircleOutlined, CheckCircleOutlined, FileImageOutlined, FilePdfOutlined, FileWordOutlined, FileExcelOutlined, FilePptOutlined, FileZipOutlined, FileTextOutlined, FileUnknownOutlined } from '@ant-design/icons';
2
2
  import { Attachments, Sender, FileCard, Bubble, Think, XProvider, Mermaid, CodeHighlighter, Welcome, Prompts, Conversations } from '@ant-design/x-v2';
3
3
  import { useRefState, useDebounce, createTokenManager, useSyncInput, isEmptyObj, markdownToText, RenderWrapper, shouldRender, isFunction, downloadFile, LuyaFilePreview, MarkdownEditor, useDeepEffect, isObject, useWebSocket, isNullOrUnDef, isNumber, getFileSuffixName, emit, FileIcon, copyText, LazyComponent, isBoolean, UserAvatar, htmlToMarkdown, buildUrlParams, isExternal, deepCopy, transforms, deepMerge, createRequest, HttpStatus, isArray, isString, isDef, isNull, transform, getWebSocketUrl, safeParseJson } from '@zero-library/common';
4
4
  import { App, Badge, Button, Flex, Typography, Tooltip, Layout, Tag, Spin, Splitter, Image as Image$1, Popover, Skeleton, Alert, theme, Collapse, Divider as Divider$1, Select as Select$1, Avatar, Space, Form, Drawer, Empty, Modal, Checkbox, Input, InputNumber, Switch as Switch$1, message, Tabs, Upload, Popconfirm, List, Card, Table, Progress as Progress$1 } from 'antd';
@@ -44,7 +44,7 @@ var styles_module_default = {
44
44
  chatAttachments: "styles_module_chatAttachments",
45
45
  chatSender: "styles_module_chatSender"};
46
46
  var Attachments_default = forwardRef(({ fileUpload, fileUploadConfig, fileList = [], onChange, extraParams }, ref) => {
47
- const { message: message3 } = App.useApp();
47
+ const { message: message4 } = App.useApp();
48
48
  const chatStore = useChatStore();
49
49
  const configState = useSnapshot(chatStore.config);
50
50
  const fileListRef = useRef([]);
@@ -72,7 +72,7 @@ var Attachments_default = forwardRef(({ fileUpload, fileUploadConfig, fileList =
72
72
  onChange(files);
73
73
  }, [attachedFiles]);
74
74
  const onErrorTip = useDebounce((errorMsg) => {
75
- message3.error(errorMsg);
75
+ message4.error(errorMsg);
76
76
  }, 300);
77
77
  const findConfig = (file) => {
78
78
  return fileUploadConfig?.allowedTypes?.find((type) => type === getFileSuffixName(file.name)) || "";
@@ -240,6 +240,7 @@ var index_module_default = {
240
240
  var CONV_MODE = {
241
241
  PROD: 1};
242
242
  var TOKEN_KEY = "NS-TOKEN";
243
+ var SHARE_KEY = "SHARE-TOKEN";
243
244
  var tokenManager = createTokenManager({
244
245
  key: TOKEN_KEY
245
246
  });
@@ -331,8 +332,9 @@ var getFileIcon = (extension, fontSize = 24) => {
331
332
  return createIcon(FileUnknownOutlined, "#94a3b8");
332
333
  };
333
334
  var getFileUrl = (params, baseUrl, url) => {
335
+ const authParams = baseUrl === "/luya/share" ? { [SHARE_KEY]: localStorage.getItem(SHARE_KEY) || "" } : { [TOKEN_KEY]: tokenManager.get() };
334
336
  const data = {
335
- [TOKEN_KEY]: tokenManager.get(),
337
+ ...authParams,
336
338
  workspaceType: "conversation" /* CONVERSATION */,
337
339
  ...params
338
340
  };
@@ -821,7 +823,7 @@ var ChatInput = React10.forwardRef(
821
823
  }
822
824
  }
823
825
  ),
824
- 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,
825
827
  ErrorBoundary: LexicalErrorBoundary
826
828
  }
827
829
  ),
@@ -835,6 +837,7 @@ var ChatInput = React10.forwardRef(
835
837
  var ChatInput_default = ChatInput;
836
838
  var ChatSender_default = forwardRef(
837
839
  ({
840
+ placeholder,
838
841
  content,
839
842
  commandConfig = {},
840
843
  fileList = [],
@@ -907,6 +910,7 @@ var ChatSender_default = forwardRef(
907
910
  className: styles_module_default.chatSender,
908
911
  ref: senderRef,
909
912
  value: inputValue,
913
+ placeholder,
910
914
  header: senderHeader,
911
915
  onSubmit,
912
916
  onChange: setInputValue,
@@ -1002,6 +1006,9 @@ var createChatService = (request, config) => {
1002
1006
  const conversationFavorite = (conversationId, isFavorite) => {
1003
1007
  return request.put("/agents/conversations/favorite", { conversationIds: [conversationId], favorite: isFavorite });
1004
1008
  };
1009
+ const shareConversation = (conversationId) => {
1010
+ return request.get(`/agents/conversations/${conversationId}/share/url`);
1011
+ };
1005
1012
  return {
1006
1013
  fetchModelList,
1007
1014
  fetchAgentInfo,
@@ -1021,7 +1028,8 @@ var createChatService = (request, config) => {
1021
1028
  listDataSources,
1022
1029
  listTags,
1023
1030
  getAgentAvatar,
1024
- conversationFavorite
1031
+ conversationFavorite,
1032
+ shareConversation
1025
1033
  };
1026
1034
  };
1027
1035
 
@@ -1067,7 +1075,13 @@ function createChatStore() {
1067
1075
  return await config.services.request.fetchModelList();
1068
1076
  };
1069
1077
  const setServices = ({ http, websocket } = {}) => {
1070
- 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
+ };
1071
1085
  const request = createRequest(httpConfig);
1072
1086
  if (config.hooks?.onRequestInterceptor) {
1073
1087
  request.instance.interceptors.request.use(...config.hooks.onRequestInterceptor);
@@ -1088,9 +1102,9 @@ function createChatStore() {
1088
1102
  config.services.request = { ...createChatService(request, httpConfig), ...http?.request };
1089
1103
  config.services.websocketUrls = ["", ""];
1090
1104
  if (isArray(websocket?.baseURLs)) {
1091
- websocket.baseURLs.forEach((baseURL, index) => {
1092
- if (isString(baseURL)) {
1093
- 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);
1094
1108
  }
1095
1109
  });
1096
1110
  } else {
@@ -1593,7 +1607,7 @@ function createChatStore() {
1593
1607
  }
1594
1608
  if (isMain) config.hooks?.onStepMessage?.(msg);
1595
1609
  }
1596
- function doneCallback(msg, message3, isMain) {
1610
+ function doneCallback(msg, message4, isMain) {
1597
1611
  conversation.messages[msg.conversationId].loading = false;
1598
1612
  const messages = conversation.messages[msg.conversationId]?.message;
1599
1613
  if (messages) {
@@ -1886,9 +1900,9 @@ function createChatStore() {
1886
1900
  }
1887
1901
  }
1888
1902
  }
1889
- function processMessageContent(message3, targetMessages) {
1903
+ function processMessageContent(message4, targetMessages) {
1890
1904
  const newMessage = {
1891
- ...message3,
1905
+ ...message4,
1892
1906
  agentId: agent.agentInfo.id
1893
1907
  };
1894
1908
  const isMain = !targetMessages;
@@ -1956,13 +1970,13 @@ function createChatStore() {
1956
1970
  }
1957
1971
  processMessageContent(newMessage);
1958
1972
  };
1959
- const sendMessage = async (message3, msgFiles = [], params) => {
1973
+ const sendMessage = async (message4, msgFiles = [], params) => {
1960
1974
  const conversationId = conversation.active.id;
1961
1975
  if (conversation.messages[conversationId].loading) return;
1962
1976
  let msgContent = "", files;
1963
1977
  const references = conversation.messages[conversationId].references;
1964
- if (message3) {
1965
- msgContent = message3;
1978
+ if (message4) {
1979
+ msgContent = message4;
1966
1980
  files = [...msgFiles, ...conversation.messages[conversationId].files || []];
1967
1981
  } else {
1968
1982
  if (references?.type === 1 && references?.content?.msgContent) {
@@ -2009,9 +2023,9 @@ function createChatStore() {
2009
2023
  };
2010
2024
  const extraParams = deepCopy(config.params?.params || {});
2011
2025
  const userInputParams = variablesToObject(conversation.active.userInput || []);
2012
- Object.assign(extraParams, message3 ? {} : { ...references?.params }, params, userInputParams);
2026
+ Object.assign(extraParams, message4 ? {} : { ...references?.params }, params, userInputParams);
2013
2027
  sendParams.params = extraParams;
2014
- if (!message3) {
2028
+ if (!message4) {
2015
2029
  setContent("");
2016
2030
  setContentParams();
2017
2031
  setReferences();
@@ -2212,7 +2226,7 @@ var ConversationFavoritesBtn_default = ({ icon, ...rest }) => {
2212
2226
  const activeConversation = useMemo(() => {
2213
2227
  return conversationsState.list.items.find((item) => item.id === conversationState.active.id);
2214
2228
  }, [conversationsState.list.items, conversationState.active.id]);
2215
- const isFavorite = Boolean(activeConversation?.isFavorite);
2229
+ const isFavorite = activeConversation?.isFavorite === true;
2216
2230
  const handleToggleFavorite = () => {
2217
2231
  if (!conversationState.active.id) return;
2218
2232
  chatStore.collectConversation(conversationState.active.id, !isFavorite);
@@ -2222,7 +2236,7 @@ var ConversationFavoritesBtn_default = ({ icon, ...rest }) => {
2222
2236
  {
2223
2237
  title: isFavorite ? "\u53D6\u6D88\u6536\u85CF" : "\u6536\u85CF",
2224
2238
  type: "text",
2225
- size: "small",
2239
+ size: "large",
2226
2240
  disabled: !conversationState.active.id,
2227
2241
  icon: icon?.() || (isFavorite ? /* @__PURE__ */ jsx(StarFilled, { className: "primary-text" }) : /* @__PURE__ */ jsx(StarOutlined, {})),
2228
2242
  onClick: handleToggleFavorite,
@@ -2230,9 +2244,37 @@ var ConversationFavoritesBtn_default = ({ icon, ...rest }) => {
2230
2244
  }
2231
2245
  );
2232
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
2272
+ }
2273
+ );
2274
+ };
2233
2275
  var CreateBtn_default = ({ icon, ...rest }) => {
2234
2276
  const chatStore = useChatStore();
2235
- return /* @__PURE__ */ jsx(Button, { title: "\u65B0\u5EFA\u4F1A\u8BDD", size: "small", type: "text", icon: icon?.() || /* @__PURE__ */ jsx(PlusOutlined, {}), onClick: () => chatStore.createConversation(), ...rest });
2277
+ return /* @__PURE__ */ jsx(Button, { title: "\u65B0\u5EFA\u4F1A\u8BDD", size: "large", type: "text", icon: icon?.() || /* @__PURE__ */ jsx(PlusOutlined, {}), onClick: () => chatStore.createConversation(), ...rest });
2236
2278
  };
2237
2279
 
2238
2280
  // src/ui/common/styles.module.less
@@ -2330,7 +2372,7 @@ var ConversationList_default = () => {
2330
2372
  Button,
2331
2373
  {
2332
2374
  icon: /* @__PURE__ */ jsx(DeleteOutlined, {}),
2333
- title: "\u5220\u9664",
2375
+ title: "\u53D6\u6D88\u6536\u85CF",
2334
2376
  type: "text",
2335
2377
  onClick: (e) => {
2336
2378
  e.stopPropagation();
@@ -2451,7 +2493,7 @@ var HistoryBtn_default = ({ icon, ...rest }) => {
2451
2493
  classNames: { container: style_module_default.popover },
2452
2494
  content: /* @__PURE__ */ jsx(ConversationList_default, {}),
2453
2495
  trigger: ["click"],
2454
- children: /* @__PURE__ */ jsx(Button, { title: "\u5386\u53F2\u4F1A\u8BDD", size: "small", type: "text", icon: icon?.() || /* @__PURE__ */ jsx(CommentOutlined, {}), ...rest })
2496
+ children: /* @__PURE__ */ jsx(Button, { title: "\u5386\u53F2\u4F1A\u8BDD", size: "large", type: "text", icon: icon?.() || /* @__PURE__ */ jsx(CommentOutlined, {}), ...rest })
2455
2497
  }
2456
2498
  );
2457
2499
  };
@@ -2461,7 +2503,8 @@ var ChatHeader_default = ({
2461
2503
  closeBtn = false,
2462
2504
  newConversationBtn = true,
2463
2505
  conversationListBtn = true,
2464
- conversationFavoriteBtn = true
2506
+ conversationFavoriteBtn = true,
2507
+ conversationShareBtn = true
2465
2508
  }) => {
2466
2509
  const chatStore = useChatStore();
2467
2510
  const agentState = useSnapshot(chatStore.agent);
@@ -2482,7 +2525,8 @@ var ChatHeader_default = ({
2482
2525
  /* @__PURE__ */ jsxs("div", { className: styles_module_default2.chatHeaderBtnGroup, children: [
2483
2526
  /* @__PURE__ */ jsx(RenderWrapper, { control: newConversationBtn, DefaultComponent: CreateBtn_default }),
2484
2527
  /* @__PURE__ */ jsx(RenderWrapper, { control: conversationListBtn, DefaultComponent: HistoryBtn_default }),
2485
- /* @__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 })
2486
2530
  ] }),
2487
2531
  /* @__PURE__ */ jsx(
2488
2532
  RenderWrapper,
@@ -3090,12 +3134,12 @@ var DocDrawer_default = ({ title, open, onClose, paramsStr }) => {
3090
3134
  }, [paramsStr]);
3091
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" }) }) });
3092
3136
  };
3093
- var IndexQuote_default = ({ data, loading, message: message3 }) => {
3137
+ var IndexQuote_default = ({ data, loading, message: message4 }) => {
3094
3138
  const [open, setOpen] = useState(false);
3095
3139
  const citation = useMemo(() => {
3096
- const citations = message3.content?.find((item) => item.type === "citation")?.citations ?? [];
3140
+ const citations = message4.content?.find((item) => item.type === "citation")?.citations ?? [];
3097
3141
  return citations?.find((item) => String(item.citationId) === String(data.citationId));
3098
- }, [data.citationId, message3.content]);
3142
+ }, [data.citationId, message4.content]);
3099
3143
  const onClick = () => {
3100
3144
  if (!citation?.citationUrl) return;
3101
3145
  if (isExternal(citation.citationUrl)) {
@@ -3110,7 +3154,7 @@ var IndexQuote_default = ({ data, loading, message: message3 }) => {
3110
3154
  open && /* @__PURE__ */ jsx(DocDrawer_default, { paramsStr: citation?.citationUrl, title: citation?.citationName, open, onClose: () => setOpen(false) })
3111
3155
  ] });
3112
3156
  };
3113
- var MarkImg_default = ({ data, loading, message: message3, ...rest }) => {
3157
+ var MarkImg_default = ({ data, loading, message: message4, ...rest }) => {
3114
3158
  const getPreviewFileUrl = (src) => {
3115
3159
  return buildUrlParams({ [TOKEN_KEY]: tokenManager.get() || "" }, src);
3116
3160
  };
@@ -3137,8 +3181,9 @@ var MdEdit_default = ({ data, loading }) => {
3137
3181
  !loading && /* @__PURE__ */ jsx(Flex, { justify: "end", className: "m-t-16", children: /* @__PURE__ */ jsx(Button, { color: "primary", variant: "outlined", onClick: onOk, children: btnText }) })
3138
3182
  ] });
3139
3183
  };
3140
- var PreviewLink_default = ({ data, loading, message: message3, ...rest }) => {
3184
+ var PreviewLink_default = ({ data, loading, message: message4, ...rest }) => {
3141
3185
  const chatStore = useChatStore();
3186
+ const conversationWorkspacePrefix = "/workspace/conversation/";
3142
3187
  const getLinkFileName = (path) => {
3143
3188
  const lastSegment = path.split("/").pop();
3144
3189
  if (!lastSegment) {
@@ -3150,13 +3195,27 @@ var PreviewLink_default = ({ data, loading, message: message3, ...rest }) => {
3150
3195
  return lastSegment;
3151
3196
  }
3152
3197
  };
3153
- 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
+ }
3154
3208
  const fileName = getLinkFileName(path);
3209
+ return `${conversationWorkspacePrefix}${fileName}`;
3210
+ };
3211
+ const handlePreviewByPath = (path) => {
3212
+ const normalizedPath = normalizePreviewPath(path);
3213
+ const fileName = getLinkFileName(normalizedPath);
3155
3214
  const suffix = getFileSuffixName(fileName);
3156
3215
  chatStore.setPreview({
3157
3216
  fileUrl: chatStore.config.services.request.getPreviewUrl({
3158
- path,
3159
- workspaceId: message3.conversationId
3217
+ path: normalizedPath,
3218
+ workspaceId: message4.conversationId
3160
3219
  }),
3161
3220
  fileName,
3162
3221
  suffix
@@ -3269,7 +3328,7 @@ var adaptMarkdownComponent = (Component, payloadMapRef, messageRef) => {
3269
3328
  return WrappedComponent;
3270
3329
  };
3271
3330
  var adaptMarkdownComponents = (components, payloadMapRef, messageRef) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component, payloadMapRef, messageRef)]));
3272
- var XMarkdown_default = memo(({ message: message3, components = {}, content = "", ...rest }) => {
3331
+ var XMarkdown_default = memo(({ message: message4, components = {}, content = "", ...rest }) => {
3273
3332
  const config = useMemo(() => getMarkdownConfig(), []);
3274
3333
  const formattedContent = useMemo(() => formatMixedContent(content), [content]);
3275
3334
  const newComponents = useMemo(
@@ -3295,9 +3354,9 @@ var XMarkdown_default = memo(({ message: message3, components = {}, content = ""
3295
3354
  [formattedContent, payloadTagPattern]
3296
3355
  );
3297
3356
  const payloadMapRef = useRef(payloadMap);
3298
- const messageRef = useRef(message3);
3357
+ const messageRef = useRef(message4);
3299
3358
  payloadMapRef.current = payloadMap;
3300
- messageRef.current = message3;
3359
+ messageRef.current = message4;
3301
3360
  const markdownComponents = useMemo(() => adaptMarkdownComponents(newComponents, payloadMapRef, messageRef), [payloadTagPattern]);
3302
3361
  return /* @__PURE__ */ jsx(
3303
3362
  XMarkdown,
@@ -3647,7 +3706,7 @@ var Switch = ({ id, label, value, bind_path_token, onChange, onDataChange }) =>
3647
3706
  /* @__PURE__ */ jsx("span", { style: { fontSize: 13, color: "#555" }, children: label })
3648
3707
  ] });
3649
3708
  };
3650
- var Button11 = ({ label, variant = "default", onClick, action, onAction }) => {
3709
+ var Button12 = ({ label, variant = "default", onClick, action, onAction }) => {
3651
3710
  const handleClick = () => {
3652
3711
  if (onClick) {
3653
3712
  onClick();
@@ -3677,7 +3736,7 @@ var A2uiComponents = {
3677
3736
  TextField,
3678
3737
  Select,
3679
3738
  Switch,
3680
- Button: Button11,
3739
+ Button: Button12,
3681
3740
  Divider,
3682
3741
  Tag: Tag3,
3683
3742
  Progress,
@@ -3724,10 +3783,10 @@ function extractDismissedSurfaceIdsFromMessages(messages) {
3724
3783
  const lastCreateIndexBySurface = /* @__PURE__ */ new Map();
3725
3784
  const lastActionIndexBySurface = /* @__PURE__ */ new Map();
3726
3785
  for (let messageIndex = 0; messageIndex < messages.length; messageIndex++) {
3727
- const message3 = messages[messageIndex];
3728
- const items = Array.isArray(message3?.content) ? message3.content : [];
3786
+ const message4 = messages[messageIndex];
3787
+ const items = Array.isArray(message4?.content) ? message4.content : [];
3729
3788
  for (const item of items) {
3730
- if (message3?.role !== 1) {
3789
+ if (message4?.role !== 1) {
3731
3790
  if (item?.type === "a2uiCommand" && item.command) {
3732
3791
  const surfaceId = String(item.command?.createSurface?.surfaceId || "").trim();
3733
3792
  if (surfaceId) lastCreateIndexBySurface.set(surfaceId, messageIndex);
@@ -3743,7 +3802,7 @@ function extractDismissedSurfaceIdsFromMessages(messages) {
3743
3802
  }
3744
3803
  }
3745
3804
  }
3746
- if (message3?.role === 1 && item?.type === "text") {
3805
+ if (message4?.role === 1 && item?.type === "text") {
3747
3806
  const text = item.messageContent || item.text || "";
3748
3807
  if (typeof text !== "string" || !text.includes("a2ui_action.v1")) continue;
3749
3808
  try {
@@ -4326,9 +4385,9 @@ function diffConversationMessages(messages, prevCursors) {
4326
4385
  const nextCursors = [];
4327
4386
  const pendingItems = [];
4328
4387
  for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
4329
- const message3 = messages[messageIndex];
4330
- const messageId = String(message3?.messageId ?? messageIndex);
4331
- 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 : [];
4332
4391
  const prevCursor = prevCursors[messageIndex];
4333
4392
  const startIndex = prevCursor ? prevCursor.contentLength : 0;
4334
4393
  if (prevCursor && (prevCursor.messageId !== messageId || items.length < prevCursor.contentLength)) {
@@ -4345,9 +4404,9 @@ function scanA2uiTagsFromMessages(messages, processedTagIds) {
4345
4404
  const newTags = [];
4346
4405
  const newTagIds = [];
4347
4406
  for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
4348
- const message3 = messages[messageIndex];
4349
- const messageId = String(message3?.messageId ?? messageIndex);
4350
- 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 : [];
4351
4410
  for (const item of items) {
4352
4411
  const text = extractItemTextForA2ui(item);
4353
4412
  if (typeof text !== "string" || !text.includes("<A2UI")) continue;
@@ -4403,9 +4462,9 @@ function reduceA2uiRuntimeMessages(state, messages) {
4403
4462
  processA2uiCommand(cmd, messageIndex, messageId, nextState, effects, deletedSurfaceIds, nextWizardSteps);
4404
4463
  }
4405
4464
  });
4406
- nextState.processedMessageCursors = shouldReplayAll ? messages.map((message3, messageIndex) => ({
4407
- messageId: String(message3?.messageId ?? messageIndex),
4408
- 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
4409
4468
  })) : nextCursors;
4410
4469
  nextState.wizardStepBySurface = { ...nextState.wizardStepBySurface, ...nextWizardSteps };
4411
4470
  if (deletedSurfaceIds.size) {
@@ -4753,8 +4812,8 @@ function readContextModelPath(context) {
4753
4812
  function buildLatestCommandIndexBySurface(messages) {
4754
4813
  const indexBySurface = {};
4755
4814
  let commandIndex = -1;
4756
- for (const message3 of messages) {
4757
- const items = Array.isArray(message3?.content) ? message3.content : [];
4815
+ for (const message4 of messages) {
4816
+ const items = Array.isArray(message4?.content) ? message4.content : [];
4758
4817
  for (const item of items) {
4759
4818
  if (item?.type === "a2uiCommand" && item.command) {
4760
4819
  commandIndex += 1;
@@ -4942,7 +5001,7 @@ var TextNode2 = React10__default.memo(
4942
5001
  item,
4943
5002
  role,
4944
5003
  customComponents,
4945
- message: message3
5004
+ message: message4
4946
5005
  }) => {
4947
5006
  const content = toA2uiDisplayText(role, item?.messageContent);
4948
5007
  const markdownComponents = {
@@ -4955,7 +5014,7 @@ var TextNode2 = React10__default.memo(
4955
5014
  const markdownContent = typeof content === "string" ? transformResourceText(content) : content;
4956
5015
  return /* @__PURE__ */ jsxs(Fragment, { children: [
4957
5016
  !!item.reasoningContent && /* @__PURE__ */ jsx(Think, { title: "\u6DF1\u5EA6\u601D\u8003", style: { marginBottom: "16px" }, children: item.reasoningContent }),
4958
- !!markdownContent && /* @__PURE__ */ jsx(XMarkdown_default, { message: message3, components: markdownComponents, content: markdownContent })
5017
+ !!markdownContent && /* @__PURE__ */ jsx(XMarkdown_default, { message: message4, components: markdownComponents, content: markdownContent })
4959
5018
  ] });
4960
5019
  }
4961
5020
  );
@@ -5283,9 +5342,9 @@ var ToolCallItem = ({ item }) => {
5283
5342
  };
5284
5343
  var tool_call_item_default = ToolCallItem;
5285
5344
  var RENDERABLE_MESSAGE_TYPES = ["runStarted", "toolCall", "toolResult", "text", "stepError", "runFailed", "files", "plan"];
5286
- 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 }) => {
5287
5346
  const content = useMemo(() => {
5288
- return (message3.content || []).filter((item) => {
5347
+ return (message4.content || []).filter((item) => {
5289
5348
  if (!RENDERABLE_MESSAGE_TYPES.includes(item.type)) {
5290
5349
  return false;
5291
5350
  }
@@ -5298,12 +5357,12 @@ var MessageRender_default = React10__default.memo(({ role, message: message3, me
5298
5357
  }
5299
5358
  return true;
5300
5359
  });
5301
- }, [message3.content]);
5360
+ }, [message4.content]);
5302
5361
  const quoteMsg = useMemo(() => {
5303
5362
  const quoteMsg2 = {};
5304
- if (message3.params) {
5363
+ if (message4.params) {
5305
5364
  try {
5306
- const citation = JSON.parse(message3.params).citation;
5365
+ const citation = JSON.parse(message4.params).citation;
5307
5366
  if (citation) {
5308
5367
  quoteMsg2.messageContent = citation;
5309
5368
  }
@@ -5311,7 +5370,7 @@ var MessageRender_default = React10__default.memo(({ role, message: message3, me
5311
5370
  }
5312
5371
  }
5313
5372
  return isEmptyObj(quoteMsg2) ? null : quoteMsg2;
5314
- }, [message3.params, message3.quoteMsg]);
5373
+ }, [message4.params, message4.quoteMsg]);
5315
5374
  const showPending = loading && (content.length === 0 || content[content.length - 1].type !== "text");
5316
5375
  if (content.length === 0 && !showPending) return null;
5317
5376
  const lastToolCallIndex = (() => {
@@ -5335,20 +5394,20 @@ var MessageRender_default = React10__default.memo(({ role, message: message3, me
5335
5394
  TextNode2,
5336
5395
  {
5337
5396
  item,
5338
- role: message3.role,
5397
+ role: message4.role,
5339
5398
  customComponents,
5340
- message: message3,
5399
+ message: message4,
5341
5400
  messageIndex
5342
5401
  },
5343
5402
  `message-${index}`
5344
5403
  ),
5345
- (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),
5346
5405
  item.type === "files" && /* @__PURE__ */ jsx(FilesNode, { item }, `files-${index}`),
5347
5406
  item.type === "plan" && /* @__PURE__ */ jsx(A2uiPlanNode, { item }, `plan-${index}`)
5348
5407
  ] })
5349
5408
  }
5350
5409
  ),
5351
- index === lastToolCallIndex && messageIndex >= 0 ? /* @__PURE__ */ jsx(A2uiMessageCards, { messageIndex, message: message3 }) : null
5410
+ index === lastToolCallIndex && messageIndex >= 0 ? /* @__PURE__ */ jsx(A2uiMessageCards, { messageIndex, message: message4 }) : null
5352
5411
  ] }, `message-${index}`)),
5353
5412
  showPending && role.user === "agent" && /* @__PURE__ */ jsx(Bubble, { role: role.user, placement: role.placement, content: /* @__PURE__ */ jsx(RunStartedNode, {}) }),
5354
5413
  quoteMsg && /* @__PURE__ */ jsx(QuoteMsgNode, { quoteMsg, role })
@@ -5444,13 +5503,13 @@ var BubbleListItems_default = ({
5444
5503
  const messageRefs = useRef({});
5445
5504
  const chatRecords = useMemo(() => {
5446
5505
  const chatRecords2 = [];
5447
- conversationMessages.forEach((message3, messageIndex) => {
5448
- const role = getRole(message3.role);
5506
+ conversationMessages.forEach((message4, messageIndex) => {
5507
+ const role = getRole(message4.role);
5449
5508
  const isLeftBubble = role.user === "agent";
5450
- const isMessageLoading = !!message3.generating;
5451
- const baseKey = `${message3.executionId}-${messageIndex}`;
5509
+ const isMessageLoading = !!message4.generating;
5510
+ const baseKey = `${message4.executionId}-${messageIndex}`;
5452
5511
  const footerNode = !isMessageLoading ? /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 8, children: [
5453
- 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" }),
5454
5513
  /* @__PURE__ */ jsx(Flex, { align: "center", gap: 4, children: role.user === "agent" && /* @__PURE__ */ jsxs(Fragment, { children: [
5455
5514
  /* @__PURE__ */ jsx(
5456
5515
  Button,
@@ -5470,21 +5529,21 @@ var BubbleListItems_default = ({
5470
5529
  /* @__PURE__ */ jsx(
5471
5530
  Button,
5472
5531
  {
5473
- color: message3.feedback === 1 ? "primary" : "default",
5532
+ color: message4.feedback === 1 ? "primary" : "default",
5474
5533
  size: "small",
5475
5534
  variant: "text",
5476
5535
  icon: /* @__PURE__ */ jsx(LikeOutlined, {}),
5477
- onClick: () => chatStore.feedback(message3.executionId, 1, messageIndex)
5536
+ onClick: () => chatStore.feedback(message4.executionId, 1, messageIndex)
5478
5537
  }
5479
5538
  ),
5480
5539
  /* @__PURE__ */ jsx(
5481
5540
  Button,
5482
5541
  {
5483
- color: message3.feedback === 2 ? "primary" : "default",
5542
+ color: message4.feedback === 2 ? "primary" : "default",
5484
5543
  size: "small",
5485
5544
  variant: "text",
5486
5545
  icon: /* @__PURE__ */ jsx(DislikeOutlined, {}),
5487
- onClick: () => chatStore.feedback(message3.executionId, 2, messageIndex)
5546
+ onClick: () => chatStore.feedback(message4.executionId, 2, messageIndex)
5488
5547
  }
5489
5548
  ),
5490
5549
  /* @__PURE__ */ jsx(
@@ -5492,7 +5551,7 @@ var BubbleListItems_default = ({
5492
5551
  {
5493
5552
  control: agentActions,
5494
5553
  ctx: {
5495
- message: message3,
5554
+ message: message4,
5496
5555
  get dom() {
5497
5556
  return messageRefs.current[baseKey];
5498
5557
  }
@@ -5510,7 +5569,7 @@ var BubbleListItems_default = ({
5510
5569
  MessageRender_default,
5511
5570
  {
5512
5571
  role,
5513
- message: message3,
5572
+ message: message4,
5514
5573
  messageIndex,
5515
5574
  customComponents,
5516
5575
  loading: isMessageLoading,
@@ -6563,6 +6622,8 @@ var layouts_default = forwardRef(({ theme: theme5, params, hooks, layout, config
6563
6622
  useDeepEffect(() => {
6564
6623
  if (agentState.agentInfo.id) {
6565
6624
  chatStore.initConversation(config);
6625
+ } else if (config.conversationId) {
6626
+ chatStore.switchConversation(config.conversationId);
6566
6627
  }
6567
6628
  }, [agentState.agentInfo.id, config.conversationId]);
6568
6629
  const hasPreView = useMemo(() => {
@@ -6581,13 +6642,13 @@ var layouts_default = forwardRef(({ theme: theme5, params, hooks, layout, config
6581
6642
  }, [hasPreView]);
6582
6643
  useWebSocket({
6583
6644
  url: configState.services.websocketUrls?.[0],
6584
- onMessage: (message3) => chatStore.acceptMessage(message3.payload),
6645
+ onMessage: (message4) => chatStore.acceptMessage(message4.payload),
6585
6646
  clientHeartbeat: false,
6586
6647
  reconnectInterval: 1e4
6587
6648
  });
6588
6649
  useWebSocket({
6589
6650
  url: configState.services.websocketUrls?.[1],
6590
- onMessage: (message3) => chatStore.acceptMessage(message3.payload),
6651
+ onMessage: (message4) => chatStore.acceptMessage(message4.payload),
6591
6652
  clientHeartbeat: false,
6592
6653
  reconnectInterval: 1e4
6593
6654
  });