@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.d.mts
CHANGED
|
@@ -583,6 +583,8 @@ type MessageEvent = RunStartedEvent | TextEvent | FilesEvent | StepStartedEvent
|
|
|
583
583
|
interface ConversationMessage {
|
|
584
584
|
/** 消息ID */
|
|
585
585
|
messageId: string;
|
|
586
|
+
/** 智能体ID */
|
|
587
|
+
agentId: string;
|
|
586
588
|
/** 会话ID */
|
|
587
589
|
conversationId: string;
|
|
588
590
|
/** 执行ID */
|
package/dist/index.d.ts
CHANGED
|
@@ -583,6 +583,8 @@ type MessageEvent = RunStartedEvent | TextEvent | FilesEvent | StepStartedEvent
|
|
|
583
583
|
interface ConversationMessage {
|
|
584
584
|
/** 消息ID */
|
|
585
585
|
messageId: string;
|
|
586
|
+
/** 智能体ID */
|
|
587
|
+
agentId: string;
|
|
586
588
|
/** 会话ID */
|
|
587
589
|
conversationId: string;
|
|
588
590
|
/** 执行ID */
|
package/dist/index.esm.js
CHANGED
|
@@ -1152,7 +1152,11 @@ function createChatStore() {
|
|
|
1152
1152
|
}
|
|
1153
1153
|
}
|
|
1154
1154
|
}
|
|
1155
|
-
function processMessageContent(
|
|
1155
|
+
function processMessageContent(message3) {
|
|
1156
|
+
const newMessage = {
|
|
1157
|
+
...message3,
|
|
1158
|
+
agentId: agent.agentInfo.id
|
|
1159
|
+
};
|
|
1156
1160
|
const contentList = Array.isArray(newMessage.content) ? newMessage.content : [];
|
|
1157
1161
|
if (contentList.length === 0) {
|
|
1158
1162
|
const messages = conversation.messages[newMessage.conversationId]?.message;
|
|
@@ -2083,32 +2087,35 @@ var getMarkdownConfig = (options) => {
|
|
|
2083
2087
|
breaks: options?.breaks ?? false
|
|
2084
2088
|
};
|
|
2085
2089
|
};
|
|
2086
|
-
var adaptMarkdownComponent = (Component) => {
|
|
2087
|
-
const WrappedComponent = ({ children, streamStatus, ...rest }) => /* @__PURE__ */ jsx(Component, { ...rest, data: safeParseJson(children, { repair: true }), loading: streamStatus === "loading" });
|
|
2090
|
+
var adaptMarkdownComponent = (Component, message3) => {
|
|
2091
|
+
const WrappedComponent = ({ children, streamStatus, ...rest }) => /* @__PURE__ */ jsx(Component, { message: message3, ...rest, data: safeParseJson(children, { repair: true }), loading: streamStatus === "loading" });
|
|
2088
2092
|
WrappedComponent.displayName = `AdaptedMarkdownComponent(${Component.displayName || Component.name || "Anonymous"})`;
|
|
2089
2093
|
return WrappedComponent;
|
|
2090
2094
|
};
|
|
2091
|
-
var adaptMarkdownComponents = (components) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component)]));
|
|
2095
|
+
var adaptMarkdownComponents = (components, message3) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component, message3)]));
|
|
2092
2096
|
function formatMixedContent(content) {
|
|
2093
2097
|
return content.replace(/<!DOCTYPE html>[\s\S]*?<\/html>/gi, (match) => `\`\`\`html
|
|
2094
2098
|
${match}
|
|
2095
2099
|
\`\`\``);
|
|
2096
2100
|
}
|
|
2097
|
-
var XMarkdown_default = ({ components, content, ...rest }) => {
|
|
2101
|
+
var XMarkdown_default = ({ message: message3, components, content, ...rest }) => {
|
|
2098
2102
|
const config = useMemo(() => getMarkdownConfig(), []);
|
|
2099
2103
|
const markdownComponents = useMemo(
|
|
2100
|
-
() => adaptMarkdownComponents(
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2104
|
+
() => adaptMarkdownComponents(
|
|
2105
|
+
{
|
|
2106
|
+
code: CodeHighlight_default,
|
|
2107
|
+
agentnavigate: AgentNavigate_default,
|
|
2108
|
+
a: PreviewLink_default,
|
|
2109
|
+
appcard: AppCard_default,
|
|
2110
|
+
fileview: FileView_default,
|
|
2111
|
+
// indexquote: IndexQuote,
|
|
2112
|
+
mdedit: MdEdit_default,
|
|
2113
|
+
fileedit: FileEdit_default,
|
|
2114
|
+
...components
|
|
2115
|
+
},
|
|
2116
|
+
message3
|
|
2117
|
+
),
|
|
2118
|
+
[components, message3]
|
|
2112
2119
|
);
|
|
2113
2120
|
return /* @__PURE__ */ jsx(
|
|
2114
2121
|
XMarkdown,
|
|
@@ -3760,20 +3767,24 @@ var RunStartedNode = React6.memo(({ loading }) => {
|
|
|
3760
3767
|
var ToolCallNode = React6.memo(({ item }) => {
|
|
3761
3768
|
return /* @__PURE__ */ jsx(tool_call_item_default, { item });
|
|
3762
3769
|
});
|
|
3763
|
-
var TextNode = React6.memo(
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3770
|
+
var TextNode = React6.memo(
|
|
3771
|
+
({ item, role, customComponents, message: message3 }) => {
|
|
3772
|
+
const content = toA2uiDisplayText(role, item?.messageContent);
|
|
3773
|
+
if (typeof content === "string" && content.startsWith("Question:")) {
|
|
3774
|
+
return /* @__PURE__ */ jsx(QuestionSummary, { content });
|
|
3775
|
+
}
|
|
3776
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3777
|
+
!!item.reasoningContent && /* @__PURE__ */ jsx(Think, { title: "\u6DF1\u5EA6\u601D\u8003", children: item.reasoningContent }),
|
|
3778
|
+
!!content && /* @__PURE__ */ jsx(XMarkdown_default, { message: message3, components: customComponents, content })
|
|
3779
|
+
] });
|
|
3767
3780
|
}
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
});
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
return /* @__PURE__ */ jsx(XMarkdown_default, { components: customComponents, content: item.errorMessage });
|
|
3776
|
-
});
|
|
3781
|
+
);
|
|
3782
|
+
var StepErrorNode = React6.memo(
|
|
3783
|
+
({ item, customComponents, message: message3 }) => {
|
|
3784
|
+
if (!item.errorMessage) return null;
|
|
3785
|
+
return /* @__PURE__ */ jsx(XMarkdown_default, { message: message3, components: customComponents, content: item.errorMessage });
|
|
3786
|
+
}
|
|
3787
|
+
);
|
|
3777
3788
|
var FilesNode = React6.memo(({ item }) => {
|
|
3778
3789
|
const chatStore = useChatStore();
|
|
3779
3790
|
const configState = useSnapshot(chatStore.config);
|
|
@@ -3842,8 +3853,8 @@ var MessageRender_default = React6.memo(({ role, message: message3, messageIndex
|
|
|
3842
3853
|
content: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3843
3854
|
item.type === "runStarted" && /* @__PURE__ */ jsx(RunStartedNode, { loading }, `flow-start-${index}`),
|
|
3844
3855
|
(item.type === "toolCall" || item.type === "toolResult") && /* @__PURE__ */ jsx(ToolCallNode, { item }, `tool-call-${item.toolCallId || index}`),
|
|
3845
|
-
item.type === "text" && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(TextNode, { item, role: message3.role, customComponents }, `message-${index}`) }),
|
|
3846
|
-
item.type === "stepError" && /* @__PURE__ */ jsx(StepErrorNode, { item, customComponents }, `step-error-${index}`),
|
|
3856
|
+
item.type === "text" && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(TextNode, { item, role: message3.role, customComponents, message: message3 }, `message-${index}`) }),
|
|
3857
|
+
item.type === "stepError" && /* @__PURE__ */ jsx(StepErrorNode, { item, customComponents, message: message3 }, `step-error-${index}`),
|
|
3847
3858
|
item.type === "files" && /* @__PURE__ */ jsx(FilesNode, { item }, `files-${index}`),
|
|
3848
3859
|
item.type === "plan" && /* @__PURE__ */ jsx(A2uiPlanNode, { item }, `plan-${index}`)
|
|
3849
3860
|
] })
|
|
@@ -4777,7 +4788,6 @@ var layouts_default = forwardRef(({ theme: theme4, params, hooks, layout, config
|
|
|
4777
4788
|
);
|
|
4778
4789
|
const configState = useSnapshot(chatStore.config);
|
|
4779
4790
|
const agentState = useSnapshot(chatStore.agent);
|
|
4780
|
-
useSnapshot(chatStore.conversation);
|
|
4781
4791
|
const containerRef = useRef(null);
|
|
4782
4792
|
useEffect(() => {
|
|
4783
4793
|
chatStore.setHooks(hooks);
|