@zero-library/chat-copilot 1.0.4 → 1.0.6

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
@@ -1163,7 +1163,11 @@ function createChatStore() {
1163
1163
  }
1164
1164
  }
1165
1165
  }
1166
- function processMessageContent(newMessage) {
1166
+ function processMessageContent(message3) {
1167
+ const newMessage = {
1168
+ ...message3,
1169
+ agentId: agent.agentInfo.id
1170
+ };
1167
1171
  const contentList = Array.isArray(newMessage.content) ? newMessage.content : [];
1168
1172
  if (contentList.length === 0) {
1169
1173
  const messages = conversation.messages[newMessage.conversationId]?.message;
@@ -2094,32 +2098,35 @@ var getMarkdownConfig = (options) => {
2094
2098
  breaks: options?.breaks ?? false
2095
2099
  };
2096
2100
  };
2097
- var adaptMarkdownComponent = (Component) => {
2098
- const WrappedComponent = ({ children, streamStatus, ...rest }) => /* @__PURE__ */ jsxRuntime.jsx(Component, { ...rest, data: common.safeParseJson(children, { repair: true }), loading: streamStatus === "loading" });
2101
+ var adaptMarkdownComponent = (Component, message3) => {
2102
+ const WrappedComponent = ({ children, streamStatus, ...rest }) => /* @__PURE__ */ jsxRuntime.jsx(Component, { message: message3, ...rest, data: common.safeParseJson(children, { repair: true }), loading: streamStatus === "loading" });
2099
2103
  WrappedComponent.displayName = `AdaptedMarkdownComponent(${Component.displayName || Component.name || "Anonymous"})`;
2100
2104
  return WrappedComponent;
2101
2105
  };
2102
- var adaptMarkdownComponents = (components) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component)]));
2106
+ var adaptMarkdownComponents = (components, message3) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component, message3)]));
2103
2107
  function formatMixedContent(content) {
2104
2108
  return content.replace(/<!DOCTYPE html>[\s\S]*?<\/html>/gi, (match) => `\`\`\`html
2105
2109
  ${match}
2106
2110
  \`\`\``);
2107
2111
  }
2108
- var XMarkdown_default = ({ components, content, ...rest }) => {
2112
+ var XMarkdown_default = ({ message: message3, components, content, ...rest }) => {
2109
2113
  const config = React6.useMemo(() => getMarkdownConfig(), []);
2110
2114
  const markdownComponents = React6.useMemo(
2111
- () => adaptMarkdownComponents({
2112
- code: CodeHighlight_default,
2113
- agentnavigate: AgentNavigate_default,
2114
- a: PreviewLink_default,
2115
- appcard: AppCard_default,
2116
- fileview: FileView_default,
2117
- // indexquote: IndexQuote,
2118
- mdedit: MdEdit_default,
2119
- fileedit: FileEdit_default,
2120
- ...components
2121
- }),
2122
- [components]
2115
+ () => adaptMarkdownComponents(
2116
+ {
2117
+ code: CodeHighlight_default,
2118
+ agentnavigate: AgentNavigate_default,
2119
+ a: PreviewLink_default,
2120
+ appcard: AppCard_default,
2121
+ fileview: FileView_default,
2122
+ // indexquote: IndexQuote,
2123
+ mdedit: MdEdit_default,
2124
+ fileedit: FileEdit_default,
2125
+ ...components
2126
+ },
2127
+ message3
2128
+ ),
2129
+ [components, message3]
2123
2130
  );
2124
2131
  return /* @__PURE__ */ jsxRuntime.jsx(
2125
2132
  XMarkdown__default.default,
@@ -3771,20 +3778,24 @@ var RunStartedNode = React6__default.default.memo(({ loading }) => {
3771
3778
  var ToolCallNode = React6__default.default.memo(({ item }) => {
3772
3779
  return /* @__PURE__ */ jsxRuntime.jsx(tool_call_item_default, { item });
3773
3780
  });
3774
- var TextNode = React6__default.default.memo(({ item, role, customComponents }) => {
3775
- const content = toA2uiDisplayText(role, item?.messageContent);
3776
- if (typeof content === "string" && content.startsWith("Question:")) {
3777
- return /* @__PURE__ */ jsxRuntime.jsx(QuestionSummary, { content });
3781
+ var TextNode = React6__default.default.memo(
3782
+ ({ item, role, customComponents, message: message3 }) => {
3783
+ const content = toA2uiDisplayText(role, item?.messageContent);
3784
+ if (typeof content === "string" && content.startsWith("Question:")) {
3785
+ return /* @__PURE__ */ jsxRuntime.jsx(QuestionSummary, { content });
3786
+ }
3787
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3788
+ !!item.reasoningContent && /* @__PURE__ */ jsxRuntime.jsx(xV2.Think, { title: "\u6DF1\u5EA6\u601D\u8003", children: item.reasoningContent }),
3789
+ !!content && /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message3, components: customComponents, content })
3790
+ ] });
3778
3791
  }
3779
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3780
- !!item.reasoningContent && /* @__PURE__ */ jsxRuntime.jsx(xV2.Think, { title: "\u6DF1\u5EA6\u601D\u8003", children: item.reasoningContent }),
3781
- !!content && /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { components: customComponents, content })
3782
- ] });
3783
- });
3784
- var StepErrorNode = React6__default.default.memo(({ item, customComponents }) => {
3785
- if (!item.errorMessage) return null;
3786
- return /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { components: customComponents, content: item.errorMessage });
3787
- });
3792
+ );
3793
+ var StepErrorNode = React6__default.default.memo(
3794
+ ({ item, customComponents, message: message3 }) => {
3795
+ if (!item.errorMessage) return null;
3796
+ return /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { message: message3, components: customComponents, content: item.errorMessage });
3797
+ }
3798
+ );
3788
3799
  var FilesNode = React6__default.default.memo(({ item }) => {
3789
3800
  const chatStore = useChatStore();
3790
3801
  const configState = valtio.useSnapshot(chatStore.config);
@@ -3853,8 +3864,8 @@ var MessageRender_default = React6__default.default.memo(({ role, message: messa
3853
3864
  content: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3854
3865
  item.type === "runStarted" && /* @__PURE__ */ jsxRuntime.jsx(RunStartedNode, { loading }, `flow-start-${index}`),
3855
3866
  (item.type === "toolCall" || item.type === "toolResult") && /* @__PURE__ */ jsxRuntime.jsx(ToolCallNode, { item }, `tool-call-${item.toolCallId || index}`),
3856
- item.type === "text" && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(TextNode, { item, role: message3.role, customComponents }, `message-${index}`) }),
3857
- item.type === "stepError" && /* @__PURE__ */ jsxRuntime.jsx(StepErrorNode, { item, customComponents }, `step-error-${index}`),
3867
+ item.type === "text" && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(TextNode, { item, role: message3.role, customComponents, message: message3 }, `message-${index}`) }),
3868
+ item.type === "stepError" && /* @__PURE__ */ jsxRuntime.jsx(StepErrorNode, { item, customComponents, message: message3 }, `step-error-${index}`),
3858
3869
  item.type === "files" && /* @__PURE__ */ jsxRuntime.jsx(FilesNode, { item }, `files-${index}`),
3859
3870
  item.type === "plan" && /* @__PURE__ */ jsxRuntime.jsx(A2uiPlanNode, { item }, `plan-${index}`)
3860
3871
  ] })
@@ -3989,7 +4000,7 @@ var BubbleListItems_default = ({
3989
4000
  const showLogButton = isDebug && isLeftBubble && !isMessageLoading && isWorkFlow;
3990
4001
  const baseKey = `${message3.executionId}-${messageIndex}`;
3991
4002
  const footerNode = !isMessageLoading ? /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", gap: 8, children: [
3992
- message3.stopFlag && /* @__PURE__ */ jsxRuntime.jsx(Text3, { type: "secondary", style: { flex: "none" }, children: "\u5DF2\u505C\u6B62" }),
4003
+ message3.stopFlag && isLeftBubble && /* @__PURE__ */ jsxRuntime.jsx(Text3, { type: "secondary", style: { flex: "none" }, children: "\u5DF2\u505C\u6B62" }),
3993
4004
  /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", gap: 4, children: [
3994
4005
  showLogButton && /* @__PURE__ */ jsxRuntime.jsx(
3995
4006
  antd.Button,
@@ -4788,7 +4799,6 @@ var layouts_default = React6.forwardRef(({ theme: theme4, params, hooks, layout,
4788
4799
  );
4789
4800
  const configState = valtio.useSnapshot(chatStore.config);
4790
4801
  const agentState = valtio.useSnapshot(chatStore.agent);
4791
- valtio.useSnapshot(chatStore.conversation);
4792
4802
  const containerRef = React6.useRef(null);
4793
4803
  React6.useEffect(() => {
4794
4804
  chatStore.setHooks(hooks);