@zero-library/chat-copilot 3.1.20 → 3.1.21

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.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CloudUploadOutlined, PaperClipOutlined, createFromIconfontCN, EnterOutlined, DownloadOutlined, CloseOutlined, PlayCircleOutlined, CopyOutlined, DotChartOutlined, LoadingOutlined, RightOutlined, LikeOutlined, DislikeOutlined, ToolOutlined, SearchOutlined, UpOutlined, DownOutlined, PlusOutlined, CommentOutlined, StarFilled, StarOutlined, ShareAltOutlined, RedoOutlined, DeleteOutlined, ClockCircleOutlined, CheckCircleOutlined, FileImageOutlined, FilePdfOutlined, FileWordOutlined, FileExcelOutlined, FilePptOutlined, FileZipOutlined, FileTextOutlined, FileUnknownOutlined } from '@ant-design/icons';
2
2
  import { Attachments, Sender, FileCard, Bubble, Think, XProvider, Mermaid, CodeHighlighter, Welcome, Prompts, Conversations } from '@ant-design/x-v2';
3
- import { useRefState, useDebounce, createTokenManager, useSyncInput, isEmptyObj, markdownToText, RenderWrapper, shouldRender, isFunction, downloadFile, LuyaFilePreview, MarkdownEditor, useDeepEffect, isObject, useWebSocket, isNullOrUnDef, isNumber, getFileSuffixName, emit, FileIcon, copyText, LazyComponent, isBoolean, UserAvatar, htmlToMarkdown, buildUrlParams, isExternal, deepCopy, transforms, deepMerge, createRequest, HttpStatus, isArray, isString, isDef, isNull, transform, getWebSocketUrl, safeParseJson } from '@zero-library/common';
3
+ import { useRefState, useDebounce, createTokenManager, useSyncInput, isEmptyObj, markdownToText, RenderWrapper, shouldRender, isFunction, downloadFile, LuyaFilePreview, MarkdownEditor, useDeepEffect, useWebSocket, isObject, isNullOrUnDef, isNumber, getFileSuffixName, emit, FileIcon, copyText, LazyComponent, isBoolean, UserAvatar, htmlToMarkdown, buildUrlParams, isExternal, deepCopy, transforms, deepMerge, createRequest, HttpStatus, isArray, isString, isDef, isNull, transform, getWebSocketUrl, safeParseJson } from '@zero-library/common';
4
4
  import { App, Badge, Button, Flex, Typography, Tooltip, Layout, Tag, Spin, Splitter, Image as Image$1, Popover, Skeleton, Alert, theme, Collapse, Divider as Divider$1, Select as Select$1, Avatar, Space, Form, Drawer, Empty, Modal, Checkbox, Input, InputNumber, Switch as Switch$1, message, Tabs, Upload, Popconfirm, List, Card, Table, Progress as Progress$1 } from 'antd';
5
5
  import * as React10 from 'react';
6
6
  import React10__default, { createContext, forwardRef, useRef, useEffect, useImperativeHandle, useMemo, memo, useState, useContext, useCallback, useLayoutEffect } from 'react';
@@ -1183,17 +1183,6 @@ function createChatStore() {
1183
1183
  agent.loading = false;
1184
1184
  }
1185
1185
  };
1186
- const setAgent = (agentInfo) => {
1187
- agent.agentInfo = agentInfo;
1188
- if (agentInfo.agentType === 2 /* AUTONOMOUS */) {
1189
- setAgentModel({
1190
- modelName: agent.agentInfo.spec?.model?.modelName || "",
1191
- providerName: agent.agentInfo.spec?.model?.providerName || ""
1192
- });
1193
- } else if (config.layout.userInput) {
1194
- getUserInput(agent.agentInfo.id);
1195
- }
1196
- };
1197
1186
  const setUserInput = (userInput) => {
1198
1187
  if (agent.agentInfo.agentType === 1 /* FLOW */) {
1199
1188
  agent.agentInfo.userInput = userInput;
@@ -1201,15 +1190,28 @@ function createChatStore() {
1201
1190
  };
1202
1191
  const getAgentInfo = async (id) => {
1203
1192
  config.loading = true;
1204
- if (agent.agentInfo.id === id) return;
1205
1193
  try {
1206
1194
  const { data } = await config.services.request.fetchAgentInfo(id || "");
1207
- setAgent(data);
1208
- config.hooks?.onAfterSwitchAgent?.(data);
1195
+ agent.agentInfo = data;
1196
+ config.hooks?.onAfterSwitchAgent?.(agent.agentInfo);
1209
1197
  } finally {
1210
1198
  config.loading = false;
1211
1199
  }
1212
1200
  };
1201
+ const setAgent = async (agentInfo) => {
1202
+ if (!agent.agentInfo.id || agent.agentInfo.id !== agentInfo.id) {
1203
+ await getAgentInfo(agentInfo.id);
1204
+ }
1205
+ agent.agentInfo = { ...agent.agentInfo, ...agentInfo };
1206
+ if (agentInfo.agentType === 2 /* AUTONOMOUS */) {
1207
+ setAgentModel({
1208
+ modelName: agent.agentInfo.spec?.model?.modelName || "",
1209
+ providerName: agent.agentInfo.spec?.model?.providerName || ""
1210
+ });
1211
+ } else if (config.layout.userInput) {
1212
+ await getUserInput(agent.agentInfo.id);
1213
+ }
1214
+ };
1213
1215
  const conversations = proxy({
1214
1216
  /** 会话列表数据 */
1215
1217
  list: {
@@ -2262,7 +2264,7 @@ var ConversationShareBtn_default = ({ icon, ...rest }) => {
2262
2264
  const handleShareConversation = async () => {
2263
2265
  const { data } = await configState.services.request.shareConversation(conversationState.active.id);
2264
2266
  if (data) {
2265
- copyText(data.url);
2267
+ copyText(data.url, "\u94FE\u63A5\u5DF2\u590D\u5236\uFF0C\u53EF\u76F4\u63A5\u7C98\u8D34\u5206\u4EAB");
2266
2268
  }
2267
2269
  };
2268
2270
  return /* @__PURE__ */ jsx(
@@ -6605,25 +6607,10 @@ var layouts_default = forwardRef(({ theme: theme5, params, hooks, layout, config
6605
6607
  chatStore.setServices(services);
6606
6608
  }, [services]);
6607
6609
  useDeepEffect(() => {
6608
- if (agentState.agentInfo.id && isObject(config.agent?.spec)) {
6609
- chatStore.setAgent({ ...agentState.agentInfo, spec: config.agent.spec || {} });
6610
- }
6611
- }, [agentState.agentInfo.id, config.agent?.spec]);
6612
- useDeepEffect(() => {
6613
- if (agentState.agentInfo.id && isObject(config.agent?.config)) {
6614
- chatStore.setAgent({ ...agentState.agentInfo, config: config.agent.config || {} });
6615
- }
6616
- }, [agentState.agentInfo.id, config.agent?.config]);
6617
- useDeepEffect(() => {
6618
- if (agentState.agentInfo.id) {
6619
- chatStore.setUserInput(config.agent.userInput);
6620
- }
6621
- }, [agentState.agentInfo.id, config.agent?.userInput]);
6622
- useDeepEffect(() => {
6623
- if (config?.agent?.id) {
6624
- chatStore.getAgentInfo(config.agent.id);
6610
+ if (config.agent) {
6611
+ chatStore.setAgent(config.agent);
6625
6612
  }
6626
- }, [config.agent?.id]);
6613
+ }, [config.agent]);
6627
6614
  useDeepEffect(() => {
6628
6615
  if (agentState.agentInfo.id) {
6629
6616
  chatStore.initConversation(config);