@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 +56 -50
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +23 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +58 -32
- package/dist/index.d.ts +58 -32
- package/dist/index.esm.js +54 -48
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CloudUploadOutlined, PaperClipOutlined, createFromIconfontCN, LoadingOutlined, EnterOutlined, DownloadOutlined, CloseOutlined, FileTextOutlined, CopyOutlined, LikeOutlined, DislikeOutlined, ToolOutlined, PlayCircleOutlined, DotChartOutlined, SearchOutlined, UpOutlined, DownOutlined, PlusOutlined, CommentOutlined, RedoOutlined, DeleteOutlined, ClockCircleOutlined, CheckCircleOutlined } from '@ant-design/icons';
|
|
2
2
|
import { Attachments, Sender, Think, FileCard, Bubble, XProvider, Mermaid, CodeHighlighter, Welcome, Prompts, Conversations } from '@ant-design/x-v2';
|
|
3
|
-
import { useRefState, useDebounce, useSyncInput, createTokenManager,
|
|
3
|
+
import { useRefState, useDebounce, useSyncInput, createTokenManager, isEmptyObj, markdownToText, RenderWrapper, shouldRender, isFunction, downloadFile, LuyaFilePreview, MarkdownEditor, useDeepEffect, isObject, useWebSocket, isNullOrUnDef, isNumber, getFileSuffixName, isBoolean, UserAvatar, htmlToMarkdown, copyText, FileIcon, LazyComponent, deepCopy, transforms, deepMerge, buildUrlParams, createRequest, HttpStatus, isArray, isString, isExternal, transform, emit, getWebSocketUrl, safeParseJson } from '@zero-library/common';
|
|
4
|
+
import dayjs from 'dayjs';
|
|
4
5
|
import { App, Badge, Button, Flex, Typography, Tooltip, Layout, Tag, Spin, Splitter, theme, Collapse, Divider as Divider$1, Select as Select$1, Avatar, Space, Popover, Skeleton, Alert, Modal, Checkbox, Input, Empty, message, List, Drawer, Card, Table, Progress as Progress$1, Switch as Switch$1 } from 'antd';
|
|
5
6
|
import React6, { createContext, forwardRef, useRef, useEffect, useImperativeHandle, useMemo, memo, useState, useContext, useCallback } from 'react';
|
|
6
7
|
import { useSnapshot, proxy } from 'valtio';
|
|
7
8
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
9
|
import classNames2 from 'classnames';
|
|
9
|
-
import dayjs from 'dayjs';
|
|
10
10
|
import InfiniteScroll from 'react-infinite-scroll-component';
|
|
11
11
|
import { XCard as XCard$1 } from '@ant-design/x-card';
|
|
12
12
|
import '@ant-design/x-markdown/themes/light.css';
|
|
@@ -14,6 +14,31 @@ import XMarkdown from '@ant-design/x-markdown';
|
|
|
14
14
|
import Latex from '@ant-design/x-markdown/plugins/Latex';
|
|
15
15
|
|
|
16
16
|
// src/components/Attachments.tsx
|
|
17
|
+
var classifyTime = (timestamp) => {
|
|
18
|
+
const now = dayjs();
|
|
19
|
+
const target = dayjs(timestamp);
|
|
20
|
+
if (target.isSame(now, "day")) {
|
|
21
|
+
return "\u4ECA\u5929";
|
|
22
|
+
}
|
|
23
|
+
const diffInDays = now.diff(target, "day");
|
|
24
|
+
if (diffInDays < 7) {
|
|
25
|
+
return "\u6700\u8FD1 7 \u5929";
|
|
26
|
+
} else if (diffInDays < 30) {
|
|
27
|
+
return "\u6700\u8FD1 30 \u5929";
|
|
28
|
+
} else if (diffInDays < 180) {
|
|
29
|
+
return "\u6700\u8FD1\u534A\u5E74";
|
|
30
|
+
} else {
|
|
31
|
+
return "\u66F4\u65E9";
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var getChatSocketUrl = (baseURL, params) => {
|
|
35
|
+
return buildUrlParams(params, getWebSocketUrl(`${baseURL}/ws`), "comma");
|
|
36
|
+
};
|
|
37
|
+
var isDocument = (fileName) => {
|
|
38
|
+
if (!fileName) return false;
|
|
39
|
+
const ext = getFileSuffixName(fileName);
|
|
40
|
+
return ["pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "csv"].includes(ext);
|
|
41
|
+
};
|
|
17
42
|
var ChatContext = createContext(null);
|
|
18
43
|
function ChatProvider({ store, children }) {
|
|
19
44
|
return React6.createElement(ChatContext.Provider, { value: store }, children);
|
|
@@ -320,26 +345,6 @@ var ChatSender_default = forwardRef(
|
|
|
320
345
|
);
|
|
321
346
|
}
|
|
322
347
|
);
|
|
323
|
-
var classifyTime = (timestamp) => {
|
|
324
|
-
const now = dayjs();
|
|
325
|
-
const target = dayjs(timestamp);
|
|
326
|
-
if (target.isSame(now, "day")) {
|
|
327
|
-
return "\u4ECA\u5929";
|
|
328
|
-
}
|
|
329
|
-
const diffInDays = now.diff(target, "day");
|
|
330
|
-
if (diffInDays < 7) {
|
|
331
|
-
return "\u6700\u8FD1 7 \u5929";
|
|
332
|
-
} else if (diffInDays < 30) {
|
|
333
|
-
return "\u6700\u8FD1 30 \u5929";
|
|
334
|
-
} else if (diffInDays < 180) {
|
|
335
|
-
return "\u6700\u8FD1\u534A\u5E74";
|
|
336
|
-
} else {
|
|
337
|
-
return "\u66F4\u65E9";
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
var getChatSocketUrl = (baseURL, params) => {
|
|
341
|
-
return buildUrlParams(params, getWebSocketUrl(`${baseURL}/ws`), "comma");
|
|
342
|
-
};
|
|
343
348
|
|
|
344
349
|
// src/core/constants.ts
|
|
345
350
|
var CONV_MODE = {
|
|
@@ -448,13 +453,6 @@ var defaultLayout = {
|
|
|
448
453
|
chatHeader: true,
|
|
449
454
|
messageList: true,
|
|
450
455
|
senderHeader: false,
|
|
451
|
-
sender: {
|
|
452
|
-
props: {
|
|
453
|
-
modelSelect: true,
|
|
454
|
-
skillsBtn: true,
|
|
455
|
-
reasoningBtn: true
|
|
456
|
-
}
|
|
457
|
-
},
|
|
458
456
|
senderFooter: false,
|
|
459
457
|
disclaimerNotice: true
|
|
460
458
|
};
|
|
@@ -669,15 +667,6 @@ function createChatStore() {
|
|
|
669
667
|
await setPreview();
|
|
670
668
|
config.hooks?.onAfterSwitchConversation?.(conversationId);
|
|
671
669
|
};
|
|
672
|
-
const setConversationSpec = (spec) => {
|
|
673
|
-
if (isObject(spec)) {
|
|
674
|
-
conversation.active.spec = spec;
|
|
675
|
-
const currentConversation = conversations.list.items.find((item) => item.id === conversation.active.id);
|
|
676
|
-
if (currentConversation) {
|
|
677
|
-
currentConversation.spec = spec;
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
670
|
const updateConversations = (data) => {
|
|
682
671
|
const item = transform(data, {
|
|
683
672
|
key: "id",
|
|
@@ -740,6 +729,11 @@ function createChatStore() {
|
|
|
740
729
|
const setHeaderOpen = (headerOpen) => {
|
|
741
730
|
conversation.messages[conversation.active.id].headerOpen = headerOpen;
|
|
742
731
|
};
|
|
732
|
+
const setConversationSpec = (spec) => {
|
|
733
|
+
if (isObject(spec)) {
|
|
734
|
+
Object.assign(conversation.active.spec, spec);
|
|
735
|
+
}
|
|
736
|
+
};
|
|
743
737
|
const feedback = async (executionId, feedback2, index) => {
|
|
744
738
|
try {
|
|
745
739
|
conversation.feedback.loading = true;
|
|
@@ -1364,9 +1358,12 @@ var CreateBtn_default = ({ icon, ...rest }) => {
|
|
|
1364
1358
|
// src/ui/common/styles.module.less
|
|
1365
1359
|
var styles_module_default2 = {
|
|
1366
1360
|
chatHeader: "styles_module_chatHeader",
|
|
1361
|
+
chatHeaderContent: "styles_module_chatHeaderContent",
|
|
1367
1362
|
chatTitle: "styles_module_chatTitle",
|
|
1363
|
+
chatHeaderBtnGroup: "styles_module_chatHeaderBtnGroup",
|
|
1368
1364
|
popover: "styles_module_popover",
|
|
1369
1365
|
conversationListPanel: "styles_module_conversationListPanel",
|
|
1366
|
+
conversationAvatar: "styles_module_conversationAvatar",
|
|
1370
1367
|
createConversationButton: "styles_module_createConversationButton",
|
|
1371
1368
|
conversations: "styles_module_conversations",
|
|
1372
1369
|
chatWelcomeWrap: "styles_module_chatWelcomeWrap",
|
|
@@ -1480,8 +1477,8 @@ var ChatHeader_default = ({ title = true, avatar = true, closeBtn = false, newCo
|
|
|
1480
1477
|
const chatStore = useChatStore();
|
|
1481
1478
|
const agentState = useSnapshot(chatStore.agent);
|
|
1482
1479
|
const configState = useSnapshot(chatStore.config);
|
|
1483
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
1484
|
-
/* @__PURE__ */ jsxs(
|
|
1480
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: classNames2(styles_module_default2.chatHeader, "zero-chat-header"), children: [
|
|
1481
|
+
/* @__PURE__ */ jsxs("div", { className: styles_module_default2.chatHeaderContent, children: [
|
|
1485
1482
|
/* @__PURE__ */ jsx(
|
|
1486
1483
|
RenderWrapper,
|
|
1487
1484
|
{
|
|
@@ -1500,7 +1497,7 @@ var ChatHeader_default = ({ title = true, avatar = true, closeBtn = false, newCo
|
|
|
1500
1497
|
/* @__PURE__ */ jsx(RenderWrapper, { control: title, DefaultComponent: /* @__PURE__ */ jsx("div", { className: styles_module_default2.chatTitle, children: agentState.agentInfo.name }) })
|
|
1501
1498
|
] }),
|
|
1502
1499
|
/* @__PURE__ */ jsxs(Space, { size: 2, children: [
|
|
1503
|
-
/* @__PURE__ */ jsxs(
|
|
1500
|
+
/* @__PURE__ */ jsxs("div", { className: styles_module_default2.chatHeaderBtnGroup, children: [
|
|
1504
1501
|
/* @__PURE__ */ jsx(RenderWrapper, { control: newConversationBtn, DefaultComponent: CreateBtn_default }),
|
|
1505
1502
|
/* @__PURE__ */ jsx(RenderWrapper, { control: conversationListBtn, DefaultComponent: HistoryBtn_default })
|
|
1506
1503
|
] }),
|
|
@@ -1524,7 +1521,15 @@ var ConversationListHeader_default = ({ title = true, avatar = true, newConversa
|
|
|
1524
1521
|
RenderWrapper,
|
|
1525
1522
|
{
|
|
1526
1523
|
control: avatar,
|
|
1527
|
-
DefaultComponent: /* @__PURE__ */ jsx(
|
|
1524
|
+
DefaultComponent: /* @__PURE__ */ jsx(
|
|
1525
|
+
Avatar,
|
|
1526
|
+
{
|
|
1527
|
+
size: 50,
|
|
1528
|
+
src: agentState.agentInfo?.iconUrl || /* @__PURE__ */ jsx(IconFont_default, { type: "icon-lolrai", className: styles_module_default2.conversationAvatar }),
|
|
1529
|
+
shape: "square",
|
|
1530
|
+
style: { flexShrink: 0 }
|
|
1531
|
+
}
|
|
1532
|
+
)
|
|
1528
1533
|
}
|
|
1529
1534
|
),
|
|
1530
1535
|
/* @__PURE__ */ jsx(
|
|
@@ -4676,7 +4681,7 @@ var ReasonBtn_default = ({}) => {
|
|
|
4676
4681
|
const chatStore = useChatStore();
|
|
4677
4682
|
const agentState = useSnapshot(chatStore.agent);
|
|
4678
4683
|
return /* @__PURE__ */ jsxs(
|
|
4679
|
-
|
|
4684
|
+
"div",
|
|
4680
4685
|
{
|
|
4681
4686
|
className: classNames2(styles_module_default2.resourceBtn, { [styles_module_default2.resourceBtnActive]: agentState.model.reasoning }),
|
|
4682
4687
|
onClick: () => chatStore.setAgentModel({ ...agentState.model, reasoning: !agentState.model.reasoning }),
|
|
@@ -4694,7 +4699,7 @@ var SkillBtn_default = ({}) => {
|
|
|
4694
4699
|
const [modalOpen, setModalOpen] = useState(false);
|
|
4695
4700
|
const skillsCount = conversationState.active.spec?.skills?.items?.length ?? 0;
|
|
4696
4701
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4697
|
-
/* @__PURE__ */ jsxs(
|
|
4702
|
+
/* @__PURE__ */ jsxs("div", { className: styles_module_default2.resourceBtn, onClick: () => setModalOpen(true), children: [
|
|
4698
4703
|
/* @__PURE__ */ jsx(IconFont_default, { type: "icon-skill" }),
|
|
4699
4704
|
/* @__PURE__ */ jsx(Text7, { children: "\u6280\u80FD" }),
|
|
4700
4705
|
skillsCount > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -4713,9 +4718,9 @@ var ChatSender_default2 = forwardRef(
|
|
|
4713
4718
|
sendBtnProps,
|
|
4714
4719
|
footerBelow = false,
|
|
4715
4720
|
reasonBtn = true,
|
|
4716
|
-
skillsBtn =
|
|
4717
|
-
knowledgeBtn =
|
|
4718
|
-
modelSelect =
|
|
4721
|
+
skillsBtn = false,
|
|
4722
|
+
knowledgeBtn = false,
|
|
4723
|
+
modelSelect = false
|
|
4719
4724
|
}, ref) => {
|
|
4720
4725
|
const chatStore = useChatStore();
|
|
4721
4726
|
const configState = useSnapshot(chatStore.config);
|
|
@@ -4797,7 +4802,7 @@ var ChatSender_default2 = forwardRef(
|
|
|
4797
4802
|
}
|
|
4798
4803
|
);
|
|
4799
4804
|
var ChatSenderHeader = () => {
|
|
4800
|
-
return /* @__PURE__ */ jsxs(
|
|
4805
|
+
return /* @__PURE__ */ jsxs("div", { className: styles_module_default2.logoArea, children: [
|
|
4801
4806
|
/* @__PURE__ */ jsxs("div", { className: styles_module_default2.logoContainer, children: [
|
|
4802
4807
|
/* @__PURE__ */ jsx("div", { className: styles_module_default2.staticHalo }),
|
|
4803
4808
|
/* @__PURE__ */ jsx("div", { className: styles_module_default2.logoHoverWrapper, children: /* @__PURE__ */ jsx(IconFont_default, { type: "icon-lolrai", className: styles_module_default2.logoImage }) })
|
|
@@ -4912,6 +4917,7 @@ var layouts_default = forwardRef(({ theme: theme4, params, hooks, layout, config
|
|
|
4912
4917
|
_ref,
|
|
4913
4918
|
() => ({
|
|
4914
4919
|
sendMessage: chatStore.sendMessage,
|
|
4920
|
+
setConversationSpec: chatStore.setConversationSpec,
|
|
4915
4921
|
switchConversation: chatStore.switchConversation,
|
|
4916
4922
|
createConversation: chatStore.createConversation,
|
|
4917
4923
|
setReferences: chatStore.setReferences,
|