@zero-library/chat-copilot 1.0.18 → 1.0.19

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
@@ -1292,6 +1292,23 @@ interface ChatHooks {
1292
1292
  * }
1293
1293
  */
1294
1294
  onAfterSetReferences?: (references?: ReferencesType) => void;
1295
+ /**
1296
+ * 处理发送参数前回调
1297
+ * 在发送消息前调用,返回新的发送参数,如果是异步操作可以返回 Promise
1298
+ *
1299
+ * @param sendParams - 要发送的消息参数
1300
+ * @returns ConversationMessageSend | Promise<ConversationMessageSend> | void - 返回处理后的发送参数
1301
+ *
1302
+ * @example
1303
+ * onHandleSendParams: (sendParams) => {
1304
+ * // 修改发送参数
1305
+ * return {
1306
+ * ...sendParams,
1307
+ * message: sendParams.message + ' (附加内容)'
1308
+ * }
1309
+ * }
1310
+ */
1311
+ onHandleSendParams?: (sendParams: ConversationMessageSend) => ConversationMessageSend | Promise<ConversationMessageSend> | void;
1295
1312
  }
1296
1313
 
1297
1314
  /**
@@ -1623,4 +1640,4 @@ interface MessageRenderProps {
1623
1640
 
1624
1641
  declare const _default: react.ForwardRefExoticComponent<ChatProps & react.RefAttributes<ChatHandle>>;
1625
1642
 
1626
- export { type AgentConfig, type AgentInfo, type AgentSpec, _default$1 as Attachments, type AttachmentsProps, type ChatConfig, _default as ChatCopilot, type ChatHandle, type ChatHooks, type ChatLayout, type ChatParams, type ChatProps, _default$2 as ChatSender, type ChatServices, type ConversationMessage, type ConversationStrategy, type CustomButtonProps, type FileTextType, type FileUploadConfig, type FileUrlType, type InputFile, type MessageRenderProps, type ReferencesType, type RequestInstance, type SenderProps };
1643
+ export { type AgentConfig, type AgentInfo, type AgentSpec, _default$1 as Attachments, type AttachmentsProps, type ChatConfig, _default as ChatCopilot, type ChatHandle, type ChatHooks, type ChatLayout, type ChatParams, type ChatProps, _default$2 as ChatSender, type ChatServices, type ConversationMessage, type ConversationMessageSend, type ConversationStrategy, type CustomButtonProps, type FileTextType, type FileUploadConfig, type FileUrlType, type InputFile, type MessageRenderProps, type ReferencesType, type RequestInstance, type SenderProps };
package/dist/index.d.ts CHANGED
@@ -1292,6 +1292,23 @@ interface ChatHooks {
1292
1292
  * }
1293
1293
  */
1294
1294
  onAfterSetReferences?: (references?: ReferencesType) => void;
1295
+ /**
1296
+ * 处理发送参数前回调
1297
+ * 在发送消息前调用,返回新的发送参数,如果是异步操作可以返回 Promise
1298
+ *
1299
+ * @param sendParams - 要发送的消息参数
1300
+ * @returns ConversationMessageSend | Promise<ConversationMessageSend> | void - 返回处理后的发送参数
1301
+ *
1302
+ * @example
1303
+ * onHandleSendParams: (sendParams) => {
1304
+ * // 修改发送参数
1305
+ * return {
1306
+ * ...sendParams,
1307
+ * message: sendParams.message + ' (附加内容)'
1308
+ * }
1309
+ * }
1310
+ */
1311
+ onHandleSendParams?: (sendParams: ConversationMessageSend) => ConversationMessageSend | Promise<ConversationMessageSend> | void;
1295
1312
  }
1296
1313
 
1297
1314
  /**
@@ -1623,4 +1640,4 @@ interface MessageRenderProps {
1623
1640
 
1624
1641
  declare const _default: react.ForwardRefExoticComponent<ChatProps & react.RefAttributes<ChatHandle>>;
1625
1642
 
1626
- export { type AgentConfig, type AgentInfo, type AgentSpec, _default$1 as Attachments, type AttachmentsProps, type ChatConfig, _default as ChatCopilot, type ChatHandle, type ChatHooks, type ChatLayout, type ChatParams, type ChatProps, _default$2 as ChatSender, type ChatServices, type ConversationMessage, type ConversationStrategy, type CustomButtonProps, type FileTextType, type FileUploadConfig, type FileUrlType, type InputFile, type MessageRenderProps, type ReferencesType, type RequestInstance, type SenderProps };
1643
+ export { type AgentConfig, type AgentInfo, type AgentSpec, _default$1 as Attachments, type AttachmentsProps, type ChatConfig, _default as ChatCopilot, type ChatHandle, type ChatHooks, type ChatLayout, type ChatParams, type ChatProps, _default$2 as ChatSender, type ChatServices, type ConversationMessage, type ConversationMessageSend, type ConversationStrategy, type CustomButtonProps, type FileTextType, type FileUploadConfig, type FileUrlType, type InputFile, type MessageRenderProps, type ReferencesType, type RequestInstance, type SenderProps };
package/dist/index.esm.js CHANGED
@@ -1215,7 +1215,8 @@ function createChatStore() {
1215
1215
  setHeaderOpen(false);
1216
1216
  }
1217
1217
  try {
1218
- await config.services.request.sendMessageStream(sendParams, agent.agentInfo?.id || "");
1218
+ const dealedParams = await config.hooks?.onHandleSendParams?.(sendParams);
1219
+ await config.services.request.sendMessageStream(dealedParams || sendParams, agent.agentInfo?.id || "");
1219
1220
  config.hooks?.onAfterSend?.();
1220
1221
  } finally {
1221
1222
  }
@@ -2149,7 +2150,7 @@ var MdEdit_default = ({ data, loading }) => {
2149
2150
  !loading && /* @__PURE__ */ jsx(Flex, { justify: "end", className: "m-t-16", children: /* @__PURE__ */ jsx(Button, { color: "primary", variant: "outlined", onClick: onOk, children: btnText }) })
2150
2151
  ] });
2151
2152
  };
2152
- var PreviewLink_default = ({ data, loading, domNode, ...rest }) => {
2153
+ var PreviewLink_default = ({ data, loading, message: message2, ...rest }) => {
2153
2154
  const chatStore = useChatStore();
2154
2155
  const getLinkFileName = (href) => {
2155
2156
  const url = new URL(href, window.location.origin);
@@ -2165,7 +2166,15 @@ var PreviewLink_default = ({ data, loading, domNode, ...rest }) => {
2165
2166
  }
2166
2167
  };
2167
2168
  const getPreviewFileUrl = (href) => {
2168
- return buildUrlParams({ [TOKEN_KEY]: tokenManager.get() || "" }, href);
2169
+ const url = new URL(href, window.location.origin);
2170
+ const path = url.searchParams.get("path") || url.pathname;
2171
+ const fileName = getLinkFileName(href);
2172
+ console.log(path, fileName);
2173
+ if (isDocument(fileName)) {
2174
+ return chatStore.config.services.request.getPreviewUrl(message2.agentId, message2.conversationId, path, "preview");
2175
+ } else {
2176
+ return chatStore.config.services.request.getPreviewUrl(message2.agentId, message2.conversationId, path, "download");
2177
+ }
2169
2178
  };
2170
2179
  const handlePreviewLink = (href) => {
2171
2180
  const fileName = getLinkFileName(href);
@@ -4592,7 +4601,7 @@ var KnowledgeBtn_default = ({}) => {
4592
4601
  const [modalOpen, setModalOpen] = useState(false);
4593
4602
  const knowledgeCount = conversationState.active.spec?.knowledge?.items?.length ?? 0;
4594
4603
  return /* @__PURE__ */ jsxs(Fragment, { children: [
4595
- /* @__PURE__ */ jsxs(Flex, { className: styles_module_default2.resourceBtn, onClick: () => setModalOpen(true), children: [
4604
+ /* @__PURE__ */ jsxs("div", { className: styles_module_default2.resourceBtn, onClick: () => setModalOpen(true), children: [
4596
4605
  /* @__PURE__ */ jsx(IconFont_default, { type: "icon-remark" }),
4597
4606
  /* @__PURE__ */ jsx(Text5, { children: "\u77E5\u8BC6\u5E93" }),
4598
4607
  knowledgeCount > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [