@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.cjs.js CHANGED
@@ -74,7 +74,7 @@ var styles_module_default = {
74
74
  chatAttachments: "styles_module_chatAttachments",
75
75
  chatSender: "styles_module_chatSender"};
76
76
  var Attachments_default = React10.forwardRef(({ fileUpload, fileUploadConfig, fileList = [], onChange, extraParams }, ref) => {
77
- const { message: message3 } = antd.App.useApp();
77
+ const { message: message4 } = antd.App.useApp();
78
78
  const chatStore = useChatStore();
79
79
  const configState = valtio.useSnapshot(chatStore.config);
80
80
  const fileListRef = React10.useRef([]);
@@ -102,7 +102,7 @@ var Attachments_default = React10.forwardRef(({ fileUpload, fileUploadConfig, fi
102
102
  onChange(files);
103
103
  }, [attachedFiles]);
104
104
  const onErrorTip = common.useDebounce((errorMsg) => {
105
- message3.error(errorMsg);
105
+ message4.error(errorMsg);
106
106
  }, 300);
107
107
  const findConfig = (file) => {
108
108
  return fileUploadConfig?.allowedTypes?.find((type) => type === common.getFileSuffixName(file.name)) || "";
@@ -270,6 +270,7 @@ var index_module_default = {
270
270
  var CONV_MODE = {
271
271
  PROD: 1};
272
272
  var TOKEN_KEY = "NS-TOKEN";
273
+ var SHARE_KEY = "SHARE-TOKEN";
273
274
  var tokenManager = common.createTokenManager({
274
275
  key: TOKEN_KEY
275
276
  });
@@ -361,8 +362,9 @@ var getFileIcon = (extension, fontSize = 24) => {
361
362
  return createIcon(icons.FileUnknownOutlined, "#94a3b8");
362
363
  };
363
364
  var getFileUrl = (params, baseUrl, url) => {
365
+ const authParams = baseUrl === "/luya/share" ? { [SHARE_KEY]: localStorage.getItem(SHARE_KEY) || "" } : { [TOKEN_KEY]: tokenManager.get() };
364
366
  const data = {
365
- [TOKEN_KEY]: tokenManager.get(),
367
+ ...authParams,
366
368
  workspaceType: "conversation" /* CONVERSATION */,
367
369
  ...params
368
370
  };
@@ -851,7 +853,7 @@ var ChatInput = React10__namespace.forwardRef(
851
853
  }
852
854
  }
853
855
  ),
854
- placeholder: !stringValue && placeholder ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default.promptEditorPlaceholder, children: placeholder }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default.promptEditorPlaceholder, children: "\u4ECA\u5929\u80FD\u5E2E\u4F60\u505A\u4EC0\u4E48\uFF1F" }),
856
+ placeholder: !stringValue ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: index_module_default.promptEditorPlaceholder, children: placeholder || "\u4ECA\u5929\u5E2E\u4F60\u505A\u4E9B\u4EC0\u4E48\uFF1F\u8F93\u5165 '/' \u8C03\u7528\u6280\u80FD\u4E0E\u77E5\u8BC6\u5E93" }) : null,
855
857
  ErrorBoundary: LexicalErrorBoundary.LexicalErrorBoundary
856
858
  }
857
859
  ),
@@ -865,6 +867,7 @@ var ChatInput = React10__namespace.forwardRef(
865
867
  var ChatInput_default = ChatInput;
866
868
  var ChatSender_default = React10.forwardRef(
867
869
  ({
870
+ placeholder,
868
871
  content,
869
872
  commandConfig = {},
870
873
  fileList = [],
@@ -937,6 +940,7 @@ var ChatSender_default = React10.forwardRef(
937
940
  className: styles_module_default.chatSender,
938
941
  ref: senderRef,
939
942
  value: inputValue,
943
+ placeholder,
940
944
  header: senderHeader,
941
945
  onSubmit,
942
946
  onChange: setInputValue,
@@ -1032,6 +1036,9 @@ var createChatService = (request, config) => {
1032
1036
  const conversationFavorite = (conversationId, isFavorite) => {
1033
1037
  return request.put("/agents/conversations/favorite", { conversationIds: [conversationId], favorite: isFavorite });
1034
1038
  };
1039
+ const shareConversation = (conversationId) => {
1040
+ return request.get(`/agents/conversations/${conversationId}/share/url`);
1041
+ };
1035
1042
  return {
1036
1043
  fetchModelList,
1037
1044
  fetchAgentInfo,
@@ -1051,7 +1058,8 @@ var createChatService = (request, config) => {
1051
1058
  listDataSources,
1052
1059
  listTags,
1053
1060
  getAgentAvatar,
1054
- conversationFavorite
1061
+ conversationFavorite,
1062
+ shareConversation
1055
1063
  };
1056
1064
  };
1057
1065
 
@@ -1097,7 +1105,13 @@ function createChatStore() {
1097
1105
  return await config.services.request.fetchModelList();
1098
1106
  };
1099
1107
  const setServices = ({ http, websocket } = {}) => {
1100
- const httpConfig = { baseURL: "/luya/v1", headers: { [TOKEN_KEY]: tokenManager.get() }, ...http?.config };
1108
+ const baseURL = http?.config?.baseURL || "/luya/v1";
1109
+ const headers = baseURL === "/luya/share" ? { [SHARE_KEY]: localStorage.getItem(SHARE_KEY) || "" } : { [TOKEN_KEY]: tokenManager.get() };
1110
+ const httpConfig = {
1111
+ baseURL,
1112
+ headers,
1113
+ ...http?.config
1114
+ };
1101
1115
  const request = common.createRequest(httpConfig);
1102
1116
  if (config.hooks?.onRequestInterceptor) {
1103
1117
  request.instance.interceptors.request.use(...config.hooks.onRequestInterceptor);
@@ -1118,9 +1132,9 @@ function createChatStore() {
1118
1132
  config.services.request = { ...createChatService(request, httpConfig), ...http?.request };
1119
1133
  config.services.websocketUrls = ["", ""];
1120
1134
  if (common.isArray(websocket?.baseURLs)) {
1121
- websocket.baseURLs.forEach((baseURL, index) => {
1122
- if (common.isString(baseURL)) {
1123
- config.services.websocketUrls[index] = getChatSocketUrl(baseURL, websocket?.params || httpConfig.headers);
1135
+ websocket.baseURLs.forEach((baseURL2, index) => {
1136
+ if (common.isString(baseURL2)) {
1137
+ config.services.websocketUrls[index] = getChatSocketUrl(baseURL2, websocket?.params || httpConfig.headers);
1124
1138
  }
1125
1139
  });
1126
1140
  } else {
@@ -1623,7 +1637,7 @@ function createChatStore() {
1623
1637
  }
1624
1638
  if (isMain) config.hooks?.onStepMessage?.(msg);
1625
1639
  }
1626
- function doneCallback(msg, message3, isMain) {
1640
+ function doneCallback(msg, message4, isMain) {
1627
1641
  conversation.messages[msg.conversationId].loading = false;
1628
1642
  const messages = conversation.messages[msg.conversationId]?.message;
1629
1643
  if (messages) {
@@ -1916,9 +1930,9 @@ function createChatStore() {
1916
1930
  }
1917
1931
  }
1918
1932
  }
1919
- function processMessageContent(message3, targetMessages) {
1933
+ function processMessageContent(message4, targetMessages) {
1920
1934
  const newMessage = {
1921
- ...message3,
1935
+ ...message4,
1922
1936
  agentId: agent.agentInfo.id
1923
1937
  };
1924
1938
  const isMain = !targetMessages;
@@ -1986,13 +2000,13 @@ function createChatStore() {
1986
2000
  }
1987
2001
  processMessageContent(newMessage);
1988
2002
  };
1989
- const sendMessage = async (message3, msgFiles = [], params) => {
2003
+ const sendMessage = async (message4, msgFiles = [], params) => {
1990
2004
  const conversationId = conversation.active.id;
1991
2005
  if (conversation.messages[conversationId].loading) return;
1992
2006
  let msgContent = "", files;
1993
2007
  const references = conversation.messages[conversationId].references;
1994
- if (message3) {
1995
- msgContent = message3;
2008
+ if (message4) {
2009
+ msgContent = message4;
1996
2010
  files = [...msgFiles, ...conversation.messages[conversationId].files || []];
1997
2011
  } else {
1998
2012
  if (references?.type === 1 && references?.content?.msgContent) {
@@ -2039,9 +2053,9 @@ function createChatStore() {
2039
2053
  };
2040
2054
  const extraParams = common.deepCopy(config.params?.params || {});
2041
2055
  const userInputParams = variablesToObject(conversation.active.userInput || []);
2042
- Object.assign(extraParams, message3 ? {} : { ...references?.params }, params, userInputParams);
2056
+ Object.assign(extraParams, message4 ? {} : { ...references?.params }, params, userInputParams);
2043
2057
  sendParams.params = extraParams;
2044
- if (!message3) {
2058
+ if (!message4) {
2045
2059
  setContent("");
2046
2060
  setContentParams();
2047
2061
  setReferences();
@@ -2242,7 +2256,7 @@ var ConversationFavoritesBtn_default = ({ icon, ...rest }) => {
2242
2256
  const activeConversation = React10.useMemo(() => {
2243
2257
  return conversationsState.list.items.find((item) => item.id === conversationState.active.id);
2244
2258
  }, [conversationsState.list.items, conversationState.active.id]);
2245
- const isFavorite = Boolean(activeConversation?.isFavorite);
2259
+ const isFavorite = activeConversation?.isFavorite === true;
2246
2260
  const handleToggleFavorite = () => {
2247
2261
  if (!conversationState.active.id) return;
2248
2262
  chatStore.collectConversation(conversationState.active.id, !isFavorite);
@@ -2252,7 +2266,7 @@ var ConversationFavoritesBtn_default = ({ icon, ...rest }) => {
2252
2266
  {
2253
2267
  title: isFavorite ? "\u53D6\u6D88\u6536\u85CF" : "\u6536\u85CF",
2254
2268
  type: "text",
2255
- size: "small",
2269
+ size: "large",
2256
2270
  disabled: !conversationState.active.id,
2257
2271
  icon: icon?.() || (isFavorite ? /* @__PURE__ */ jsxRuntime.jsx(icons.StarFilled, { className: "primary-text" }) : /* @__PURE__ */ jsxRuntime.jsx(icons.StarOutlined, {})),
2258
2272
  onClick: handleToggleFavorite,
@@ -2260,9 +2274,37 @@ var ConversationFavoritesBtn_default = ({ icon, ...rest }) => {
2260
2274
  }
2261
2275
  );
2262
2276
  };
2277
+ var ConversationShareBtn_default = ({ icon, ...rest }) => {
2278
+ const chatStore = useChatStore();
2279
+ const conversationState = valtio.useSnapshot(chatStore.conversation);
2280
+ const configState = valtio.useSnapshot(chatStore.config);
2281
+ const handleShareConversation = async () => {
2282
+ try {
2283
+ const { data } = await configState.services.request.shareConversation(conversationState.active.id);
2284
+ if (data) {
2285
+ common.copyText(data);
2286
+ antd.message.success("\u5206\u4EAB\u94FE\u63A5\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F");
2287
+ }
2288
+ } catch (error) {
2289
+ antd.message.error("\u5206\u4EAB\u4F1A\u8BDD\u5931\u8D25");
2290
+ }
2291
+ };
2292
+ return /* @__PURE__ */ jsxRuntime.jsx(
2293
+ antd.Button,
2294
+ {
2295
+ title: "\u5206\u4EAB",
2296
+ type: "text",
2297
+ size: "large",
2298
+ disabled: !conversationState.active.id,
2299
+ icon: icon?.() || /* @__PURE__ */ jsxRuntime.jsx(icons.ShareAltOutlined, {}),
2300
+ ...rest,
2301
+ onClick: handleShareConversation
2302
+ }
2303
+ );
2304
+ };
2263
2305
  var CreateBtn_default = ({ icon, ...rest }) => {
2264
2306
  const chatStore = useChatStore();
2265
- return /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { title: "\u65B0\u5EFA\u4F1A\u8BDD", size: "small", type: "text", icon: icon?.() || /* @__PURE__ */ jsxRuntime.jsx(icons.PlusOutlined, {}), onClick: () => chatStore.createConversation(), ...rest });
2307
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { title: "\u65B0\u5EFA\u4F1A\u8BDD", size: "large", type: "text", icon: icon?.() || /* @__PURE__ */ jsxRuntime.jsx(icons.PlusOutlined, {}), onClick: () => chatStore.createConversation(), ...rest });
2266
2308
  };
2267
2309
 
2268
2310
  // src/ui/common/styles.module.less
@@ -2360,7 +2402,7 @@ var ConversationList_default = () => {
2360
2402
  antd.Button,
2361
2403
  {
2362
2404
  icon: /* @__PURE__ */ jsxRuntime.jsx(icons.DeleteOutlined, {}),
2363
- title: "\u5220\u9664",
2405
+ title: "\u53D6\u6D88\u6536\u85CF",
2364
2406
  type: "text",
2365
2407
  onClick: (e) => {
2366
2408
  e.stopPropagation();
@@ -2481,7 +2523,7 @@ var HistoryBtn_default = ({ icon, ...rest }) => {
2481
2523
  classNames: { container: style_module_default.popover },
2482
2524
  content: /* @__PURE__ */ jsxRuntime.jsx(ConversationList_default, {}),
2483
2525
  trigger: ["click"],
2484
- children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { title: "\u5386\u53F2\u4F1A\u8BDD", size: "small", type: "text", icon: icon?.() || /* @__PURE__ */ jsxRuntime.jsx(icons.CommentOutlined, {}), ...rest })
2526
+ children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { title: "\u5386\u53F2\u4F1A\u8BDD", size: "large", type: "text", icon: icon?.() || /* @__PURE__ */ jsxRuntime.jsx(icons.CommentOutlined, {}), ...rest })
2485
2527
  }
2486
2528
  );
2487
2529
  };
@@ -2491,7 +2533,8 @@ var ChatHeader_default = ({
2491
2533
  closeBtn = false,
2492
2534
  newConversationBtn = true,
2493
2535
  conversationListBtn = true,
2494
- conversationFavoriteBtn = true
2536
+ conversationFavoriteBtn = true,
2537
+ conversationShareBtn = true
2495
2538
  }) => {
2496
2539
  const chatStore = useChatStore();
2497
2540
  const agentState = valtio.useSnapshot(chatStore.agent);
@@ -2512,7 +2555,8 @@ var ChatHeader_default = ({
2512
2555
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default2.chatHeaderBtnGroup, children: [
2513
2556
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: newConversationBtn, DefaultComponent: CreateBtn_default }),
2514
2557
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: conversationListBtn, DefaultComponent: HistoryBtn_default }),
2515
- /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: conversationFavoriteBtn, DefaultComponent: ConversationFavoritesBtn_default })
2558
+ /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: conversationFavoriteBtn, DefaultComponent: ConversationFavoritesBtn_default }),
2559
+ /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: conversationShareBtn, DefaultComponent: ConversationShareBtn_default })
2516
2560
  ] }),
2517
2561
  /* @__PURE__ */ jsxRuntime.jsx(
2518
2562
  common.RenderWrapper,
@@ -3120,12 +3164,12 @@ var DocDrawer_default = ({ title, open, onClose, paramsStr }) => {
3120
3164
  }, [paramsStr]);
3121
3165
  return /* @__PURE__ */ jsxRuntime.jsx(antd.Drawer, { title, push: false, size: "100%", open, onClose, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, children: content ? /* @__PURE__ */ jsxRuntime.jsx(XMarkdown__default.default, { content }) : /* @__PURE__ */ jsxRuntime.jsx(antd.Empty, { className: "m-t-32" }) }) });
3122
3166
  };
3123
- var IndexQuote_default = ({ data, loading, message: message3 }) => {
3167
+ var IndexQuote_default = ({ data, loading, message: message4 }) => {
3124
3168
  const [open, setOpen] = React10.useState(false);
3125
3169
  const citation = React10.useMemo(() => {
3126
- const citations = message3.content?.find((item) => item.type === "citation")?.citations ?? [];
3170
+ const citations = message4.content?.find((item) => item.type === "citation")?.citations ?? [];
3127
3171
  return citations?.find((item) => String(item.citationId) === String(data.citationId));
3128
- }, [data.citationId, message3.content]);
3172
+ }, [data.citationId, message4.content]);
3129
3173
  const onClick = () => {
3130
3174
  if (!citation?.citationUrl) return;
3131
3175
  if (common.isExternal(citation.citationUrl)) {
@@ -3140,7 +3184,7 @@ var IndexQuote_default = ({ data, loading, message: message3 }) => {
3140
3184
  open && /* @__PURE__ */ jsxRuntime.jsx(DocDrawer_default, { paramsStr: citation?.citationUrl, title: citation?.citationName, open, onClose: () => setOpen(false) })
3141
3185
  ] });
3142
3186
  };
3143
- var MarkImg_default = ({ data, loading, message: message3, ...rest }) => {
3187
+ var MarkImg_default = ({ data, loading, message: message4, ...rest }) => {
3144
3188
  const getPreviewFileUrl = (src) => {
3145
3189
  return common.buildUrlParams({ [TOKEN_KEY]: tokenManager.get() || "" }, src);
3146
3190
  };
@@ -3167,8 +3211,9 @@ var MdEdit_default = ({ data, loading }) => {
3167
3211
  !loading && /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { justify: "end", className: "m-t-16", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { color: "primary", variant: "outlined", onClick: onOk, children: btnText }) })
3168
3212
  ] });
3169
3213
  };
3170
- var PreviewLink_default = ({ data, loading, message: message3, ...rest }) => {
3214
+ var PreviewLink_default = ({ data, loading, message: message4, ...rest }) => {
3171
3215
  const chatStore = useChatStore();
3216
+ const conversationWorkspacePrefix = "/workspace/conversation/";
3172
3217
  const getLinkFileName = (path) => {
3173
3218
  const lastSegment = path.split("/").pop();
3174
3219
  if (!lastSegment) {
@@ -3180,13 +3225,27 @@ var PreviewLink_default = ({ data, loading, message: message3, ...rest }) => {
3180
3225
  return lastSegment;
3181
3226
  }
3182
3227
  };
3183
- const handlePreviewByPath = (path) => {
3228
+ const normalizePreviewPath = (path) => {
3229
+ if (!path) {
3230
+ return path;
3231
+ }
3232
+ if (path.startsWith(conversationWorkspacePrefix)) {
3233
+ return path;
3234
+ }
3235
+ if (path.startsWith(conversationWorkspacePrefix.slice(1))) {
3236
+ return `/${path}`;
3237
+ }
3184
3238
  const fileName = getLinkFileName(path);
3239
+ return `${conversationWorkspacePrefix}${fileName}`;
3240
+ };
3241
+ const handlePreviewByPath = (path) => {
3242
+ const normalizedPath = normalizePreviewPath(path);
3243
+ const fileName = getLinkFileName(normalizedPath);
3185
3244
  const suffix = common.getFileSuffixName(fileName);
3186
3245
  chatStore.setPreview({
3187
3246
  fileUrl: chatStore.config.services.request.getPreviewUrl({
3188
- path,
3189
- workspaceId: message3.conversationId
3247
+ path: normalizedPath,
3248
+ workspaceId: message4.conversationId
3190
3249
  }),
3191
3250
  fileName,
3192
3251
  suffix
@@ -3299,7 +3358,7 @@ var adaptMarkdownComponent = (Component, payloadMapRef, messageRef) => {
3299
3358
  return WrappedComponent;
3300
3359
  };
3301
3360
  var adaptMarkdownComponents = (components, payloadMapRef, messageRef) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component, payloadMapRef, messageRef)]));
3302
- var XMarkdown_default = React10.memo(({ message: message3, components = {}, content = "", ...rest }) => {
3361
+ var XMarkdown_default = React10.memo(({ message: message4, components = {}, content = "", ...rest }) => {
3303
3362
  const config = React10.useMemo(() => getMarkdownConfig(), []);
3304
3363
  const formattedContent = React10.useMemo(() => formatMixedContent(content), [content]);
3305
3364
  const newComponents = React10.useMemo(
@@ -3325,9 +3384,9 @@ var XMarkdown_default = React10.memo(({ message: message3, components = {}, cont
3325
3384
  [formattedContent, payloadTagPattern]
3326
3385
  );
3327
3386
  const payloadMapRef = React10.useRef(payloadMap);
3328
- const messageRef = React10.useRef(message3);
3387
+ const messageRef = React10.useRef(message4);
3329
3388
  payloadMapRef.current = payloadMap;
3330
- messageRef.current = message3;
3389
+ messageRef.current = message4;
3331
3390
  const markdownComponents = React10.useMemo(() => adaptMarkdownComponents(newComponents, payloadMapRef, messageRef), [payloadTagPattern]);
3332
3391
  return /* @__PURE__ */ jsxRuntime.jsx(
3333
3392
  XMarkdown__default.default,
@@ -3677,7 +3736,7 @@ var Switch = ({ id, label, value, bind_path_token, onChange, onDataChange }) =>
3677
3736
  /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 13, color: "#555" }, children: label })
3678
3737
  ] });
3679
3738
  };
3680
- var Button11 = ({ label, variant = "default", onClick, action, onAction }) => {
3739
+ var Button12 = ({ label, variant = "default", onClick, action, onAction }) => {
3681
3740
  const handleClick = () => {
3682
3741
  if (onClick) {
3683
3742
  onClick();
@@ -3707,7 +3766,7 @@ var A2uiComponents = {
3707
3766
  TextField,
3708
3767
  Select,
3709
3768
  Switch,
3710
- Button: Button11,
3769
+ Button: Button12,
3711
3770
  Divider,
3712
3771
  Tag: Tag3,
3713
3772
  Progress,
@@ -3754,10 +3813,10 @@ function extractDismissedSurfaceIdsFromMessages(messages) {
3754
3813
  const lastCreateIndexBySurface = /* @__PURE__ */ new Map();
3755
3814
  const lastActionIndexBySurface = /* @__PURE__ */ new Map();
3756
3815
  for (let messageIndex = 0; messageIndex < messages.length; messageIndex++) {
3757
- const message3 = messages[messageIndex];
3758
- const items = Array.isArray(message3?.content) ? message3.content : [];
3816
+ const message4 = messages[messageIndex];
3817
+ const items = Array.isArray(message4?.content) ? message4.content : [];
3759
3818
  for (const item of items) {
3760
- if (message3?.role !== 1) {
3819
+ if (message4?.role !== 1) {
3761
3820
  if (item?.type === "a2uiCommand" && item.command) {
3762
3821
  const surfaceId = String(item.command?.createSurface?.surfaceId || "").trim();
3763
3822
  if (surfaceId) lastCreateIndexBySurface.set(surfaceId, messageIndex);
@@ -3773,7 +3832,7 @@ function extractDismissedSurfaceIdsFromMessages(messages) {
3773
3832
  }
3774
3833
  }
3775
3834
  }
3776
- if (message3?.role === 1 && item?.type === "text") {
3835
+ if (message4?.role === 1 && item?.type === "text") {
3777
3836
  const text = item.messageContent || item.text || "";
3778
3837
  if (typeof text !== "string" || !text.includes("a2ui_action.v1")) continue;
3779
3838
  try {
@@ -4356,9 +4415,9 @@ function diffConversationMessages(messages, prevCursors) {
4356
4415
  const nextCursors = [];
4357
4416
  const pendingItems = [];
4358
4417
  for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
4359
- const message3 = messages[messageIndex];
4360
- const messageId = String(message3?.messageId ?? messageIndex);
4361
- const items = Array.isArray(message3?.content) ? message3.content : [];
4418
+ const message4 = messages[messageIndex];
4419
+ const messageId = String(message4?.messageId ?? messageIndex);
4420
+ const items = Array.isArray(message4?.content) ? message4.content : [];
4362
4421
  const prevCursor = prevCursors[messageIndex];
4363
4422
  const startIndex = prevCursor ? prevCursor.contentLength : 0;
4364
4423
  if (prevCursor && (prevCursor.messageId !== messageId || items.length < prevCursor.contentLength)) {
@@ -4375,9 +4434,9 @@ function scanA2uiTagsFromMessages(messages, processedTagIds) {
4375
4434
  const newTags = [];
4376
4435
  const newTagIds = [];
4377
4436
  for (let messageIndex = 0; messageIndex < messages.length; messageIndex += 1) {
4378
- const message3 = messages[messageIndex];
4379
- const messageId = String(message3?.messageId ?? messageIndex);
4380
- const items = Array.isArray(message3?.content) ? message3.content : [];
4437
+ const message4 = messages[messageIndex];
4438
+ const messageId = String(message4?.messageId ?? messageIndex);
4439
+ const items = Array.isArray(message4?.content) ? message4.content : [];
4381
4440
  for (const item of items) {
4382
4441
  const text = extractItemTextForA2ui(item);
4383
4442
  if (typeof text !== "string" || !text.includes("<A2UI")) continue;
@@ -4433,9 +4492,9 @@ function reduceA2uiRuntimeMessages(state, messages) {
4433
4492
  processA2uiCommand(cmd, messageIndex, messageId, nextState, effects, deletedSurfaceIds, nextWizardSteps);
4434
4493
  }
4435
4494
  });
4436
- nextState.processedMessageCursors = shouldReplayAll ? messages.map((message3, messageIndex) => ({
4437
- messageId: String(message3?.messageId ?? messageIndex),
4438
- contentLength: Array.isArray(message3?.content) ? message3.content.length : 0
4495
+ nextState.processedMessageCursors = shouldReplayAll ? messages.map((message4, messageIndex) => ({
4496
+ messageId: String(message4?.messageId ?? messageIndex),
4497
+ contentLength: Array.isArray(message4?.content) ? message4.content.length : 0
4439
4498
  })) : nextCursors;
4440
4499
  nextState.wizardStepBySurface = { ...nextState.wizardStepBySurface, ...nextWizardSteps };
4441
4500
  if (deletedSurfaceIds.size) {
@@ -4783,8 +4842,8 @@ function readContextModelPath(context) {
4783
4842
  function buildLatestCommandIndexBySurface(messages) {
4784
4843
  const indexBySurface = {};
4785
4844
  let commandIndex = -1;
4786
- for (const message3 of messages) {
4787
- const items = Array.isArray(message3?.content) ? message3.content : [];
4845
+ for (const message4 of messages) {
4846
+ const items = Array.isArray(message4?.content) ? message4.content : [];
4788
4847
  for (const item of items) {
4789
4848
  if (item?.type === "a2uiCommand" && item.command) {
4790
4849
  commandIndex += 1;
@@ -4972,7 +5031,7 @@ var TextNode2 = React10__namespace.default.memo(
4972
5031
  item,
4973
5032
  role,
4974
5033
  customComponents,
4975
- message: message3
5034
+ message: message4
4976
5035
  }) => {
4977
5036
  const content = toA2uiDisplayText(role, item?.messageContent);
4978
5037
  const markdownComponents = {
@@ -4985,7 +5044,7 @@ var TextNode2 = React10__namespace.default.memo(
4985
5044
  const markdownContent = typeof content === "string" ? transformResourceText(content) : content;
4986
5045
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4987
5046
  !!item.reasoningContent && /* @__PURE__ */ jsxRuntime.jsx(xV2.Think, { title: "\u6DF1\u5EA6\u601D\u8003", style: { marginBottom: "16px" }, children: item.reasoningContent }),
4988
- !!markdownContent && /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message3, components: markdownComponents, content: markdownContent })
5047
+ !!markdownContent && /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message4, components: markdownComponents, content: markdownContent })
4989
5048
  ] });
4990
5049
  }
4991
5050
  );
@@ -5313,9 +5372,9 @@ var ToolCallItem = ({ item }) => {
5313
5372
  };
5314
5373
  var tool_call_item_default = ToolCallItem;
5315
5374
  var RENDERABLE_MESSAGE_TYPES = ["runStarted", "toolCall", "toolResult", "text", "stepError", "runFailed", "files", "plan"];
5316
- var MessageRender_default = React10__namespace.default.memo(({ role, message: message3, messageIndex = -1, loading, containerRef, customComponents }) => {
5375
+ var MessageRender_default = React10__namespace.default.memo(({ role, message: message4, messageIndex = -1, loading, containerRef, customComponents }) => {
5317
5376
  const content = React10.useMemo(() => {
5318
- return (message3.content || []).filter((item) => {
5377
+ return (message4.content || []).filter((item) => {
5319
5378
  if (!RENDERABLE_MESSAGE_TYPES.includes(item.type)) {
5320
5379
  return false;
5321
5380
  }
@@ -5328,12 +5387,12 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
5328
5387
  }
5329
5388
  return true;
5330
5389
  });
5331
- }, [message3.content]);
5390
+ }, [message4.content]);
5332
5391
  const quoteMsg = React10.useMemo(() => {
5333
5392
  const quoteMsg2 = {};
5334
- if (message3.params) {
5393
+ if (message4.params) {
5335
5394
  try {
5336
- const citation = JSON.parse(message3.params).citation;
5395
+ const citation = JSON.parse(message4.params).citation;
5337
5396
  if (citation) {
5338
5397
  quoteMsg2.messageContent = citation;
5339
5398
  }
@@ -5341,7 +5400,7 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
5341
5400
  }
5342
5401
  }
5343
5402
  return common.isEmptyObj(quoteMsg2) ? null : quoteMsg2;
5344
- }, [message3.params, message3.quoteMsg]);
5403
+ }, [message4.params, message4.quoteMsg]);
5345
5404
  const showPending = loading && (content.length === 0 || content[content.length - 1].type !== "text");
5346
5405
  if (content.length === 0 && !showPending) return null;
5347
5406
  const lastToolCallIndex = (() => {
@@ -5365,20 +5424,20 @@ var MessageRender_default = React10__namespace.default.memo(({ role, message: me
5365
5424
  TextNode2,
5366
5425
  {
5367
5426
  item,
5368
- role: message3.role,
5427
+ role: message4.role,
5369
5428
  customComponents,
5370
- message: message3,
5429
+ message: message4,
5371
5430
  messageIndex
5372
5431
  },
5373
5432
  `message-${index}`
5374
5433
  ),
5375
- (item.type === "stepError" || item.type === "runFailed") && (item.errorMessage ? /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message3, components: customComponents, content: item.errorMessage }) : null),
5434
+ (item.type === "stepError" || item.type === "runFailed") && (item.errorMessage ? /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message4, components: customComponents, content: item.errorMessage }) : null),
5376
5435
  item.type === "files" && /* @__PURE__ */ jsxRuntime.jsx(FilesNode, { item }, `files-${index}`),
5377
5436
  item.type === "plan" && /* @__PURE__ */ jsxRuntime.jsx(A2uiPlanNode, { item }, `plan-${index}`)
5378
5437
  ] })
5379
5438
  }
5380
5439
  ),
5381
- index === lastToolCallIndex && messageIndex >= 0 ? /* @__PURE__ */ jsxRuntime.jsx(A2uiMessageCards, { messageIndex, message: message3 }) : null
5440
+ index === lastToolCallIndex && messageIndex >= 0 ? /* @__PURE__ */ jsxRuntime.jsx(A2uiMessageCards, { messageIndex, message: message4 }) : null
5382
5441
  ] }, `message-${index}`)),
5383
5442
  showPending && role.user === "agent" && /* @__PURE__ */ jsxRuntime.jsx(xV2.Bubble, { role: role.user, placement: role.placement, content: /* @__PURE__ */ jsxRuntime.jsx(RunStartedNode, {}) }),
5384
5443
  quoteMsg && /* @__PURE__ */ jsxRuntime.jsx(QuoteMsgNode, { quoteMsg, role })
@@ -5474,13 +5533,13 @@ var BubbleListItems_default = ({
5474
5533
  const messageRefs = React10.useRef({});
5475
5534
  const chatRecords = React10.useMemo(() => {
5476
5535
  const chatRecords2 = [];
5477
- conversationMessages.forEach((message3, messageIndex) => {
5478
- const role = getRole(message3.role);
5536
+ conversationMessages.forEach((message4, messageIndex) => {
5537
+ const role = getRole(message4.role);
5479
5538
  const isLeftBubble = role.user === "agent";
5480
- const isMessageLoading = !!message3.generating;
5481
- const baseKey = `${message3.executionId}-${messageIndex}`;
5539
+ const isMessageLoading = !!message4.generating;
5540
+ const baseKey = `${message4.executionId}-${messageIndex}`;
5482
5541
  const footerNode = !isMessageLoading ? /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", gap: 8, children: [
5483
- message3.stopFlag && isLeftBubble && /* @__PURE__ */ jsxRuntime.jsx(Text3, { type: "secondary", style: { flex: "none" }, children: "\u5DF2\u505C\u6B62" }),
5542
+ message4.stopFlag && isLeftBubble && /* @__PURE__ */ jsxRuntime.jsx(Text3, { type: "secondary", style: { flex: "none" }, children: "\u5DF2\u505C\u6B62" }),
5484
5543
  /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { align: "center", gap: 4, children: role.user === "agent" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5485
5544
  /* @__PURE__ */ jsxRuntime.jsx(
5486
5545
  antd.Button,
@@ -5500,21 +5559,21 @@ var BubbleListItems_default = ({
5500
5559
  /* @__PURE__ */ jsxRuntime.jsx(
5501
5560
  antd.Button,
5502
5561
  {
5503
- color: message3.feedback === 1 ? "primary" : "default",
5562
+ color: message4.feedback === 1 ? "primary" : "default",
5504
5563
  size: "small",
5505
5564
  variant: "text",
5506
5565
  icon: /* @__PURE__ */ jsxRuntime.jsx(icons.LikeOutlined, {}),
5507
- onClick: () => chatStore.feedback(message3.executionId, 1, messageIndex)
5566
+ onClick: () => chatStore.feedback(message4.executionId, 1, messageIndex)
5508
5567
  }
5509
5568
  ),
5510
5569
  /* @__PURE__ */ jsxRuntime.jsx(
5511
5570
  antd.Button,
5512
5571
  {
5513
- color: message3.feedback === 2 ? "primary" : "default",
5572
+ color: message4.feedback === 2 ? "primary" : "default",
5514
5573
  size: "small",
5515
5574
  variant: "text",
5516
5575
  icon: /* @__PURE__ */ jsxRuntime.jsx(icons.DislikeOutlined, {}),
5517
- onClick: () => chatStore.feedback(message3.executionId, 2, messageIndex)
5576
+ onClick: () => chatStore.feedback(message4.executionId, 2, messageIndex)
5518
5577
  }
5519
5578
  ),
5520
5579
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -5522,7 +5581,7 @@ var BubbleListItems_default = ({
5522
5581
  {
5523
5582
  control: agentActions,
5524
5583
  ctx: {
5525
- message: message3,
5584
+ message: message4,
5526
5585
  get dom() {
5527
5586
  return messageRefs.current[baseKey];
5528
5587
  }
@@ -5540,7 +5599,7 @@ var BubbleListItems_default = ({
5540
5599
  MessageRender_default,
5541
5600
  {
5542
5601
  role,
5543
- message: message3,
5602
+ message: message4,
5544
5603
  messageIndex,
5545
5604
  customComponents,
5546
5605
  loading: isMessageLoading,
@@ -6593,6 +6652,8 @@ var layouts_default = React10.forwardRef(({ theme: theme5, params, hooks, layout
6593
6652
  common.useDeepEffect(() => {
6594
6653
  if (agentState.agentInfo.id) {
6595
6654
  chatStore.initConversation(config);
6655
+ } else if (config.conversationId) {
6656
+ chatStore.switchConversation(config.conversationId);
6596
6657
  }
6597
6658
  }, [agentState.agentInfo.id, config.conversationId]);
6598
6659
  const hasPreView = React10.useMemo(() => {
@@ -6611,13 +6672,13 @@ var layouts_default = React10.forwardRef(({ theme: theme5, params, hooks, layout
6611
6672
  }, [hasPreView]);
6612
6673
  common.useWebSocket({
6613
6674
  url: configState.services.websocketUrls?.[0],
6614
- onMessage: (message3) => chatStore.acceptMessage(message3.payload),
6675
+ onMessage: (message4) => chatStore.acceptMessage(message4.payload),
6615
6676
  clientHeartbeat: false,
6616
6677
  reconnectInterval: 1e4
6617
6678
  });
6618
6679
  common.useWebSocket({
6619
6680
  url: configState.services.websocketUrls?.[1],
6620
- onMessage: (message3) => chatStore.acceptMessage(message3.payload),
6681
+ onMessage: (message4) => chatStore.acceptMessage(message4.payload),
6621
6682
  clientHeartbeat: false,
6622
6683
  reconnectInterval: 1e4
6623
6684
  });