@zero-library/chat-copilot 1.0.8 → 1.0.9

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.d.mts CHANGED
@@ -576,7 +576,16 @@ interface PlanEvent {
576
576
  content?: string;
577
577
  plan?: any;
578
578
  }
579
- type MessageEvent = RunStartedEvent | TextEvent | FilesEvent | StepStartedEvent | StepFinishedEvent | StepErrorEvent | RunFinishedEvent | RunStoppedEvent | ConversationNewTitleEvent | ToolCallEvent | ToolResultEvent | RunFailedEvent | A2uiCommandEvent | A2uiSchemaEvent | PlanEvent;
579
+ interface Citation {
580
+ citationId?: string;
581
+ citationUrl?: string;
582
+ citationName?: string;
583
+ }
584
+ interface CitationEvent {
585
+ type: 'citation';
586
+ citations?: Citation[];
587
+ }
588
+ type MessageEvent = RunStartedEvent | TextEvent | FilesEvent | StepStartedEvent | StepFinishedEvent | StepErrorEvent | RunFinishedEvent | RunStoppedEvent | ConversationNewTitleEvent | ToolCallEvent | ToolResultEvent | RunFailedEvent | A2uiCommandEvent | A2uiSchemaEvent | PlanEvent | CitationEvent;
580
589
  /**
581
590
  * 消息类型
582
591
  * 定义智能体和用户之间的消息结构
package/dist/index.d.ts CHANGED
@@ -576,7 +576,16 @@ interface PlanEvent {
576
576
  content?: string;
577
577
  plan?: any;
578
578
  }
579
- type MessageEvent = RunStartedEvent | TextEvent | FilesEvent | StepStartedEvent | StepFinishedEvent | StepErrorEvent | RunFinishedEvent | RunStoppedEvent | ConversationNewTitleEvent | ToolCallEvent | ToolResultEvent | RunFailedEvent | A2uiCommandEvent | A2uiSchemaEvent | PlanEvent;
579
+ interface Citation {
580
+ citationId?: string;
581
+ citationUrl?: string;
582
+ citationName?: string;
583
+ }
584
+ interface CitationEvent {
585
+ type: 'citation';
586
+ citations?: Citation[];
587
+ }
588
+ type MessageEvent = RunStartedEvent | TextEvent | FilesEvent | StepStartedEvent | StepFinishedEvent | StepErrorEvent | RunFinishedEvent | RunStoppedEvent | ConversationNewTitleEvent | ToolCallEvent | ToolResultEvent | RunFailedEvent | A2uiCommandEvent | A2uiSchemaEvent | PlanEvent | CitationEvent;
580
589
  /**
581
590
  * 消息类型
582
591
  * 定义智能体和用户之间的消息结构
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { CloudUploadOutlined, PaperClipOutlined, LoadingOutlined, createFromIconfontCN, EnterOutlined, DownloadOutlined, CloseOutlined, PlusOutlined, CommentOutlined, FileTextOutlined, CopyOutlined, LikeOutlined, DislikeOutlined, ToolOutlined, RedoOutlined, PlayCircleOutlined, DotChartOutlined, DeleteOutlined, ClockCircleOutlined, CheckCircleOutlined } from '@ant-design/icons';
2
2
  import { Attachments, Sender, Think, FileCard, Bubble, XProvider, Conversations, Welcome, Prompts, Mermaid, CodeHighlighter } from '@ant-design/x-v2';
3
- import { useRefState, useDebounce, useSyncInput, createTokenManager, isEmptyObj, markdownToText, RenderWrapper, shouldRender, isFunction, downloadFile, LuyaFilePreview, MarkdownEditor, useDeepEffect, isObject, useWebSocket, isNullOrUnDef, isNumber, getFileSuffixName, isBoolean, UserAvatar, htmlToMarkdown, copyText, deepCopy, transforms, deepMerge, buildUrlParams, createRequest, HttpStatus, isArray, isString, FileIcon, LazyComponent, formatSize, isDef, isNull, transform, emit, getWebSocketUrl, safeParseJson } from '@zero-library/common';
4
- import { App, Badge, Button, Flex, Typography, Tooltip, Tag as Tag$1, Spin, Splitter, theme, Collapse, Avatar, Space, Popover, Form, Empty, Input, InputNumber, Switch as Switch$1, message, List, Skeleton, Alert, Upload, Card, Table, Progress as Progress$1, Divider as Divider$1, Select as Select$1 } from 'antd';
3
+ import { useRefState, useDebounce, useSyncInput, createTokenManager, isEmptyObj, markdownToText, RenderWrapper, shouldRender, isFunction, downloadFile, LuyaFilePreview, MarkdownEditor, useDeepEffect, isObject, useWebSocket, isNullOrUnDef, isNumber, getFileSuffixName, isBoolean, UserAvatar, htmlToMarkdown, copyText, deepCopy, transforms, deepMerge, buildUrlParams, createRequest, HttpStatus, isArray, isString, FileIcon, LazyComponent, formatSize, isDef, isNull, transform, emit, getWebSocketUrl, safeParseJson, isExternal } from '@zero-library/common';
4
+ import { App, Badge, Button, Flex, Typography, Tooltip, Tag, Spin, Splitter, theme, Collapse, Avatar, Space, Popover, Form, Empty, Input, InputNumber, Switch as Switch$1, message, List, Skeleton, Alert, Upload, Drawer, Card, Table, Progress as Progress$1, Divider as Divider$1, Select as Select$1 } from 'antd';
5
5
  import React6, { createContext, forwardRef, useRef, useEffect, useImperativeHandle, useMemo, memo, useState, useContext, useCallback } from 'react';
6
6
  import { useSnapshot, proxy } from 'valtio';
7
7
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -1149,7 +1149,7 @@ function createChatStore() {
1149
1149
  messages.push(finalMsg);
1150
1150
  } else {
1151
1151
  const prevContent = messages[idx]?.content || [];
1152
- messages[idx].content = [...prevContent, newMessage.content[0]];
1152
+ messages[idx].content = [...prevContent, ...newMessage.content];
1153
1153
  }
1154
1154
  conversation.messages[newMessage.conversationId].loading = true;
1155
1155
  break;
@@ -1549,7 +1549,7 @@ function getArtifactFallbackTitle(type) {
1549
1549
  return "\u672A\u547D\u540D\u5185\u5BB9";
1550
1550
  }
1551
1551
  var ArtifactCard = ({ type, title }) => /* @__PURE__ */ jsx(Card, { size: "small", style: { borderRadius: 12 }, children: /* @__PURE__ */ jsxs(Space, { align: "center", wrap: true, children: [
1552
- /* @__PURE__ */ jsx(Tag$1, { color: "blue", children: type }),
1552
+ /* @__PURE__ */ jsx(Tag, { color: "blue", children: type }),
1553
1553
  /* @__PURE__ */ jsx(AText, { strong: true, children: title || getArtifactFallbackTitle(type) })
1554
1554
  ] }) });
1555
1555
  function renderMiniChart(spec, opts) {
@@ -2065,6 +2065,44 @@ var FileView_default = ({ data, loading }) => {
2065
2065
  /* @__PURE__ */ jsx("div", { className: "text-ellipsis", title: data.fileName, children: data.fileName })
2066
2066
  ] }) });
2067
2067
  };
2068
+ var DocDrawer_default = ({ title, open, onClose, paramsStr }) => {
2069
+ const chatStore = useChatStore();
2070
+ useSnapshot(chatStore.config);
2071
+ const [content, setContent] = useState("");
2072
+ const [loading, setLoading] = useState(false);
2073
+ const getContent = async () => {
2074
+ try {
2075
+ setLoading(true);
2076
+ setContent("");
2077
+ } finally {
2078
+ setLoading(false);
2079
+ }
2080
+ };
2081
+ useEffect(() => {
2082
+ getContent();
2083
+ }, [paramsStr]);
2084
+ return /* @__PURE__ */ jsx(Drawer, { title, push: false, size: "100%", open, onClose, children: /* @__PURE__ */ jsx(Spin, { spinning: loading, children: content ? /* @__PURE__ */ jsx(XMarkdown, { content }) : /* @__PURE__ */ jsx(Empty, { className: "m-t-32" }) }) });
2085
+ };
2086
+ var IndexQuote_default = ({ data, loading, message: message3 }) => {
2087
+ const [open, setOpen] = useState(false);
2088
+ const citation = useMemo(() => {
2089
+ const citations = message3.content?.find((item) => item.type === "citation")?.citations ?? [];
2090
+ return citations?.find((item) => String(item.citationId) === String(data.citationId));
2091
+ }, [data.citationId, message3.content]);
2092
+ const onClick = () => {
2093
+ if (!citation?.citationUrl) return;
2094
+ if (isExternal(citation.citationUrl)) {
2095
+ window.open(citation.citationUrl, "_blank");
2096
+ } else {
2097
+ setOpen(true);
2098
+ }
2099
+ };
2100
+ const Content = /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Flex, { align: "center", gap: 8, children: /* @__PURE__ */ jsx("a", { onClick, children: citation?.citationName }) }) });
2101
+ return /* @__PURE__ */ jsxs("div", { className: "inline-block m-l-8", children: [
2102
+ /* @__PURE__ */ jsx(Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsx(Popover, { content: Content, children: /* @__PURE__ */ jsx(Tag, { variant: "filled", color: "processing", className: "cursor-pointer", children: data?.citationName }) }) }),
2103
+ open && /* @__PURE__ */ jsx(DocDrawer_default, { paramsStr: citation?.citationUrl, title: citation?.citationName, open, onClose: () => setOpen(false) })
2104
+ ] });
2105
+ };
2068
2106
  var MdEdit_default = ({ data, loading }) => {
2069
2107
  const chatStore = useChatStore();
2070
2108
  const [value, setValue] = useState("");
@@ -2122,6 +2160,9 @@ var PreviewLink_default = ({ data, loading, domNode, ...rest }) => {
2122
2160
  };
2123
2161
  return /* @__PURE__ */ jsx("a", { ...rest, onClick: handleClick, children: data });
2124
2162
  };
2163
+ var Think_default = ({ data }) => {
2164
+ return /* @__PURE__ */ jsx(Think, { title: "\u6DF1\u5EA6\u601D\u8003", className: "m-b-16", children: data });
2165
+ };
2125
2166
 
2126
2167
  // src/components/XMarkdown/styles.module.less
2127
2168
  var styles_module_default4 = {
@@ -2169,13 +2210,14 @@ var XMarkdown_default = ({ message: message3, components, content, ...rest }) =>
2169
2210
  const markdownComponents = useMemo(
2170
2211
  () => adaptMarkdownComponents(
2171
2212
  {
2213
+ think: Think_default,
2172
2214
  code: CodeHighlight_default,
2173
2215
  agentnavigate: AgentNavigate_default,
2174
2216
  a: PreviewLink_default,
2175
2217
  appcard: AppCard_default,
2176
2218
  fileview: FileView_default,
2177
2219
  charts: Charts_default,
2178
- // indexquote: IndexQuote,
2220
+ indexquote: IndexQuote_default,
2179
2221
  mdedit: MdEdit_default,
2180
2222
  fileedit: FileEdit_default,
2181
2223
  ...components
@@ -2546,7 +2588,7 @@ var Button7 = ({ label, variant = "default", onClick, action, onAction }) => {
2546
2588
  return /* @__PURE__ */ jsx(Button, { type: variant === "primary" ? "primary" : "default", danger: variant === "danger", onClick: handleClick, style: { borderRadius: 8 }, children: label });
2547
2589
  };
2548
2590
  var Divider = () => /* @__PURE__ */ jsx(Divider$1, { style: { margin: "8px 0" } });
2549
- var Tag = ({ text, color }) => /* @__PURE__ */ jsx(Tag$1, { color, children: text });
2591
+ var Tag2 = ({ text, color }) => /* @__PURE__ */ jsx(Tag, { color, children: text });
2550
2592
  var Progress = ({
2551
2593
  percent,
2552
2594
  status = "normal",
@@ -2564,7 +2606,7 @@ var A2uiComponents = {
2564
2606
  Switch,
2565
2607
  Button: Button7,
2566
2608
  Divider,
2567
- Tag,
2609
+ Tag: Tag2,
2568
2610
  Progress,
2569
2611
  ArtifactCard,
2570
2612
  TableViewer,
@@ -4818,7 +4860,7 @@ var ChatPreviewPanel = memo(({ file }) => {
4818
4860
  }
4819
4861
  });
4820
4862
  },
4821
- extraNav: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Tag$1, { variant: "filled", color: "default", className: "cursor-pointer", onClick: () => chatStore.setPreview(), children: /* @__PURE__ */ jsx(CloseOutlined, {}) }) })
4863
+ extraNav: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Tag, { variant: "filled", color: "default", className: "cursor-pointer", onClick: () => chatStore.setPreview(), children: /* @__PURE__ */ jsx(CloseOutlined, {}) }) })
4822
4864
  }
4823
4865
  )
4824
4866
  ] });