@zero-library/chat-copilot 1.0.16 → 1.0.17

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 = {
@@ -680,15 +685,6 @@ function createChatStore() {
680
685
  await setPreview();
681
686
  config.hooks?.onAfterSwitchConversation?.(conversationId);
682
687
  };
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
688
  const updateConversations = (data) => {
693
689
  const item = common.transform(data, {
694
690
  key: "id",
@@ -751,6 +747,11 @@ function createChatStore() {
751
747
  const setHeaderOpen = (headerOpen) => {
752
748
  conversation.messages[conversation.active.id].headerOpen = headerOpen;
753
749
  };
750
+ const setConversationSpec = (spec) => {
751
+ if (common.isObject(spec)) {
752
+ Object.assign(conversation.active.spec, spec);
753
+ }
754
+ };
754
755
  const feedback = async (executionId, feedback2, index) => {
755
756
  try {
756
757
  conversation.feedback.loading = true;
@@ -1375,9 +1376,12 @@ var CreateBtn_default = ({ icon, ...rest }) => {
1375
1376
  // src/ui/common/styles.module.less
1376
1377
  var styles_module_default2 = {
1377
1378
  chatHeader: "styles_module_chatHeader",
1379
+ chatHeaderContent: "styles_module_chatHeaderContent",
1378
1380
  chatTitle: "styles_module_chatTitle",
1381
+ chatHeaderBtnGroup: "styles_module_chatHeaderBtnGroup",
1379
1382
  popover: "styles_module_popover",
1380
1383
  conversationListPanel: "styles_module_conversationListPanel",
1384
+ conversationAvatar: "styles_module_conversationAvatar",
1381
1385
  createConversationButton: "styles_module_createConversationButton",
1382
1386
  conversations: "styles_module_conversations",
1383
1387
  chatWelcomeWrap: "styles_module_chatWelcomeWrap",
@@ -1491,8 +1495,8 @@ var ChatHeader_default = ({ title = true, avatar = true, closeBtn = false, newCo
1491
1495
  const chatStore = useChatStore();
1492
1496
  const agentState = valtio.useSnapshot(chatStore.agent);
1493
1497
  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: [
1498
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames2__default.default(styles_module_default2.chatHeader, "zero-chat-header"), children: [
1499
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default2.chatHeaderContent, children: [
1496
1500
  /* @__PURE__ */ jsxRuntime.jsx(
1497
1501
  common.RenderWrapper,
1498
1502
  {
@@ -1511,7 +1515,7 @@ var ChatHeader_default = ({ title = true, avatar = true, closeBtn = false, newCo
1511
1515
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: title, DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.chatTitle, children: agentState.agentInfo.name }) })
1512
1516
  ] }),
1513
1517
  /* @__PURE__ */ jsxRuntime.jsxs(antd.Space, { size: 2, children: [
1514
- /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 8, children: [
1518
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default2.chatHeaderBtnGroup, children: [
1515
1519
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: newConversationBtn, DefaultComponent: CreateBtn_default }),
1516
1520
  /* @__PURE__ */ jsxRuntime.jsx(common.RenderWrapper, { control: conversationListBtn, DefaultComponent: HistoryBtn_default })
1517
1521
  ] }),
@@ -1535,7 +1539,15 @@ var ConversationListHeader_default = ({ title = true, avatar = true, newConversa
1535
1539
  common.RenderWrapper,
1536
1540
  {
1537
1541
  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) })
1542
+ DefaultComponent: /* @__PURE__ */ jsxRuntime.jsx(
1543
+ antd.Avatar,
1544
+ {
1545
+ size: 50,
1546
+ src: agentState.agentInfo?.iconUrl || /* @__PURE__ */ jsxRuntime.jsx(IconFont_default, { type: "icon-lolrai", className: styles_module_default2.conversationAvatar }),
1547
+ shape: "square",
1548
+ style: { flexShrink: 0 }
1549
+ }
1550
+ )
1539
1551
  }
1540
1552
  ),
1541
1553
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -3981,7 +3993,7 @@ var FilesNode = React6__default.default.memo(({ item }) => {
3981
3993
  const fileItems = React6.useMemo(() => {
3982
3994
  return (item.files || []).map((file) => {
3983
3995
  let previewUrl = file.id;
3984
- if (common.isDocument(file.name)) {
3996
+ if (isDocument(file.name)) {
3985
3997
  previewUrl = configState.services.request.getPreviewUrl(agentState.agentInfo.id, conversationState.active.id, file.path, "preview");
3986
3998
  } else {
3987
3999
  previewUrl = configState.services.request.getPreviewUrl(agentState.agentInfo.id, conversationState.active.id, file.path, "download");
@@ -4687,7 +4699,7 @@ var ReasonBtn_default = ({}) => {
4687
4699
  const chatStore = useChatStore();
4688
4700
  const agentState = valtio.useSnapshot(chatStore.agent);
4689
4701
  return /* @__PURE__ */ jsxRuntime.jsxs(
4690
- antd.Flex,
4702
+ "div",
4691
4703
  {
4692
4704
  className: classNames2__default.default(styles_module_default2.resourceBtn, { [styles_module_default2.resourceBtnActive]: agentState.model.reasoning }),
4693
4705
  onClick: () => chatStore.setAgentModel({ ...agentState.model, reasoning: !agentState.model.reasoning }),
@@ -4705,7 +4717,7 @@ var SkillBtn_default = ({}) => {
4705
4717
  const [modalOpen, setModalOpen] = React6.useState(false);
4706
4718
  const skillsCount = conversationState.active.spec?.skills?.items?.length ?? 0;
4707
4719
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4708
- /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { className: styles_module_default2.resourceBtn, onClick: () => setModalOpen(true), children: [
4720
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default2.resourceBtn, onClick: () => setModalOpen(true), children: [
4709
4721
  /* @__PURE__ */ jsxRuntime.jsx(IconFont_default, { type: "icon-skill" }),
4710
4722
  /* @__PURE__ */ jsxRuntime.jsx(Text7, { children: "\u6280\u80FD" }),
4711
4723
  skillsCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -4724,8 +4736,8 @@ var ChatSender_default2 = React6.forwardRef(
4724
4736
  sendBtnProps,
4725
4737
  footerBelow = false,
4726
4738
  reasonBtn = true,
4727
- skillsBtn = true,
4728
- knowledgeBtn = true,
4739
+ skillsBtn = false,
4740
+ knowledgeBtn = false,
4729
4741
  modelSelect = true
4730
4742
  }, ref) => {
4731
4743
  const chatStore = useChatStore();
@@ -4808,7 +4820,7 @@ var ChatSender_default2 = React6.forwardRef(
4808
4820
  }
4809
4821
  );
4810
4822
  var ChatSenderHeader = () => {
4811
- return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { vertical: true, className: styles_module_default2.logoArea, children: [
4823
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default2.logoArea, children: [
4812
4824
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default2.logoContainer, children: [
4813
4825
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default2.staticHalo }),
4814
4826
  /* @__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 +4935,7 @@ var layouts_default = React6.forwardRef(({ theme: theme4, params, hooks, layout,
4923
4935
  _ref,
4924
4936
  () => ({
4925
4937
  sendMessage: chatStore.sendMessage,
4938
+ setConversationSpec: chatStore.setConversationSpec,
4926
4939
  switchConversation: chatStore.switchConversation,
4927
4940
  createConversation: chatStore.createConversation,
4928
4941
  setReferences: chatStore.setReferences,