@zero-library/chat-agent 2.1.18 → 2.1.20

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
@@ -2,19 +2,19 @@
2
2
 
3
3
  var common = require('@zero-library/common');
4
4
  var antd = require('antd');
5
- var dayjs = require('dayjs');
6
5
  var jsxRuntime = require('react/jsx-runtime');
7
6
  var react = require('react');
8
7
  var valtio = require('valtio');
9
8
  var icons = require('@ant-design/icons');
10
9
  var x = require('@ant-design/x');
11
- var classNames9 = require('classnames');
10
+ var classNames8 = require('classnames');
11
+ var dayjs = require('dayjs');
12
12
  var InfiniteScroll = require('react-infinite-scroll-component');
13
13
 
14
14
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
15
 
16
+ var classNames8__default = /*#__PURE__*/_interopDefault(classNames8);
16
17
  var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
17
- var classNames9__default = /*#__PURE__*/_interopDefault(classNames9);
18
18
  var InfiniteScroll__default = /*#__PURE__*/_interopDefault(InfiniteScroll);
19
19
 
20
20
  var __defProp = Object.defineProperty;
@@ -26,33 +26,6 @@ var __export = (target, all) => {
26
26
  for (var name in all)
27
27
  __defProp(target, name, { get: all[name], enumerable: true });
28
28
  };
29
- var classifyTime, copy;
30
- var init_utils = __esm({
31
- "src/core/utils.ts"() {
32
- classifyTime = (timestamp) => {
33
- const now = dayjs__default.default();
34
- const target = dayjs__default.default(timestamp);
35
- if (target.isSame(now, "day")) {
36
- return "\u4ECA\u5929";
37
- }
38
- const diffInDays = now.diff(target, "day");
39
- if (diffInDays < 7) {
40
- return "\u6700\u8FD1 7 \u5929";
41
- } else if (diffInDays < 30) {
42
- return "\u6700\u8FD1 30 \u5929";
43
- } else if (diffInDays < 180) {
44
- return "\u6700\u8FD1\u534A\u5E74";
45
- } else {
46
- return "\u66F4\u65E9";
47
- }
48
- };
49
- copy = (value) => {
50
- common.copyText(value).then(() => {
51
- antd.message.success("\u590D\u5236\u6210\u529F");
52
- });
53
- };
54
- }
55
- });
56
29
  var ChatProvider, useChatStore;
57
30
  var init_Context = __esm({
58
31
  "src/stores/Context.ts"() {
@@ -211,7 +184,6 @@ __export(FileEdit_exports, {
211
184
  var FileEdit_default;
212
185
  var init_FileEdit = __esm({
213
186
  "src/ui/common/markdownAlert/FileEdit.tsx"() {
214
- init_utils();
215
187
  init_Context();
216
188
  init_styles_module();
217
189
  FileEdit_default = ({ data, loading }) => {
@@ -227,7 +199,7 @@ var init_FileEdit = __esm({
227
199
  ] }),
228
200
  /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
229
201
  /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { color: "default", variant: "text", size: "small", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlayCircleOutlined, {}), onClick: onPreview, children: "\u9884\u89C8\u7F16\u8F91" }),
230
- /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { color: "default", variant: "text", size: "small", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CopyOutlined, {}), onClick: () => copy(data.content), children: "\u590D\u5236" })
202
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { color: "default", variant: "text", size: "small", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CopyOutlined, {}), onClick: () => common.copyText(data.content), children: "\u590D\u5236" })
231
203
  ] }) })
232
204
  ] }),
233
205
  /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { gap: 8, align: "center", className: styles_module_default.fileEditContent, children: /* @__PURE__ */ jsxRuntime.jsx(common.RenderMarkdown, { content: data.content }) })
@@ -310,9 +282,26 @@ var init_Think = __esm({
310
282
  };
311
283
  }
312
284
  });
313
-
314
- // src/stores/index.ts
315
- init_utils();
285
+ var classifyTime = (timestamp) => {
286
+ const now = dayjs__default.default();
287
+ const target = dayjs__default.default(timestamp);
288
+ if (target.isSame(now, "day")) {
289
+ return "\u4ECA\u5929";
290
+ }
291
+ const diffInDays = now.diff(target, "day");
292
+ if (diffInDays < 7) {
293
+ return "\u6700\u8FD1 7 \u5929";
294
+ } else if (diffInDays < 30) {
295
+ return "\u6700\u8FD1 30 \u5929";
296
+ } else if (diffInDays < 180) {
297
+ return "\u6700\u8FD1\u534A\u5E74";
298
+ } else {
299
+ return "\u66F4\u65E9";
300
+ }
301
+ };
302
+ var replaceThinkTags = (str) => {
303
+ return str.replace(/<think>/g, ":::alert type=think data={content:'").replace(/<\/think>/g, "'} :::");
304
+ };
316
305
 
317
306
  // src/services/index.ts
318
307
  var createChatService = (request) => {
@@ -448,6 +437,7 @@ function createChatStore() {
448
437
  },
449
438
  hooks: {},
450
439
  layout: {},
440
+ /** 文件预览状态 */
451
441
  preview: {
452
442
  file: {},
453
443
  isEdit: false
@@ -455,7 +445,9 @@ function createChatStore() {
455
445
  // isShow: 0, // 0 不显示 1 显示 2 用户关闭
456
446
  // isIntact: false // true 完整 false 不完整
457
447
  },
448
+ /** 当前用户信息 */
458
449
  userInfo: {},
450
+ /** 聊天参数配置 */
459
451
  params: {}
460
452
  });
461
453
  const setServices = ({ baseUrl = "/api" } = {}) => {
@@ -497,14 +489,16 @@ function createChatStore() {
497
489
  },
498
490
  name: "name",
499
491
  iconUrl: "avatar",
500
- description: "name"
492
+ description: "remark"
501
493
  });
502
494
  };
503
495
  const receiver = valtio.proxy({
496
+ /** 当前激活的接收者信息(智能体或专家) */
504
497
  active: {},
498
+ /** 接收者加载状态 */
505
499
  loading: false,
500
+ /** 接收者透传参数,后期可能扩展不透传参数 */
506
501
  params: {}
507
- // 透传参数,后期可能扩展不透传参数
508
502
  });
509
503
  const setReceiverParams = (params) => {
510
504
  if (common.isObject(params)) {
@@ -563,10 +557,15 @@ function createChatStore() {
563
557
  setReceiverParams();
564
558
  };
565
559
  const character = valtio.proxy({
560
+ /** 性格列表 */
566
561
  list: [],
562
+ /** 当前激活的性格 */
567
563
  active: {},
564
+ /** 性格选择面板是否打开 */
568
565
  open: false,
566
+ /** 加载性格列表的状态 */
569
567
  loading: false,
568
+ /** 切换性格时的加载状态 */
570
569
  switchLoading: false
571
570
  });
572
571
  const getCharacters = async (agentId) => {
@@ -601,16 +600,20 @@ function createChatStore() {
601
600
  }
602
601
  };
603
602
  const conversations = valtio.proxy({
603
+ /** 会话列表数据 */
604
604
  list: {
605
605
  items: [],
606
+ /** 分页查询参数 */
606
607
  params: {
607
608
  pageNum: 1,
608
609
  pageSize: 1e3
609
610
  }
610
611
  },
612
+ /** 当前会话索引,创建会话时更新,促使页面更新会话列表 */
611
613
  updateIndex: 0,
612
- // 当前会话索引, 创建会话时更新,促使页面更新会话列表
614
+ /** 获取会话列表的加载状态 */
613
615
  loading: false,
616
+ /** 删除会话的加载状态 */
614
617
  delLoading: false
615
618
  });
616
619
  const getConversations = async (targetId, targetType) => {
@@ -656,14 +659,18 @@ function createChatStore() {
656
659
  }
657
660
  };
658
661
  const conversation = valtio.proxy({
659
- // 每个会话单独存储
662
+ /** 当前激活的会话信息 */
660
663
  active: {
661
664
  id: "",
665
+ /** 会话成员对象,包含用户、智能体、专家等 */
662
666
  member: {}
663
667
  },
668
+ /** 每个会话的消息存储,以会话ID为键 */
664
669
  messages: {},
670
+ /** 消息反馈状态 */
665
671
  feedback: {
666
672
  // open: false,
673
+ /** 反馈操作加载状态 */
667
674
  loading: false
668
675
  // recordId: '',
669
676
  // target: undefined as number | undefined
@@ -711,14 +718,18 @@ function createChatStore() {
711
718
  };
712
719
  const setInitMessage = async (conversationId) => {
713
720
  conversation.messages[conversationId] = {
721
+ /** 输入框内容 */
714
722
  content: "",
723
+ /** 上传文件列表 */
715
724
  files: [],
716
- // 上传文件内容
725
+ /** 头部展开状态 */
717
726
  headerOpen: false,
727
+ /** 消息发送/接收加载状态 */
718
728
  loading: false,
729
+ /** 消息列表 */
719
730
  message: [],
731
+ /** 推荐问题列表 */
720
732
  questionList: []
721
- // 推荐问题
722
733
  };
723
734
  };
724
735
  const resolveConversationId = async (receiverId, strategy = 2) => {
@@ -823,13 +834,13 @@ function createChatStore() {
823
834
  if (other) return other;
824
835
  return void 0;
825
836
  };
826
- const sendMessage = async (message3, files = [], params) => {
837
+ const sendMessage = async (message2, files = [], params) => {
827
838
  const conversationId = conversation.active.id;
828
839
  if (conversation.messages[conversationId].loading) return;
829
840
  let msgContent = "", msgFiles;
830
841
  const references = conversation.messages[conversationId].references;
831
- if (message3) {
832
- msgContent = message3;
842
+ if (message2) {
843
+ msgContent = message2;
833
844
  msgFiles = files;
834
845
  } else {
835
846
  if (references?.type === 1 && references?.content?.markdown) {
@@ -857,9 +868,9 @@ function createChatStore() {
857
868
  stream: true
858
869
  };
859
870
  const extraParams = common.deepCopy(config.params.params || {});
860
- Object.assign(extraParams, receiver.params, message3 ? {} : references?.params, params);
871
+ Object.assign(extraParams, receiver.params, message2 ? {} : references?.params, params);
861
872
  sendParams.params = JSON.stringify(extraParams);
862
- if (!message3) {
873
+ if (!message2) {
863
874
  setContent("");
864
875
  setFileList([]);
865
876
  setReferences();
@@ -905,15 +916,15 @@ function createChatStore() {
905
916
  const messages = conversation.messages[msg.conversationId].message;
906
917
  const idx = findMsgIndex(msg.conversationId, msg.id);
907
918
  if (idx === -1) return;
908
- const message3 = messages[idx];
919
+ const message2 = messages[idx];
909
920
  conversation.messages[msg.conversationId].loading = true;
910
- if (message3?.type === "STEP_STARTED" || message3?.type === "TEXT_MESSAGE_START") {
921
+ if (message2?.type === "STEP_STARTED" || message2?.type === "TEXT_MESSAGE_START") {
911
922
  messages[idx] = msg;
912
923
  return;
913
924
  }
914
925
  messages[idx] = {
915
- ...message3,
916
- msgContent: message3.msgContent + (msg.msgContent || "")
926
+ ...message2,
927
+ msgContent: message2.msgContent + (msg.msgContent || "")
917
928
  };
918
929
  };
919
930
  const endCallback = (msg) => {
@@ -953,35 +964,65 @@ function createChatStore() {
953
964
  }
954
965
  };
955
966
  return {
967
+ /** 全局配置对象 */
956
968
  config,
969
+ /** 设置服务配置 */
957
970
  setServices,
971
+ /** 设置文件预览 */
958
972
  setPreview,
973
+ /** 设置布局配置 */
959
974
  setLayout,
975
+ /** 设置生命周期钩子 */
960
976
  setHooks,
977
+ /** 设置聊天参数 */
961
978
  setParams,
979
+ /** 设置用户信息 */
962
980
  setUserInfo,
981
+ /** 智能体性格状态 */
963
982
  character,
983
+ /** 获取性格列表 */
964
984
  getCharacters,
985
+ /** 打开性格选择面板 */
965
986
  openCharacterList,
987
+ /** 关闭性格选择面板 */
966
988
  closeCharacterList,
989
+ /** 切换性格 */
967
990
  switchCharacter,
991
+ /** 接收者状态 */
968
992
  receiver,
993
+ /** 设置接收者参数 */
969
994
  setReceiverParams,
995
+ /** 历史会话状态 */
970
996
  conversations,
997
+ /** 获取会话列表 */
971
998
  getConversations,
999
+ /** 删除会话 */
972
1000
  delConversation,
1001
+ /** 当前会话状态 */
973
1002
  conversation,
1003
+ /** 设置说话人类型 */
974
1004
  setSpeakHuman,
1005
+ /** 设置引用消息 */
975
1006
  setReferences,
1007
+ /** 设置消息内容 */
976
1008
  setContent,
1009
+ /** 设置文件列表 */
977
1010
  setFileList,
1011
+ /** 设置头部展开状态 */
978
1012
  setHeaderOpen,
1013
+ /** 消息反馈操作 */
979
1014
  feedback,
1015
+ /** 切换智能体会话 */
980
1016
  switchAgentConversation,
1017
+ /** 创建新会话 */
981
1018
  createConversation,
1019
+ /** 切换会话 */
982
1020
  switchConversation,
1021
+ /** 发送消息 */
983
1022
  sendMessage,
1023
+ /** 取消接收 */
984
1024
  cancelReceive,
1025
+ /** 接收消息 */
985
1026
  acceptMessage
986
1027
  };
987
1028
  }
@@ -1007,17 +1048,17 @@ var styles_module_default2 = {
1007
1048
  chatSender: "styles_module_chatSender",
1008
1049
  chatQuoteMsg: "styles_module_chatQuoteMsg"
1009
1050
  };
1010
- var MessageRender_default = ({ message: message3, placement }) => {
1011
- return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, children: !(message3.msgContent || message3.msgFiles.length) ? /* @__PURE__ */ jsxRuntime.jsx(antd.Typography, { children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { size: "small" }) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1012
- message3.msgContent && /* @__PURE__ */ jsxRuntime.jsx(
1051
+ var MessageRender_default = ({ message: message2, placement }) => {
1052
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, children: !(message2.msgContent || message2.msgFiles.length) ? /* @__PURE__ */ jsxRuntime.jsx(antd.Typography, { children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { size: "small" }) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1053
+ message2.msgContent && /* @__PURE__ */ jsxRuntime.jsx(
1013
1054
  x.Bubble,
1014
1055
  {
1015
1056
  placement,
1016
- className: classNames9__default.default({ [styles_module_default2.loadingMessage]: message3.type }),
1017
- content: /* @__PURE__ */ jsxRuntime.jsx(common.RenderMarkdown, { content: message3.msgContent, customComponents })
1057
+ className: classNames8__default.default({ [styles_module_default2.loadingMessage]: message2.type }),
1058
+ content: /* @__PURE__ */ jsxRuntime.jsx(common.RenderMarkdown, { content: replaceThinkTags(message2.msgContent), customComponents })
1018
1059
  }
1019
1060
  ),
1020
- message3.msgFiles?.map((file) => /* @__PURE__ */ jsxRuntime.jsx(
1061
+ message2.msgFiles?.map((file) => /* @__PURE__ */ jsxRuntime.jsx(
1021
1062
  x.Bubble,
1022
1063
  {
1023
1064
  className: "m-t-8",
@@ -1037,19 +1078,19 @@ var MessageRender_default = ({ message: message3, placement }) => {
1037
1078
  },
1038
1079
  file.content
1039
1080
  )),
1040
- message3.quoteMsg?.id && /* @__PURE__ */ jsxRuntime.jsx(
1081
+ message2.quoteMsg?.id && /* @__PURE__ */ jsxRuntime.jsx(
1041
1082
  x.Bubble,
1042
1083
  {
1043
- className: classNames9__default.default(styles_module_default2.chatQuoteMsg),
1084
+ className: classNames8__default.default(styles_module_default2.chatQuoteMsg),
1044
1085
  placement,
1045
1086
  content: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, gap: 8, children: [
1046
- message3.quoteMsg.msgContent && /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
1087
+ message2.quoteMsg.msgContent && /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
1047
1088
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u3010\u5F15\u7528\u6D88\u606F\u3011\uFF1A" }),
1048
- /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { flex: 1, className: "text-ellipsis", children: message3.quoteMsg.msgContent })
1089
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { flex: 1, className: "text-ellipsis", children: message2.quoteMsg.msgContent })
1049
1090
  ] }),
1050
- message3.quoteMsg?.msgFiles && message3.quoteMsg.msgFiles.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
1091
+ message2.quoteMsg?.msgFiles && message2.quoteMsg.msgFiles.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
1051
1092
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u3010\u5F15\u7528\u6587\u4EF6\u3011\uFF1A" }),
1052
- /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { gap: 8, wrap: true, flex: 1, children: message3.quoteMsg.msgFiles.map((file) => /* @__PURE__ */ jsxRuntime.jsx(
1093
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { gap: 8, wrap: true, flex: 1, children: message2.quoteMsg.msgFiles.map((file) => /* @__PURE__ */ jsxRuntime.jsx(
1053
1094
  x.Attachments.FileCard,
1054
1095
  {
1055
1096
  item: {
@@ -1075,7 +1116,6 @@ var MEMBER_TYPE = {
1075
1116
  };
1076
1117
 
1077
1118
  // src/ui/common/BubbleListItems.tsx
1078
- init_utils();
1079
1119
  init_Context();
1080
1120
 
1081
1121
  // src/ui/common/styles.module.less
@@ -1101,73 +1141,7 @@ var styles_module_default3 = {
1101
1141
  nsAvatarListItem: "styles_module_nsAvatarListItem",
1102
1142
  nsAvatarListItemIcon: "styles_module_nsAvatarListItemIcon",
1103
1143
  nsAvatarListItemIconActive: "styles_module_nsAvatarListItemIconActive",
1104
- nsAvatarListItemName: "styles_module_nsAvatarListItemName",
1105
- think: "styles_module_think2",
1106
- loadingMessage: "styles_module_loadingMessage2"
1107
- };
1108
- function extractThinkContent(content) {
1109
- let main = content;
1110
- const thinkContents = [];
1111
- let buffer = "";
1112
- const regex = /<think>(.*?)<\/think>/gs;
1113
- for (const match of content.matchAll(regex)) {
1114
- const thinkText = match[1].trim();
1115
- thinkContents.push(thinkText);
1116
- main = main.replace(match[0], "");
1117
- }
1118
- const lastStart = content.lastIndexOf("<think>");
1119
- const lastEnd = content.lastIndexOf("</think>");
1120
- if (lastStart > lastEnd) {
1121
- buffer = content.slice(lastStart).replace("<think>", "");
1122
- main = main.slice(0, lastStart);
1123
- }
1124
- return { mainContent: main, thinkContents, thinkBuffer: buffer };
1125
- }
1126
- function renderMarkdownPanel(content, label, key) {
1127
- return {
1128
- key,
1129
- label,
1130
- children: /* @__PURE__ */ jsxRuntime.jsx(common.RenderMarkdown, { content, customComponents })
1131
- };
1132
- }
1133
- var MessageAIRender_default = ({ message: message3, placement }) => {
1134
- const { mainContent, thinkContents, thinkBuffer } = react.useMemo(() => {
1135
- if (!message3?.msgContent) return { mainContent: "", thinkContents: [], thinkBuffer: "" };
1136
- return extractThinkContent(message3.msgContent);
1137
- }, [message3?.msgContent]);
1138
- if (!message3.msgContent) {
1139
- return /* @__PURE__ */ jsxRuntime.jsx(antd.Typography, { children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { size: "small" }) });
1140
- }
1141
- return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, children: /* @__PURE__ */ jsxRuntime.jsx(
1142
- x.Bubble,
1143
- {
1144
- placement,
1145
- className: classNames9__default.default({ [styles_module_default3.loadingMessage]: message3.type && message3.type !== "TEXT_MESSAGE_END" }),
1146
- content: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1147
- thinkContents.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
1148
- antd.Collapse,
1149
- {
1150
- ghost: true,
1151
- size: "small",
1152
- className: styles_module_default3.think,
1153
- defaultActiveKey: thinkContents.map((_, i) => `think-${i}`),
1154
- items: thinkContents.map((content, index) => renderMarkdownPanel(content, `\u601D\u8003\u8FC7\u7A0B`, `think-${index}`))
1155
- }
1156
- ),
1157
- thinkBuffer && /* @__PURE__ */ jsxRuntime.jsx(
1158
- antd.Collapse,
1159
- {
1160
- ghost: true,
1161
- size: "small",
1162
- className: styles_module_default3.think,
1163
- defaultActiveKey: ["buffer-think"],
1164
- items: [renderMarkdownPanel(thinkBuffer, "\u4ED4\u7EC6\u601D\u8003\u4E2D...", "buffer-think")]
1165
- }
1166
- ),
1167
- /* @__PURE__ */ jsxRuntime.jsx(common.RenderMarkdown, { content: mainContent, customComponents })
1168
- ] })
1169
- }
1170
- ) });
1144
+ nsAvatarListItemName: "styles_module_nsAvatarListItemName"
1171
1145
  };
1172
1146
  var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, agent: true, other: true } }) => {
1173
1147
  const chatStore = useChatStore();
@@ -1217,7 +1191,7 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
1217
1191
  /* @__PURE__ */ jsxRuntime.jsx(
1218
1192
  x.Welcome,
1219
1193
  {
1220
- className: classNames9__default.default(styles_module_default3.chatWelcome, "p-t-32"),
1194
+ className: classNames8__default.default(styles_module_default3.chatWelcome, "p-t-32"),
1221
1195
  variant: "borderless",
1222
1196
  icon: /* @__PURE__ */ jsxRuntime.jsx(antd.Avatar, { shape: "square", size: 58, src: receiverState.active.logo }),
1223
1197
  title: `\u4F60\u597D\uFF0C\u6211\u662F${receiverState.active.name || ""}`,
@@ -1235,7 +1209,7 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
1235
1209
  label: "\u{1F914} \u63A8\u8350\u95EE\u9898:",
1236
1210
  children: receiverState.active.config.recommendQuestions.map(({ question }) => ({
1237
1211
  key: question,
1238
- description: /* @__PURE__ */ jsxRuntime.jsx("span", { onClick: () => chatStore.sendMessage(question), className: classNames9__default.default(styles_module_default3.chatWelcomePrompts, "text-ellipsis"), children: question })
1212
+ description: /* @__PURE__ */ jsxRuntime.jsx("span", { onClick: () => chatStore.sendMessage(question), className: classNames8__default.default(styles_module_default3.chatWelcomePrompts, "text-ellipsis"), children: question })
1239
1213
  }))
1240
1214
  }
1241
1215
  ]
@@ -1274,37 +1248,36 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
1274
1248
  [chatMessage?.questionList]
1275
1249
  );
1276
1250
  const chatRecords = react.useMemo(() => {
1277
- return (chatMessage?.message || []).map((message3, index) => {
1278
- const role = conversationRoles[MEMBER_TYPE[message3.sender.type]] || {};
1251
+ return (chatMessage?.message || []).map((message2, index) => {
1252
+ const role = conversationRoles[MEMBER_TYPE[message2.sender.type]] || {};
1279
1253
  return {
1280
- key: message3.id,
1254
+ key: message2.id,
1281
1255
  placement: role.placement,
1282
1256
  variant: "borderless",
1283
1257
  avatar: role.avatar,
1284
- // content: <MessageRender message={message as ConversationMessage} placement={role.placement} />,
1285
- content: role.user === "agent" ? /* @__PURE__ */ jsxRuntime.jsx(MessageAIRender_default, { message: message3, placement: role.placement }) : /* @__PURE__ */ jsxRuntime.jsx(MessageRender_default, { message: message3, placement: role.placement }),
1258
+ content: /* @__PURE__ */ jsxRuntime.jsx(MessageRender_default, { message: message2, placement: role.placement }),
1286
1259
  footer: role.user === "agent" && /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
1287
- /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: () => copy(message3.msgContent), color: "default", variant: "text", size: "small", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CopyOutlined, {}) }),
1260
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: () => common.copyText(message2.msgContent), color: "default", variant: "text", size: "small", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CopyOutlined, {}) }),
1288
1261
  /* @__PURE__ */ jsxRuntime.jsx(
1289
1262
  antd.Button,
1290
1263
  {
1291
- color: message3.msgFeedback === 1 ? "primary" : "default",
1292
- disabled: !!message3.type,
1264
+ color: message2.msgFeedback === 1 ? "primary" : "default",
1265
+ disabled: !!message2.type,
1293
1266
  size: "small",
1294
1267
  variant: "text",
1295
1268
  icon: /* @__PURE__ */ jsxRuntime.jsx(icons.LikeOutlined, {}),
1296
- onClick: () => chatStore.feedback(conversationState.active.id, message3.id, 1, index)
1269
+ onClick: () => chatStore.feedback(conversationState.active.id, message2.id, 1, index)
1297
1270
  }
1298
1271
  ),
1299
1272
  /* @__PURE__ */ jsxRuntime.jsx(
1300
1273
  antd.Button,
1301
1274
  {
1302
- color: message3.msgFeedback === 2 ? "primary" : "default",
1303
- disabled: !!message3.type,
1275
+ color: message2.msgFeedback === 2 ? "primary" : "default",
1276
+ disabled: !!message2.type,
1304
1277
  size: "small",
1305
1278
  variant: "text",
1306
1279
  icon: /* @__PURE__ */ jsxRuntime.jsx(icons.DislikeOutlined, {}),
1307
- onClick: () => chatStore.feedback(conversationState.active.id, message3.id, 2, index)
1280
+ onClick: () => chatStore.feedback(conversationState.active.id, message2.id, 2, index)
1308
1281
  }
1309
1282
  )
1310
1283
  ] })
@@ -1343,7 +1316,7 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
1343
1316
  const handleScroll = (el) => {
1344
1317
  const target = el.target;
1345
1318
  const distanceToBottom = target.scrollHeight - target.scrollTop - target.clientHeight;
1346
- autoScrollRef.current = distanceToBottom < 100;
1319
+ autoScrollRef.current = distanceToBottom < 150;
1347
1320
  };
1348
1321
  react.useEffect(() => {
1349
1322
  autoScrollRef.current = true;
@@ -1368,7 +1341,7 @@ var BubbleListItems_default = ({ firstMessage = false, avatar = { user: false, a
1368
1341
  autoScroll: false,
1369
1342
  ref: listRef,
1370
1343
  items: bubbleListItems,
1371
- className: classNames9__default.default(styles_module_default3.nsBubbleList, "height-full", "scroll-fade-in", "zero-chat-bubbles"),
1344
+ className: classNames8__default.default(styles_module_default3.nsBubbleList, "height-full", "scroll-fade-in", "zero-chat-bubbles"),
1372
1345
  onScroll: handleScroll
1373
1346
  },
1374
1347
  conversationState.active.id
@@ -1403,7 +1376,7 @@ var CharacterList_default = () => {
1403
1376
  /* @__PURE__ */ jsxRuntime.jsx(
1404
1377
  antd.Avatar,
1405
1378
  {
1406
- className: classNames9__default.default(styles_module_default3.nsAvatarListItemIcon, "cursor-pointer", {
1379
+ className: classNames8__default.default(styles_module_default3.nsAvatarListItemIcon, "cursor-pointer", {
1407
1380
  [styles_module_default3.nsAvatarListItemIconActive]: activeCharacter.id === item.id
1408
1381
  }),
1409
1382
  size: 50,
@@ -1498,7 +1471,7 @@ var ChatHeader_default = ({
1498
1471
  const chatStore = useChatStore();
1499
1472
  const receiverState = valtio.useSnapshot(chatStore.receiver);
1500
1473
  const configState = valtio.useSnapshot(chatStore.config);
1501
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "space-between", align: "center", className: classNames9__default.default(styles_module_default3.nsChatHeader, "zero-chat-header"), children: [
1474
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "space-between", align: "center", className: classNames8__default.default(styles_module_default3.nsChatHeader, "zero-chat-header"), children: [
1502
1475
  /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 4, align: "center", children: [
1503
1476
  /* @__PURE__ */ jsxRuntime.jsx(
1504
1477
  common.RenderWrapper,
@@ -1549,7 +1522,7 @@ var ChatHeader_default = ({
1549
1522
  ] }) });
1550
1523
  };
1551
1524
  var Attachments_default = react.forwardRef(({ fileUpload, fileUploadConfig = [], fileList = [], onChange, extraParams }, ref) => {
1552
- const { message: message3 } = antd.App.useApp();
1525
+ const { message: message2 } = antd.App.useApp();
1553
1526
  const fileListRef = react.useRef([]);
1554
1527
  const [attachedFiles, setAttachedFiles, getAttachedFiles] = common.useRefState([]);
1555
1528
  react.useEffect(() => {
@@ -1577,7 +1550,7 @@ var Attachments_default = react.forwardRef(({ fileUpload, fileUploadConfig = [],
1577
1550
  onChange(files);
1578
1551
  }, [attachedFiles]);
1579
1552
  const onErrorTip = common.useDebounce((errorMsg) => {
1580
- message3.error(errorMsg);
1553
+ message2.error(errorMsg);
1581
1554
  }, 300);
1582
1555
  const findConfigByFile = (file) => {
1583
1556
  return fileUploadConfig.find((cfg) => cfg.allowedFileTypes?.includes(common.getFileSuffixName(file.name).toLocaleUpperCase()));
@@ -1808,7 +1781,7 @@ var SenderPromptsItems_default = () => {
1808
1781
  title: /* @__PURE__ */ jsxRuntime.jsx(
1809
1782
  "div",
1810
1783
  {
1811
- className: classNames9__default.default(styles_module_default3.nsSenderListTitle, "text-ellipsis"),
1784
+ className: classNames8__default.default(styles_module_default3.nsSenderListTitle, "text-ellipsis"),
1812
1785
  children: `${receiverState.active.name}\u5F00\u59CB\u5173\u6CE8${question.name}\u5185\u5BB9\uFF01`
1813
1786
  }
1814
1787
  ),
@@ -1937,7 +1910,7 @@ var ConversationListHeader_default = () => {
1937
1910
  type: "primary",
1938
1911
  shape: "round",
1939
1912
  onClick: () => chatStore.createConversation(),
1940
- className: classNames9__default.default("m-t-16"),
1913
+ className: classNames8__default.default("m-t-16"),
1941
1914
  icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlusOutlined, {}),
1942
1915
  children: "\u65B0\u5EFA\u4F1A\u8BDD"
1943
1916
  }
@@ -1945,7 +1918,7 @@ var ConversationListHeader_default = () => {
1945
1918
  ] });
1946
1919
  };
1947
1920
  var ConversationListPanel_default = ({ header }) => {
1948
- return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames9__default.default("height-full", "zero-chat-conversations", styles_module_default3.nsConversationListPanel), children: [
1921
+ return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames8__default.default("height-full", "zero-chat-conversations", styles_module_default3.nsConversationListPanel), children: [
1949
1922
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: header, DefaultComponent: ConversationListHeader_default }),
1950
1923
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsxRuntime.jsx(ConversationList_default, {}) })
1951
1924
  ] });
@@ -2043,7 +2016,7 @@ var layouts_default = react.forwardRef(({ theme, params, userInfo, hooks, layout
2043
2016
  react.useEffect(() => {
2044
2017
  configState.hooks?.onBeforeInit?.();
2045
2018
  }, []);
2046
- return /* @__PURE__ */ jsxRuntime.jsx(x.XProvider, { theme: { cssVar: true, ...theme }, children: /* @__PURE__ */ jsxRuntime.jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: receiverState.loading, wrapperClassName: "full-spin", children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames9__default.default(styles_module_default4.nsChatLayout, "zero-chat-layout", "height-full"), children: [
2019
+ return /* @__PURE__ */ jsxRuntime.jsx(x.XProvider, { theme: { cssVar: true, ...theme }, children: /* @__PURE__ */ jsxRuntime.jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: receiverState.loading, wrapperClassName: "full-spin", children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames8__default.default(styles_module_default4.nsChatLayout, "zero-chat-layout", "height-full"), children: [
2047
2020
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.globalHeader, DefaultComponent: ChatHeader_default }),
2048
2021
  /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { className: "full-scroll", children: [
2049
2022
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.leftPanel }),
@@ -2097,15 +2070,15 @@ var layouts_default = react.forwardRef(({ theme, params, userInfo, hooks, layout
2097
2070
  }
2098
2071
  )
2099
2072
  ] }) }),
2100
- /* @__PURE__ */ jsxRuntime.jsx(antd.Splitter.Panel, { collapsible: false, max: 800, min: 400, size: sizes[1], children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames9__default.default("height-full"), children: [
2073
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Splitter.Panel, { collapsible: false, max: 800, min: 400, size: sizes[1], children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: classNames8__default.default("height-full"), children: [
2101
2074
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.chatHeader, DefaultComponent: ChatHeader_default }),
2102
- /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, className: classNames9__default.default("full-scroll"), children: /* @__PURE__ */ jsxRuntime.jsxs(
2075
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, className: classNames8__default.default("full-scroll"), children: /* @__PURE__ */ jsxRuntime.jsxs(
2103
2076
  antd.Flex,
2104
2077
  {
2105
2078
  justify: "center",
2106
2079
  vertical: true,
2107
2080
  gap: 24,
2108
- className: classNames9__default.default("height-full", styles_module_default4.nsChatBody, "zero-chat-body", styles_module_default4.nsBodyWidth),
2081
+ className: classNames8__default.default("height-full", styles_module_default4.nsChatBody, "zero-chat-body", styles_module_default4.nsBodyWidth),
2109
2082
  children: [
2110
2083
  common.shouldRender(configState.layout.messageList) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: configState.layout.messageList, DefaultComponent: BubbleListItems_default }) }),
2111
2084
  /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, gap: 8, children: [