@zero-library/chat-copilot 1.0.16 → 1.0.18

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
@@ -3,12 +3,12 @@
3
3
  var icons = require('@ant-design/icons');
4
4
  var xV2 = require('@ant-design/x-v2');
5
5
  var common = require('@zero-library/common');
6
+ var dayjs = require('dayjs');
6
7
  var antd = require('antd');
7
8
  var React6 = require('react');
8
9
  var valtio = require('valtio');
9
10
  var jsxRuntime = require('react/jsx-runtime');
10
11
  var classNames2 = require('classnames');
11
- var dayjs = require('dayjs');
12
12
  var InfiniteScroll = require('react-infinite-scroll-component');
13
13
  var xCard = require('@ant-design/x-card');
14
14
  require('@ant-design/x-markdown/themes/light.css');
@@ -17,14 +17,39 @@ var Latex = require('@ant-design/x-markdown/plugins/Latex');
17
17
 
18
18
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
19
19
 
20
+ var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
20
21
  var React6__default = /*#__PURE__*/_interopDefault(React6);
21
22
  var classNames2__default = /*#__PURE__*/_interopDefault(classNames2);
22
- var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
23
23
  var InfiniteScroll__default = /*#__PURE__*/_interopDefault(InfiniteScroll);
24
24
  var XMarkdown__default = /*#__PURE__*/_interopDefault(XMarkdown);
25
25
  var Latex__default = /*#__PURE__*/_interopDefault(Latex);
26
26
 
27
27
  // src/components/Attachments.tsx
28
+ var classifyTime = (timestamp) => {
29
+ const now = dayjs__default.default();
30
+ const target = dayjs__default.default(timestamp);
31
+ if (target.isSame(now, "day")) {
32
+ return "\u4ECA\u5929";
33
+ }
34
+ const diffInDays = now.diff(target, "day");
35
+ if (diffInDays < 7) {
36
+ return "\u6700\u8FD1 7 \u5929";
37
+ } else if (diffInDays < 30) {
38
+ return "\u6700\u8FD1 30 \u5929";
39
+ } else if (diffInDays < 180) {
40
+ return "\u6700\u8FD1\u534A\u5E74";
41
+ } else {
42
+ return "\u66F4\u65E9";
43
+ }
44
+ };
45
+ var getChatSocketUrl = (baseURL, params) => {
46
+ return common.buildUrlParams(params, common.getWebSocketUrl(`${baseURL}/ws`), "comma");
47
+ };
48
+ var isDocument = (fileName) => {
49
+ if (!fileName) return false;
50
+ const ext = common.getFileSuffixName(fileName);
51
+ return ["pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "csv"].includes(ext);
52
+ };
28
53
  var ChatContext = React6.createContext(null);
29
54
  function ChatProvider({ store, children }) {
30
55
  return React6__default.default.createElement(ChatContext.Provider, { value: store }, children);
@@ -133,7 +158,7 @@ var Attachments_default = React6.forwardRef(({ fileUpload, fileUploadConfig, fil
133
158
  const uploadedFile = data[0];
134
159
  let previewUrl = uploadedFile.id;
135
160
  if (uploadedFile.conversationId && uploadedFile.path) {
136
- if (common.isDocument(uploadedFile.name)) {
161
+ if (isDocument(uploadedFile.name)) {
137
162
  previewUrl = chatStore.config.services.request.getPreviewUrl(
138
163
  agentState.agentInfo.id,
139
164
  uploadedFile.conversationId,
@@ -331,26 +356,6 @@ var ChatSender_default = React6.forwardRef(
331
356
  );
332
357
  }
333
358
  );
334
- var classifyTime = (timestamp) => {
335
- const now = dayjs__default.default();
336
- const target = dayjs__default.default(timestamp);
337
- if (target.isSame(now, "day")) {
338
- return "\u4ECA\u5929";
339
- }
340
- const diffInDays = now.diff(target, "day");
341
- if (diffInDays < 7) {
342
- return "\u6700\u8FD1 7 \u5929";
343
- } else if (diffInDays < 30) {
344
- return "\u6700\u8FD1 30 \u5929";
345
- } else if (diffInDays < 180) {
346
- return "\u6700\u8FD1\u534A\u5E74";
347
- } else {
348
- return "\u66F4\u65E9";
349
- }
350
- };
351
- var getChatSocketUrl = (baseURL, params) => {
352
- return common.buildUrlParams(params, common.getWebSocketUrl(`${baseURL}/ws`), "comma");
353
- };
354
359
 
355
360
  // src/core/constants.ts
356
361
  var CONV_MODE = {
@@ -459,13 +464,6 @@ var defaultLayout = {
459
464
  chatHeader: true,
460
465
  messageList: true,
461
466
  senderHeader: false,
462
- sender: {
463
- props: {
464
- modelSelect: true,
465
- skillsBtn: true,
466
- reasoningBtn: true
467
- }
468
- },
469
467
  senderFooter: false,
470
468
  disclaimerNotice: true
471
469
  };
@@ -680,15 +678,6 @@ function createChatStore() {
680
678
  await setPreview();
681
679
  config.hooks?.onAfterSwitchConversation?.(conversationId);
682
680
  };
683
- const setConversationSpec = (spec) => {
684
- if (common.isObject(spec)) {
685
- conversation.active.spec = spec;
686
- const currentConversation = conversations.list.items.find((item) => item.id === conversation.active.id);
687
- if (currentConversation) {
688
- currentConversation.spec = spec;
689
- }
690
- }
691
- };
692
681
  const updateConversations = (data) => {
693
682
  const item = common.transform(data, {
694
683
  key: "id",
@@ -751,6 +740,11 @@ function createChatStore() {
751
740
  const setHeaderOpen = (headerOpen) => {
752
741
  conversation.messages[conversation.active.id].headerOpen = headerOpen;
753
742
  };
743
+ const setConversationSpec = (spec) => {
744
+ if (common.isObject(spec)) {
745
+ Object.assign(conversation.active.spec, spec);
746
+ }
747
+ };
754
748
  const feedback = async (executionId, feedback2, index) => {
755
749
  try {
756
750
  conversation.feedback.loading = true;
@@ -1375,9 +1369,12 @@ var CreateBtn_default = ({ icon, ...rest }) => {
1375
1369
  // src/ui/common/styles.module.less
1376
1370
  var styles_module_default2 = {
1377
1371
  chatHeader: "styles_module_chatHeader",
1372
+ chatHeaderContent: "styles_module_chatHeaderContent",
1378
1373
  chatTitle: "styles_module_chatTitle",
1374
+ chatHeaderBtnGroup: "styles_module_chatHeaderBtnGroup",
1379
1375
  popover: "styles_module_popover",
1380
1376
  conversationListPanel: "styles_module_conversationListPanel",
1377
+ conversationAvatar: "styles_module_conversationAvatar",
1381
1378
  createConversationButton: "styles_module_createConversationButton",
1382
1379
  conversations: "styles_module_conversations",
1383
1380
  chatWelcomeWrap: "styles_module_chatWelcomeWrap",
@@ -1491,8 +1488,8 @@ var ChatHeader_default = ({ title = true, avatar = true, closeBtn = false, newCo
1491
1488
  const chatStore = useChatStore();
1492
1489
  const agentState = valtio.useSnapshot(chatStore.agent);
1493
1490
  const configState = valtio.useSnapshot(chatStore.config);
1494
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "space-between", align: "center", className: classNames2__default.default(styles_module_default2.chatHeader, "zero-chat-header"), children: [
1495
- /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 4, align: "center", children: [
1491
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames2__default.default(styles_module_default2.chatHeader, "zero-chat-header"), children: [
1492
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default2.chatHeaderContent, children: [
1496
1493
  /* @__PURE__ */ jsxRuntime.jsx(
1497
1494
  common.RenderWrapper,
1498
1495
  {
@@ -1511,7 +1508,7 @@ var ChatHeader_default = ({ title = true, avatar = true, closeBtn = false, newCo
1511
1508
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: title, DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.chatTitle, children: agentState.agentInfo.name }) })
1512
1509
  ] }),
1513
1510
  /* @__PURE__ */ jsxRuntime.jsxs(antd.Space, { size: 2, children: [
1514
- /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 8, children: [
1511
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default2.chatHeaderBtnGroup, children: [
1515
1512
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: newConversationBtn, DefaultComponent: CreateBtn_default }),
1516
1513
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: conversationListBtn, DefaultComponent: HistoryBtn_default })
1517
1514
  ] }),
@@ -1535,7 +1532,15 @@ var ConversationListHeader_default = ({ title = true, avatar = true, newConversa
1535
1532
  common.RenderWrapper,
1536
1533
  {
1537
1534
  control: avatar,
1538
- DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx(antd.Avatar, { size: 50, src: agentState.agentInfo?.iconUrl || /* @__PURE__ */ jsxRuntime.jsx(IconFont_default, { type: "icon-lolrai" }), shape: "square", style: { flexShrink: 0 }, children: (agentState.agentInfo?.name || "AI").slice(0, 1) })
1535
+ DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx(
1536
+ antd.Avatar,
1537
+ {
1538
+ size: 50,
1539
+ src: agentState.agentInfo?.iconUrl || /* @__PURE__ */ jsxRuntime.jsx(IconFont_default, { type: "icon-lolrai", className: styles_module_default2.conversationAvatar }),
1540
+ shape: "square",
1541
+ style: { flexShrink: 0 }
1542
+ }
1543
+ )
1539
1544
  }
1540
1545
  ),
1541
1546
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -3981,7 +3986,7 @@ var FilesNode = React6__default.default.memo(({ item }) => {
3981
3986
  const fileItems = React6.useMemo(() => {
3982
3987
  return (item.files || []).map((file) => {
3983
3988
  let previewUrl = file.id;
3984
- if (common.isDocument(file.name)) {
3989
+ if (isDocument(file.name)) {
3985
3990
  previewUrl = configState.services.request.getPreviewUrl(agentState.agentInfo.id, conversationState.active.id, file.path, "preview");
3986
3991
  } else {
3987
3992
  previewUrl = configState.services.request.getPreviewUrl(agentState.agentInfo.id, conversationState.active.id, file.path, "download");
@@ -4687,7 +4692,7 @@ var ReasonBtn_default = ({}) => {
4687
4692
  const chatStore = useChatStore();
4688
4693
  const agentState = valtio.useSnapshot(chatStore.agent);
4689
4694
  return /* @__PURE__ */ jsxRuntime.jsxs(
4690
- antd.Flex,
4695
+ "div",
4691
4696
  {
4692
4697
  className: classNames2__default.default(styles_module_default2.resourceBtn, { [styles_module_default2.resourceBtnActive]: agentState.model.reasoning }),
4693
4698
  onClick: () => chatStore.setAgentModel({ ...agentState.model, reasoning: !agentState.model.reasoning }),
@@ -4705,7 +4710,7 @@ var SkillBtn_default = ({}) => {
4705
4710
  const [modalOpen, setModalOpen] = React6.useState(false);
4706
4711
  const skillsCount = conversationState.active.spec?.skills?.items?.length ?? 0;
4707
4712
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4708
- /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { className: styles_module_default2.resourceBtn, onClick: () => setModalOpen(true), children: [
4713
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default2.resourceBtn, onClick: () => setModalOpen(true), children: [
4709
4714
  /* @__PURE__ */ jsxRuntime.jsx(IconFont_default, { type: "icon-skill" }),
4710
4715
  /* @__PURE__ */ jsxRuntime.jsx(Text7, { children: "\u6280\u80FD" }),
4711
4716
  skillsCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -4724,9 +4729,9 @@ var ChatSender_default2 = React6.forwardRef(
4724
4729
  sendBtnProps,
4725
4730
  footerBelow = false,
4726
4731
  reasonBtn = true,
4727
- skillsBtn = true,
4728
- knowledgeBtn = true,
4729
- modelSelect = true
4732
+ skillsBtn = false,
4733
+ knowledgeBtn = false,
4734
+ modelSelect = false
4730
4735
  }, ref) => {
4731
4736
  const chatStore = useChatStore();
4732
4737
  const configState = valtio.useSnapshot(chatStore.config);
@@ -4808,7 +4813,7 @@ var ChatSender_default2 = React6.forwardRef(
4808
4813
  }
4809
4814
  );
4810
4815
  var ChatSenderHeader = () => {
4811
- return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: styles_module_default2.logoArea, children: [
4816
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default2.logoArea, children: [
4812
4817
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default2.logoContainer, children: [
4813
4818
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.staticHalo }),
4814
4819
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.logoHoverWrapper, children: /* @__PURE__ */ jsxRuntime.jsx(IconFont_default, { type: "icon-lolrai", className: styles_module_default2.logoImage }) })
@@ -4923,6 +4928,7 @@ var layouts_default = React6.forwardRef(({ theme: theme4, params, hooks, layout,
4923
4928
  _ref,
4924
4929
  () => ({
4925
4930
  sendMessage: chatStore.sendMessage,
4931
+ setConversationSpec: chatStore.setConversationSpec,
4926
4932
  switchConversation: chatStore.switchConversation,
4927
4933
  createConversation: chatStore.createConversation,
4928
4934
  setReferences: chatStore.setReferences,