@zero-library/chat-copilot 1.0.4 → 1.0.5
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 +43 -33
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +43 -33
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -1163,7 +1163,11 @@ function createChatStore() {
|
|
|
1163
1163
|
}
|
|
1164
1164
|
}
|
|
1165
1165
|
}
|
|
1166
|
-
function processMessageContent(
|
|
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
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
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(
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
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
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
});
|
|
3784
|
-
|
|
3785
|
-
|
|
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
|
] })
|
|
@@ -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);
|