@zero-library/chat-copilot 1.0.2 → 1.0.3
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 +607 -535
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +68 -22
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +31 -5
- package/dist/index.d.ts +31 -5
- package/dist/index.esm.js +543 -471
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { CloudUploadOutlined, PaperClipOutlined, LoadingOutlined, createFromIconfontCN, EnterOutlined, DownloadOutlined, CloseOutlined, PlusOutlined, CommentOutlined, FileTextOutlined, CopyOutlined, LikeOutlined, DislikeOutlined, ToolOutlined, RedoOutlined, DeleteOutlined, ClockCircleOutlined, CheckCircleOutlined, FileImageOutlined, FilePdfOutlined, FileWordOutlined, FileExcelOutlined, FilePptOutlined, FileZipOutlined, FileUnknownOutlined } from '@ant-design/icons';
|
|
2
|
-
import { Attachments, Sender, Suggestion, Think, FileCard, Bubble, XProvider,
|
|
3
|
-
import { useRefState, useDebounce, useSyncInput, createTokenManager, markdownToText, RenderWrapper, shouldRender, isFunction,
|
|
4
|
-
import { App, Badge, Button, Flex, Typography, Spin, Splitter, theme, Collapse, Avatar, Space, Popover, Form, Empty, Input, InputNumber, Switch as Switch$1, message, List, Upload, Card, Table, Tag as Tag$1, Progress as Progress$1, Divider as Divider$1, Select as Select$1 } from 'antd';
|
|
5
|
-
import
|
|
1
|
+
import { CloudUploadOutlined, PaperClipOutlined, LoadingOutlined, createFromIconfontCN, EnterOutlined, DownloadOutlined, CloseOutlined, PlusOutlined, CommentOutlined, FileTextOutlined, CopyOutlined, LikeOutlined, DislikeOutlined, ToolOutlined, RedoOutlined, PlayCircleOutlined, DeleteOutlined, ClockCircleOutlined, CheckCircleOutlined, FileImageOutlined, FilePdfOutlined, FileWordOutlined, FileExcelOutlined, FilePptOutlined, FileZipOutlined, FileUnknownOutlined } from '@ant-design/icons';
|
|
2
|
+
import { Attachments, Sender, Suggestion, Think, FileCard, Bubble, XProvider, Conversations, Welcome, Prompts, Mermaid, CodeHighlighter } from '@ant-design/x-v2';
|
|
3
|
+
import { useRefState, useDebounce, useSyncInput, createTokenManager, isEmptyObj, markdownToText, RenderWrapper, shouldRender, isFunction, LuyaFilePreview, useDeepEffect, isObject, useWebSocket, isNullOrUnDef, isNumber, isBoolean, UserAvatar, htmlToMarkdown, copyText, deepCopy, transforms, deepMerge, createRequest, HttpStatus, isArray, isString, FileIcon, RenderMarkdown, MarkdownEditor, isDef, isNull, transform, emit, buildUrlParams, getWebSocketUrl, safeParseJson } from '@zero-library/common';
|
|
4
|
+
import { App, Badge, Button, Flex, Typography, Tooltip, Spin, Splitter, theme, Collapse, Avatar, Space, Popover, Form, Empty, Input, InputNumber, Switch as Switch$1, message, List, Upload, Card, Table, Tag as Tag$1, Progress as Progress$1, Divider as Divider$1, Select as Select$1 } from 'antd';
|
|
5
|
+
import React7, { createContext, forwardRef, useRef, useEffect, useImperativeHandle, useMemo, memo, useState, useContext, useCallback } from 'react';
|
|
6
6
|
import { useSnapshot, proxy } from 'valtio';
|
|
7
7
|
import dayjs from 'dayjs';
|
|
8
|
-
import
|
|
8
|
+
import Latex2 from '@ant-design/x-markdown/plugins/Latex';
|
|
9
9
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
10
|
-
import XMarkdown from '@ant-design/x-markdown';
|
|
11
10
|
import '@ant-design/x-markdown/themes/light.css';
|
|
12
|
-
import classNames5 from 'classnames';
|
|
13
11
|
import { XCard as XCard$1 } from '@ant-design/x-card';
|
|
12
|
+
import XMarkdown from '@ant-design/x-markdown';
|
|
13
|
+
import classNames2 from 'classnames';
|
|
14
14
|
import InfiniteScroll from 'react-infinite-scroll-component';
|
|
15
15
|
|
|
16
16
|
// src/components/Attachments.tsx
|
|
17
|
+
|
|
18
|
+
// src/assets/images/logo.png
|
|
19
|
+
var logo_default = "./logo-BX4TAWHK.png";
|
|
17
20
|
function getFileExtension(fileName = "") {
|
|
18
21
|
const ext = fileName.split(".").pop();
|
|
19
22
|
return (ext || "").toLowerCase();
|
|
@@ -27,7 +30,7 @@ function formatFileSize(size) {
|
|
|
27
30
|
}
|
|
28
31
|
var getFileIcon = (extension, fontSize = 24) => {
|
|
29
32
|
const baseStyle = { fontSize };
|
|
30
|
-
const createIcon = (Icon, color) =>
|
|
33
|
+
const createIcon = (Icon, color) => React7.createElement(Icon, { style: { ...baseStyle, color } });
|
|
31
34
|
if (["png", "jpg", "jpeg", "gif", "bmp", "webp", "svg"].includes(extension)) {
|
|
32
35
|
return createIcon(FileImageOutlined, "#22c55e");
|
|
33
36
|
}
|
|
@@ -51,6 +54,7 @@ var getFileIcon = (extension, fontSize = 24) => {
|
|
|
51
54
|
}
|
|
52
55
|
return createIcon(FileUnknownOutlined, "#94a3b8");
|
|
53
56
|
};
|
|
57
|
+
var getChatCopilotLogo = () => logo_default;
|
|
54
58
|
var classifyTime = (timestamp) => {
|
|
55
59
|
const now = dayjs();
|
|
56
60
|
const target = dayjs(timestamp);
|
|
@@ -103,38 +107,12 @@ var variablesToObject = (variables) => {
|
|
|
103
107
|
{}
|
|
104
108
|
);
|
|
105
109
|
};
|
|
106
|
-
var singleTildeExtension = {
|
|
107
|
-
name: "singleTilde",
|
|
108
|
-
level: "inline",
|
|
109
|
-
start(src) {
|
|
110
|
-
return src.match(/(?<!~)~(?!~)/)?.index;
|
|
111
|
-
},
|
|
112
|
-
tokenizer(src) {
|
|
113
|
-
const match = /^(?<!~)~(?!~)/.exec(src);
|
|
114
|
-
if (match) {
|
|
115
|
-
return {
|
|
116
|
-
type: "text",
|
|
117
|
-
raw: match[0],
|
|
118
|
-
text: match[0]
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
return void 0;
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
var getMarkdownConfig = (options) => {
|
|
125
|
-
const latexExtensions = Latex();
|
|
126
|
-
const extensions = Array.isArray(latexExtensions) ? [...latexExtensions, singleTildeExtension] : [latexExtensions, singleTildeExtension];
|
|
127
|
-
return {
|
|
128
|
-
extensions,
|
|
129
|
-
breaks: options?.breaks ?? false
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
110
|
var getChatSocketUrl = (baseURL, params) => {
|
|
133
111
|
return buildUrlParams(params, getWebSocketUrl(`${baseURL}/ws`), "comma");
|
|
134
112
|
};
|
|
135
113
|
var ChatContext = createContext(null);
|
|
136
114
|
function ChatProvider({ store, children }) {
|
|
137
|
-
return
|
|
115
|
+
return React7.createElement(ChatContext.Provider, { value: store }, children);
|
|
138
116
|
}
|
|
139
117
|
function useChatStore() {
|
|
140
118
|
const store = useContext(ChatContext);
|
|
@@ -148,7 +126,11 @@ function useChatStore() {
|
|
|
148
126
|
var styles_module_default = {
|
|
149
127
|
chatAttachments: "styles_module_chatAttachments",
|
|
150
128
|
chatSender: "styles_module_chatSender",
|
|
151
|
-
runStartedNode: "styles_module_runStartedNode"
|
|
129
|
+
runStartedNode: "styles_module_runStartedNode",
|
|
130
|
+
chatQuoteMsg: "styles_module_chatQuoteMsg",
|
|
131
|
+
quoteTooltip: "styles_module_quoteTooltip",
|
|
132
|
+
quoteTooltipContainer: "styles_module_quoteTooltipContainer"
|
|
133
|
+
};
|
|
152
134
|
var Attachments_default = forwardRef(({ fileUpload, fileUploadConfig, fileList = [], onChange, extraParams }, ref) => {
|
|
153
135
|
const { message: message3 } = App.useApp();
|
|
154
136
|
const chatStore = useChatStore();
|
|
@@ -658,7 +640,7 @@ function renderMiniChart(spec, opts) {
|
|
|
658
640
|
] }) });
|
|
659
641
|
}
|
|
660
642
|
|
|
661
|
-
// src/components/
|
|
643
|
+
// src/components/CustomComponents/a2ui-runtime/components/artifacts/export-utils.ts
|
|
662
644
|
function sanitizeFileName(name) {
|
|
663
645
|
return name.replace(/[\\/:*?"<>|\u0000-\u001F]/g, "_").replace(/\s+/g, " ").trim();
|
|
664
646
|
}
|
|
@@ -727,11 +709,11 @@ function exportJsonFile(data, fileName) {
|
|
|
727
709
|
exportTextFile(json, fileName, "application/json;charset=utf-8");
|
|
728
710
|
}
|
|
729
711
|
var ChartViewer = ({ artifactId, title, payload }) => {
|
|
730
|
-
const containerRef =
|
|
731
|
-
const [containerWidth, setContainerWidth] =
|
|
712
|
+
const containerRef = React7.useRef(null);
|
|
713
|
+
const [containerWidth, setContainerWidth] = React7.useState(0);
|
|
732
714
|
const spec = payload?.spec;
|
|
733
715
|
const needsContainerWidth = true;
|
|
734
|
-
|
|
716
|
+
React7.useLayoutEffect(() => {
|
|
735
717
|
const el = containerRef.current;
|
|
736
718
|
if (!el) return;
|
|
737
719
|
let frame = 0;
|
|
@@ -781,39 +763,62 @@ var ChartViewer = ({ artifactId, title, payload }) => {
|
|
|
781
763
|
}
|
|
782
764
|
);
|
|
783
765
|
};
|
|
784
|
-
var
|
|
766
|
+
var AgentNavigate_default = memo(({ data }) => {
|
|
785
767
|
const [content, setContent] = useState(null);
|
|
786
|
-
const { children } = props;
|
|
787
768
|
useEffect(() => {
|
|
788
|
-
if (!
|
|
769
|
+
if (!data) {
|
|
789
770
|
return;
|
|
790
771
|
}
|
|
791
|
-
console.log(typeof
|
|
792
|
-
if (typeof
|
|
772
|
+
console.log(typeof data, data);
|
|
773
|
+
if (typeof data === "string") {
|
|
793
774
|
try {
|
|
794
|
-
setContent(JSON.parse(
|
|
775
|
+
setContent(JSON.parse(data));
|
|
795
776
|
} catch (_error) {
|
|
796
777
|
setContent(null);
|
|
797
778
|
}
|
|
798
779
|
} else {
|
|
799
|
-
setContent(
|
|
780
|
+
setContent(data);
|
|
800
781
|
}
|
|
801
|
-
}, [
|
|
782
|
+
}, [data]);
|
|
802
783
|
const handleClick = () => {
|
|
803
784
|
if (!content?.emit) return;
|
|
804
785
|
};
|
|
805
786
|
return /* @__PURE__ */ jsx(Button, { onClick: handleClick, style: { padding: 0 }, type: "link", children: content?.name || "\u70B9\u51FB\u6B64\u5904" });
|
|
806
787
|
});
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
788
|
+
|
|
789
|
+
// src/components/CustomComponents/XMarkdown/styles.module.less
|
|
790
|
+
var styles_module_default2 = {
|
|
791
|
+
appCard: "styles_module_appCard",
|
|
792
|
+
fileView: "styles_module_fileView",
|
|
793
|
+
fileEdit: "styles_module_fileEdit",
|
|
794
|
+
fileEditHeader: "styles_module_fileEditHeader",
|
|
795
|
+
fileEditContent: "styles_module_fileEditContent",
|
|
796
|
+
mdEdit: "styles_module_mdEdit"
|
|
797
|
+
};
|
|
798
|
+
var AppCard_default = ({ data, loading }) => {
|
|
799
|
+
const chatStore = useChatStore();
|
|
800
|
+
const onClick = async () => {
|
|
801
|
+
if (data.appKey) {
|
|
802
|
+
const canProceed = await chatStore.config.hooks?.onAppRightVerify?.(data.appKey);
|
|
803
|
+
if (canProceed === false) {
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
chatStore.getAgentInfo(data.agentId);
|
|
808
|
+
};
|
|
809
|
+
return /* @__PURE__ */ jsx(Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsxs(Flex, { vertical: true, gap: 4, align: "center", className: styles_module_default2.appCard, onClick, children: [
|
|
810
|
+
/* @__PURE__ */ jsx("img", { src: data.iconUrl }),
|
|
811
|
+
/* @__PURE__ */ jsx("div", { className: "text-ellipsis", title: data.appName, children: data.appName })
|
|
812
|
+
] }) });
|
|
813
|
+
};
|
|
814
|
+
var CodeHighlight_default = ({ className, data }) => {
|
|
810
815
|
const lang = className?.match(/language-(\w+)/)?.[1] || "";
|
|
811
|
-
if (typeof
|
|
816
|
+
if (typeof data !== "string") return null;
|
|
812
817
|
if (!lang) {
|
|
813
|
-
return /* @__PURE__ */ jsx("code", { children });
|
|
818
|
+
return /* @__PURE__ */ jsx("code", { children: data });
|
|
814
819
|
}
|
|
815
820
|
if (lang === "mermaid") {
|
|
816
|
-
return /* @__PURE__ */ jsx(Mermaid, { children });
|
|
821
|
+
return /* @__PURE__ */ jsx(Mermaid, { children: data });
|
|
817
822
|
}
|
|
818
823
|
return /* @__PURE__ */ jsx(
|
|
819
824
|
"div",
|
|
@@ -824,11 +829,54 @@ var CodeHighlight = (props) => {
|
|
|
824
829
|
overflowX: "auto",
|
|
825
830
|
borderRadius: 8
|
|
826
831
|
},
|
|
827
|
-
children: /* @__PURE__ */ jsx("div", { style: { minWidth: "max-content" }, children: /* @__PURE__ */ jsx(CodeHighlighter, { lang, style: { margin: 0 }, children }) })
|
|
832
|
+
children: /* @__PURE__ */ jsx("div", { style: { minWidth: "max-content" }, children: /* @__PURE__ */ jsx(CodeHighlighter, { lang, style: { margin: 0 }, children: data }) })
|
|
828
833
|
}
|
|
829
834
|
);
|
|
830
835
|
};
|
|
831
|
-
var
|
|
836
|
+
var FileEdit_default = ({ data, loading }) => {
|
|
837
|
+
const chatStore = useChatStore();
|
|
838
|
+
const onPreview = () => {
|
|
839
|
+
chatStore.setPreview(data, true);
|
|
840
|
+
};
|
|
841
|
+
return /* @__PURE__ */ jsxs(Flex, { vertical: true, className: styles_module_default2.fileEdit, children: [
|
|
842
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 8, align: "center", justify: "space-between", className: styles_module_default2.fileEditHeader, children: [
|
|
843
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 4, align: "center", className: "flex-1", children: [
|
|
844
|
+
/* @__PURE__ */ jsx(FileIcon, { suffix: "md", fontSize: 18 }),
|
|
845
|
+
/* @__PURE__ */ jsx("div", { className: "text-ellipsis", title: data.fileName, children: data.fileName })
|
|
846
|
+
] }),
|
|
847
|
+
/* @__PURE__ */ jsx(Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsxs(Flex, { children: [
|
|
848
|
+
/* @__PURE__ */ jsx(Button, { color: "default", variant: "text", size: "small", icon: /* @__PURE__ */ jsx(PlayCircleOutlined, {}), onClick: onPreview, children: "\u9884\u89C8\u7F16\u8F91" }),
|
|
849
|
+
/* @__PURE__ */ jsx(Button, { color: "default", variant: "text", size: "small", icon: /* @__PURE__ */ jsx(CopyOutlined, {}), onClick: () => copyText(data.content), children: "\u590D\u5236" })
|
|
850
|
+
] }) })
|
|
851
|
+
] }),
|
|
852
|
+
/* @__PURE__ */ jsx(Flex, { gap: 8, align: "center", className: styles_module_default2.fileEditContent, children: /* @__PURE__ */ jsx(RenderMarkdown, { content: data.content }) })
|
|
853
|
+
] });
|
|
854
|
+
};
|
|
855
|
+
var FileView_default = ({ data, loading }) => {
|
|
856
|
+
const chatStore = useChatStore();
|
|
857
|
+
const onClick = () => {
|
|
858
|
+
chatStore.setPreview(data, false);
|
|
859
|
+
};
|
|
860
|
+
return /* @__PURE__ */ jsx(Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsxs(Flex, { gap: 8, align: "center", className: styles_module_default2.fileView, onClick, children: [
|
|
861
|
+
/* @__PURE__ */ jsx(FileIcon, { suffix: data.suffix }),
|
|
862
|
+
/* @__PURE__ */ jsx("div", { className: "text-ellipsis", title: data.fileName, children: data.fileName })
|
|
863
|
+
] }) });
|
|
864
|
+
};
|
|
865
|
+
var MdEdit_default = ({ data, loading }) => {
|
|
866
|
+
const chatStore = useChatStore();
|
|
867
|
+
const [value, setValue] = useState("");
|
|
868
|
+
const btnText = data.btnText || "\u7EE7\u7EED";
|
|
869
|
+
const onOk = () => {
|
|
870
|
+
chatStore.sendMessage(btnText, [], { citation: value });
|
|
871
|
+
};
|
|
872
|
+
useEffect(() => {
|
|
873
|
+
setValue(data.content);
|
|
874
|
+
}, [data.content]);
|
|
875
|
+
return /* @__PURE__ */ jsxs("div", { className: styles_module_default2.mdEdit, children: [
|
|
876
|
+
/* @__PURE__ */ jsx(MarkdownEditor, { disabled: loading, value, onChange: setValue, fixedToolbar: false, floatToolbar: false }),
|
|
877
|
+
!loading && /* @__PURE__ */ jsx(Flex, { justify: "end", className: "m-t-16", children: /* @__PURE__ */ jsx(Button, { color: "primary", variant: "outlined", onClick: onOk, children: btnText }) })
|
|
878
|
+
] });
|
|
879
|
+
};
|
|
832
880
|
var TOKEN_KEY = "NS-TOKEN";
|
|
833
881
|
var tokenManager = createTokenManager({
|
|
834
882
|
key: TOKEN_KEY
|
|
@@ -837,20 +885,20 @@ var redirectUrl = () => {
|
|
|
837
885
|
const path = localStorage.getItem("SIGNPATH");
|
|
838
886
|
emit("jumpLink", { url: `/uc${path || "/sign-in"}` });
|
|
839
887
|
};
|
|
840
|
-
var
|
|
888
|
+
var PreviewLink_default = ({ data, ...rest }) => {
|
|
841
889
|
const chatStore = useChatStore();
|
|
842
890
|
const configState = useSnapshot(chatStore.config);
|
|
843
891
|
return /* @__PURE__ */ jsx(
|
|
844
892
|
"a",
|
|
845
893
|
{
|
|
846
|
-
...
|
|
894
|
+
...rest,
|
|
847
895
|
onClick: (e) => {
|
|
848
|
-
if (
|
|
849
|
-
|
|
896
|
+
if (rest.onClick) {
|
|
897
|
+
rest.onClick(e);
|
|
850
898
|
}
|
|
851
899
|
if (!e.defaultPrevented && e.currentTarget.href) {
|
|
852
900
|
e.preventDefault();
|
|
853
|
-
if (
|
|
901
|
+
if (rest.href && String(rest.href).startsWith("/luya") && configState.layout.preview) {
|
|
854
902
|
let fileName = "link";
|
|
855
903
|
let path = e.currentTarget.href;
|
|
856
904
|
const url = new URL(path, window.location.origin);
|
|
@@ -868,16 +916,16 @@ var PreviewLinkComponent = (props) => {
|
|
|
868
916
|
fileName = lastSegment;
|
|
869
917
|
}
|
|
870
918
|
}
|
|
871
|
-
} else if (typeof
|
|
872
|
-
fileName =
|
|
873
|
-
} else if (Array.isArray(
|
|
874
|
-
fileName = String(
|
|
919
|
+
} else if (typeof data === "string") {
|
|
920
|
+
fileName = data;
|
|
921
|
+
} else if (Array.isArray(data) && typeof data[0] === "string") {
|
|
922
|
+
fileName = String(data[0]);
|
|
875
923
|
}
|
|
876
924
|
chatStore.setPreview({ path, fileName });
|
|
877
|
-
} else if (
|
|
878
|
-
window.open(
|
|
879
|
-
} else if (
|
|
880
|
-
const urlObj = new URL(
|
|
925
|
+
} else if (rest.href && !String(rest.href).startsWith("/luya")) {
|
|
926
|
+
window.open(rest.href || e.currentTarget.href, "_blank");
|
|
927
|
+
} else if (rest.href && String(rest.href).startsWith("/luya") && !configState.layout.preview) {
|
|
928
|
+
const urlObj = new URL(rest.href, window.location.origin);
|
|
881
929
|
urlObj.searchParams.set("NS-TOKEN", tokenManager.get() || "");
|
|
882
930
|
window.open(urlObj.toString(), "_blank");
|
|
883
931
|
}
|
|
@@ -886,246 +934,69 @@ var PreviewLinkComponent = (props) => {
|
|
|
886
934
|
}
|
|
887
935
|
);
|
|
888
936
|
};
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
todoText: "index_module_todoText",
|
|
904
|
-
completed: "index_module_completed",
|
|
905
|
-
emptyText: "index_module_emptyText"
|
|
906
|
-
};
|
|
907
|
-
var DefaultToolRender = ({ argsContent, resultContent, errorMessage, item }) => {
|
|
908
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
909
|
-
(item.content || item.arguments) && argsContent && /* @__PURE__ */ jsxs("div", { className: index_module_default.sectionBlock, children: [
|
|
910
|
-
/* @__PURE__ */ jsx(Typography.Text, { className: index_module_default.sectionLabel, children: "\u8F93\u5165\u53C2\u6570" }),
|
|
911
|
-
/* @__PURE__ */ jsx("div", { className: index_module_default.markdownContainer, children: /* @__PURE__ */ jsx(
|
|
912
|
-
XMarkdown,
|
|
913
|
-
{
|
|
914
|
-
className: "xMarkdownStyle",
|
|
915
|
-
components: { code: code_highlight_default },
|
|
916
|
-
config: getMarkdownConfig(),
|
|
917
|
-
content: argsContent.isJson ? `\`\`\`json
|
|
918
|
-
${argsContent.text}
|
|
919
|
-
\`\`\`` : argsContent.text
|
|
920
|
-
}
|
|
921
|
-
) })
|
|
922
|
-
] }),
|
|
923
|
-
item.result && resultContent && /* @__PURE__ */ jsxs("div", { className: index_module_default.sectionBlock, children: [
|
|
924
|
-
/* @__PURE__ */ jsx(Typography.Text, { className: index_module_default.sectionLabel, children: "\u8FD4\u56DE\u7ED3\u679C" }),
|
|
925
|
-
/* @__PURE__ */ jsx("div", { className: index_module_default.markdownContainer, children: /* @__PURE__ */ jsx(
|
|
926
|
-
XMarkdown,
|
|
927
|
-
{
|
|
928
|
-
className: "xMarkdownStyle",
|
|
929
|
-
components: { code: code_highlight_default },
|
|
930
|
-
config: getMarkdownConfig(),
|
|
931
|
-
content: resultContent.isJson ? `\`\`\`json
|
|
932
|
-
${resultContent.text}
|
|
933
|
-
\`\`\`` : resultContent.text
|
|
934
|
-
}
|
|
935
|
-
) })
|
|
936
|
-
] }),
|
|
937
|
-
errorMessage && /* @__PURE__ */ jsxs("div", { className: index_module_default.sectionBlock, children: [
|
|
938
|
-
/* @__PURE__ */ jsx(Typography.Text, { className: index_module_default.sectionLabel, children: "\u9519\u8BEF\u4FE1\u606F" }),
|
|
939
|
-
/* @__PURE__ */ jsx("div", { className: index_module_default.markdownContainer, children: /* @__PURE__ */ jsx(
|
|
940
|
-
XMarkdown,
|
|
941
|
-
{
|
|
942
|
-
className: "xMarkdownStyle",
|
|
943
|
-
components: { code: code_highlight_default },
|
|
944
|
-
config: getMarkdownConfig(),
|
|
945
|
-
content: `\`\`\`
|
|
946
|
-
${errorMessage}
|
|
947
|
-
\`\`\``
|
|
948
|
-
}
|
|
949
|
-
) })
|
|
950
|
-
] })
|
|
951
|
-
] });
|
|
952
|
-
};
|
|
953
|
-
var default_render_default = DefaultToolRender;
|
|
954
|
-
var TodoWriteRender = ({ args, result }) => {
|
|
955
|
-
const { token } = theme.useToken();
|
|
956
|
-
const todos = Array.isArray(result) ? result : result?.todos || (Array.isArray(args) ? args : args?.todos) || [];
|
|
957
|
-
const getStatusIcon = (status) => {
|
|
958
|
-
switch (status) {
|
|
959
|
-
case "completed":
|
|
960
|
-
return /* @__PURE__ */ jsx(CheckCircleOutlined, { style: { color: token.colorSuccess } });
|
|
961
|
-
case "in_progress":
|
|
962
|
-
return /* @__PURE__ */ jsx(ClockCircleOutlined, { style: { color: token.colorPrimary } });
|
|
963
|
-
case "pending":
|
|
964
|
-
default:
|
|
965
|
-
return /* @__PURE__ */ jsx(ClockCircleOutlined, { style: { color: token.colorTextTertiary } });
|
|
966
|
-
}
|
|
967
|
-
};
|
|
968
|
-
if (!todos || todos.length === 0) {
|
|
969
|
-
return /* @__PURE__ */ jsx(Typography.Text, { type: "secondary", className: index_module_default.emptyText, children: "\u6682\u65E0\u4EFB\u52A1" });
|
|
970
|
-
}
|
|
971
|
-
return /* @__PURE__ */ jsx(
|
|
972
|
-
List,
|
|
973
|
-
{
|
|
974
|
-
size: "small",
|
|
975
|
-
dataSource: todos,
|
|
976
|
-
renderItem: (item) => /* @__PURE__ */ jsxs(List.Item, { className: index_module_default.todoItem, children: [
|
|
977
|
-
/* @__PURE__ */ jsx("div", { className: index_module_default.statusIconWrapper, children: getStatusIcon(item.status) }),
|
|
978
|
-
/* @__PURE__ */ jsx("div", { className: index_module_default.todoContent, children: /* @__PURE__ */ jsx(Typography.Text, { className: `${index_module_default.todoText} ${item.status === "completed" ? index_module_default.completed : ""}`, children: item.title || item.content }) })
|
|
979
|
-
] }),
|
|
980
|
-
className: index_module_default.todoList
|
|
937
|
+
var singleTildeExtension = {
|
|
938
|
+
name: "singleTilde",
|
|
939
|
+
level: "inline",
|
|
940
|
+
start(src) {
|
|
941
|
+
return src.match(/(?<!~)~(?!~)/)?.index;
|
|
942
|
+
},
|
|
943
|
+
tokenizer(src) {
|
|
944
|
+
const match = /^(?<!~)~(?!~)/.exec(src);
|
|
945
|
+
if (match) {
|
|
946
|
+
return {
|
|
947
|
+
type: "text",
|
|
948
|
+
raw: match[0],
|
|
949
|
+
text: match[0]
|
|
950
|
+
};
|
|
981
951
|
}
|
|
982
|
-
|
|
983
|
-
};
|
|
984
|
-
var todo_write_render_default = TodoWriteRender;
|
|
985
|
-
var toolRenders = {
|
|
986
|
-
todo_write: {
|
|
987
|
-
component: todo_write_render_default,
|
|
988
|
-
defaultExpanded: false,
|
|
989
|
-
alwaysShowContent: (args, result) => {
|
|
990
|
-
const todos = Array.isArray(result) ? result : result?.todos || (Array.isArray(args) ? args : args?.todos) || [];
|
|
991
|
-
return todos && todos.length > 0;
|
|
992
|
-
},
|
|
993
|
-
hideStatus: true,
|
|
994
|
-
disableExpandOnError: true
|
|
952
|
+
return void 0;
|
|
995
953
|
}
|
|
996
954
|
};
|
|
997
|
-
var
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
}
|
|
955
|
+
var getMarkdownConfig = (options) => {
|
|
956
|
+
const latexExtensions = Latex2();
|
|
957
|
+
const extensions = Array.isArray(latexExtensions) ? [...latexExtensions, singleTildeExtension] : [latexExtensions, singleTildeExtension];
|
|
1001
958
|
return {
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
alwaysShowContent: false
|
|
959
|
+
extensions,
|
|
960
|
+
breaks: options?.breaks ?? false
|
|
1005
961
|
};
|
|
1006
962
|
};
|
|
1007
|
-
var
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
return { text: JSON.stringify(content, null, 2), isJson: true, parsed: content };
|
|
1012
|
-
}
|
|
1013
|
-
const parsed = JSON.parse(content);
|
|
1014
|
-
if (typeof parsed === "object" && parsed !== null) {
|
|
1015
|
-
return { text: JSON.stringify(parsed, null, 2), isJson: true, parsed };
|
|
1016
|
-
}
|
|
1017
|
-
return { text: content, isJson: false, parsed: null };
|
|
1018
|
-
} catch {
|
|
1019
|
-
return { text: typeof content === "string" ? content : "", isJson: false, parsed: null };
|
|
1020
|
-
}
|
|
963
|
+
var adaptMarkdownComponent = (Component) => {
|
|
964
|
+
const WrappedComponent = ({ children, streamStatus, ...rest }) => /* @__PURE__ */ jsx(Component, { ...rest, data: safeParseJson(children, { repair: true }), loading: streamStatus === "loading" });
|
|
965
|
+
WrappedComponent.displayName = `AdaptedMarkdownComponent(${Component.displayName || Component.name || "Anonymous"})`;
|
|
966
|
+
return WrappedComponent;
|
|
1021
967
|
};
|
|
1022
|
-
var
|
|
1023
|
-
const { token } = theme.useToken();
|
|
1024
|
-
const renderConfig = getToolRenderConfig(item.toolName);
|
|
1025
|
-
const CustomRender = renderConfig.component;
|
|
1026
|
-
const status = useMemo(() => {
|
|
1027
|
-
if (item.status) return item.status;
|
|
1028
|
-
if (item.errorMessage) return "error";
|
|
1029
|
-
if (item.result) return "success";
|
|
1030
|
-
return "running";
|
|
1031
|
-
}, [item.status, item.errorMessage, item.result]);
|
|
1032
|
-
const argsContent = useMemo(() => formatContent(item.arguments || item.content), [item.arguments, item.content]);
|
|
1033
|
-
const resultContent = useMemo(() => item.result ? formatContent(item.result) : null, [item.result]);
|
|
1034
|
-
const hasContent = useMemo(() => {
|
|
1035
|
-
if (renderConfig.disableExpandOnError && status === "error") return false;
|
|
1036
|
-
let alwaysShow = false;
|
|
1037
|
-
if (typeof renderConfig.alwaysShowContent === "function") {
|
|
1038
|
-
alwaysShow = renderConfig.alwaysShowContent(argsContent.parsed, resultContent?.parsed);
|
|
1039
|
-
} else if (renderConfig.alwaysShowContent) {
|
|
1040
|
-
alwaysShow = renderConfig.alwaysShowContent;
|
|
1041
|
-
}
|
|
1042
|
-
if (alwaysShow) return true;
|
|
1043
|
-
return Boolean(item.errorMessage);
|
|
1044
|
-
}, [renderConfig.disableExpandOnError, renderConfig.alwaysShowContent, item.errorMessage, status, argsContent.parsed, resultContent?.parsed]);
|
|
1045
|
-
const isDefaultExpanded = useMemo(() => {
|
|
1046
|
-
if (typeof renderConfig.defaultExpanded === "function") {
|
|
1047
|
-
return renderConfig.defaultExpanded(argsContent.parsed, resultContent?.parsed);
|
|
1048
|
-
}
|
|
1049
|
-
return renderConfig.defaultExpanded;
|
|
1050
|
-
}, [renderConfig.defaultExpanded, argsContent.parsed, resultContent?.parsed]);
|
|
1051
|
-
const statusConfig = {
|
|
1052
|
-
running: {
|
|
1053
|
-
icon: /* @__PURE__ */ jsx(LoadingOutlined, {}),
|
|
1054
|
-
color: token.colorPrimary
|
|
1055
|
-
},
|
|
1056
|
-
success: {
|
|
1057
|
-
icon: null,
|
|
1058
|
-
color: token.colorSuccess
|
|
1059
|
-
},
|
|
1060
|
-
error: {
|
|
1061
|
-
icon: null,
|
|
1062
|
-
color: token.colorSuccess
|
|
1063
|
-
},
|
|
1064
|
-
pending: {
|
|
1065
|
-
icon: /* @__PURE__ */ jsx(LoadingOutlined, {}),
|
|
1066
|
-
color: token.colorTextSecondary
|
|
1067
|
-
}
|
|
1068
|
-
}[status] || {
|
|
1069
|
-
icon: /* @__PURE__ */ jsx(LoadingOutlined, {}),
|
|
1070
|
-
color: token.colorPrimary
|
|
1071
|
-
};
|
|
1072
|
-
const renderIcon = () => {
|
|
1073
|
-
if (!item.toolIcon) {
|
|
1074
|
-
return /* @__PURE__ */ jsx(ToolOutlined, { style: { fontSize: 14, color: token.colorTextSecondary } });
|
|
1075
|
-
}
|
|
1076
|
-
const isUrl = /^(http|\/)/.test(item.toolIcon);
|
|
1077
|
-
if (isUrl) {
|
|
1078
|
-
return /* @__PURE__ */ jsx("img", { src: item.toolIcon, alt: "tool-icon", style: { width: "100%", height: "100%", objectFit: "contain" } });
|
|
1079
|
-
}
|
|
1080
|
-
return /* @__PURE__ */ jsx("span", { style: { fontSize: 14, lineHeight: 1 }, children: item.toolIcon });
|
|
1081
|
-
};
|
|
1082
|
-
return /* @__PURE__ */ jsx(
|
|
1083
|
-
Collapse,
|
|
1084
|
-
{
|
|
1085
|
-
style: { width: "70%" },
|
|
1086
|
-
collapsible: hasContent ? void 0 : "disabled",
|
|
1087
|
-
defaultActiveKey: isDefaultExpanded && hasContent ? [item.toolCallId || "fallback-key"] : void 0,
|
|
1088
|
-
expandIconPlacement: "end",
|
|
1089
|
-
styles: {
|
|
1090
|
-
header: {
|
|
1091
|
-
padding: "6px 10px"
|
|
1092
|
-
}
|
|
1093
|
-
},
|
|
1094
|
-
items: [
|
|
1095
|
-
{
|
|
1096
|
-
key: item.toolCallId || "fallback-key",
|
|
1097
|
-
showArrow: hasContent,
|
|
1098
|
-
label: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 8, style: { flex: 1, minWidth: 0 }, children: [
|
|
1099
|
-
/* @__PURE__ */ jsx("div", { className: index_module_default.iconContainer, children: renderIcon() }),
|
|
1100
|
-
/* @__PURE__ */ jsx("span", { className: index_module_default.toolName, children: item.title || item.toolName || "Unknown Tool" }),
|
|
1101
|
-
(status === "running" || status === "pending") && /* @__PURE__ */ jsx("div", { className: index_module_default.statusIcon, style: { color: statusConfig.color }, children: statusConfig.icon }),
|
|
1102
|
-
item.duration && /* @__PURE__ */ jsxs(Typography.Text, { className: index_module_default.duration, children: [
|
|
1103
|
-
item.duration,
|
|
1104
|
-
"ms"
|
|
1105
|
-
] })
|
|
1106
|
-
] }),
|
|
1107
|
-
children: /* @__PURE__ */ jsx(
|
|
1108
|
-
CustomRender,
|
|
1109
|
-
{
|
|
1110
|
-
item,
|
|
1111
|
-
args: argsContent.parsed,
|
|
1112
|
-
result: resultContent?.parsed,
|
|
1113
|
-
argsContent,
|
|
1114
|
-
resultContent,
|
|
1115
|
-
errorMessage: item.errorMessage
|
|
1116
|
-
}
|
|
1117
|
-
)
|
|
1118
|
-
}
|
|
1119
|
-
]
|
|
1120
|
-
}
|
|
1121
|
-
);
|
|
1122
|
-
};
|
|
1123
|
-
var tool_call_item_default = ToolCallItem;
|
|
968
|
+
var adaptMarkdownComponents = (components) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component)]));
|
|
1124
969
|
function formatMixedContent(content) {
|
|
1125
970
|
return content.replace(/<!DOCTYPE html>[\s\S]*?<\/html>/gi, (match) => `\`\`\`html
|
|
1126
971
|
${match}
|
|
1127
972
|
\`\`\``);
|
|
1128
973
|
}
|
|
974
|
+
var XMarkdown_default = ({ components, content, ...rest }) => {
|
|
975
|
+
const config = useMemo(() => getMarkdownConfig(), []);
|
|
976
|
+
const markdownComponents = useMemo(
|
|
977
|
+
() => adaptMarkdownComponents({
|
|
978
|
+
code: CodeHighlight_default,
|
|
979
|
+
agentnavigate: AgentNavigate_default,
|
|
980
|
+
a: PreviewLink_default,
|
|
981
|
+
appcard: AppCard_default,
|
|
982
|
+
fileview: FileView_default,
|
|
983
|
+
// indexquote: IndexQuote,
|
|
984
|
+
mdedit: MdEdit_default,
|
|
985
|
+
fileedit: FileEdit_default,
|
|
986
|
+
...components
|
|
987
|
+
}),
|
|
988
|
+
[components]
|
|
989
|
+
);
|
|
990
|
+
return /* @__PURE__ */ jsx(
|
|
991
|
+
XMarkdown,
|
|
992
|
+
{
|
|
993
|
+
config,
|
|
994
|
+
...rest,
|
|
995
|
+
content: formatMixedContent(content),
|
|
996
|
+
components: markdownComponents
|
|
997
|
+
}
|
|
998
|
+
);
|
|
999
|
+
};
|
|
1129
1000
|
var ReportViewer = ({ artifactId, title, payload }) => {
|
|
1130
1001
|
const markdown = typeof payload?.markdown === "string" ? payload.markdown : null;
|
|
1131
1002
|
if (!markdown) {
|
|
@@ -1142,20 +1013,7 @@ var ReportViewer = ({ artifactId, title, payload }) => {
|
|
|
1142
1013
|
style: { borderRadius: 12 },
|
|
1143
1014
|
title: title || "\u62A5\u544A",
|
|
1144
1015
|
extra: /* @__PURE__ */ jsx(Space, { size: 4, children: /* @__PURE__ */ jsx(Button, { size: "small", type: "text", onClick: exportMd, children: "\u5BFC\u51FAMD" }) }),
|
|
1145
|
-
children: /* @__PURE__ */ jsx("div", { style: { lineHeight: 1.75 }, children: /* @__PURE__ */ jsx(
|
|
1146
|
-
XMarkdown,
|
|
1147
|
-
{
|
|
1148
|
-
openLinksInNewTab: true,
|
|
1149
|
-
className: classNames5("x-markdown-light", "xMarkdownStyle"),
|
|
1150
|
-
components: {
|
|
1151
|
-
code: code_highlight_default,
|
|
1152
|
-
agentnavigate: agent_navigate_default,
|
|
1153
|
-
a: PreviewLinkComponent
|
|
1154
|
-
},
|
|
1155
|
-
config: getMarkdownConfig(),
|
|
1156
|
-
content: formatMixedContent(markdown)
|
|
1157
|
-
}
|
|
1158
|
-
) })
|
|
1016
|
+
children: /* @__PURE__ */ jsx("div", { style: { lineHeight: 1.75 }, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: markdown }) })
|
|
1159
1017
|
}
|
|
1160
1018
|
);
|
|
1161
1019
|
};
|
|
@@ -1325,8 +1183,8 @@ function useBoundFieldState({
|
|
|
1325
1183
|
const valuePath = decodeBindPathToken(bindPathToken) ?? pathFromValue(value);
|
|
1326
1184
|
const cachedValue = readCachedValue(readPathValue(valuePath));
|
|
1327
1185
|
const externalValue = readExternalValue(value);
|
|
1328
|
-
const dirtyRef =
|
|
1329
|
-
const [localValue, setLocalValue] =
|
|
1186
|
+
const dirtyRef = React7.useRef(false);
|
|
1187
|
+
const [localValue, setLocalValue] = React7.useState(() => {
|
|
1330
1188
|
if (valuePath && cachedValue !== void 0) {
|
|
1331
1189
|
return cachedValue;
|
|
1332
1190
|
}
|
|
@@ -1339,10 +1197,10 @@ function useBoundFieldState({
|
|
|
1339
1197
|
if (cachedValue !== void 0) return cachedValue;
|
|
1340
1198
|
return defaultValue;
|
|
1341
1199
|
});
|
|
1342
|
-
|
|
1200
|
+
React7.useEffect(() => {
|
|
1343
1201
|
dirtyRef.current = false;
|
|
1344
1202
|
}, [valuePath]);
|
|
1345
|
-
|
|
1203
|
+
React7.useEffect(() => {
|
|
1346
1204
|
if (valuePath && cachedValue !== void 0) {
|
|
1347
1205
|
setLocalValue(cachedValue);
|
|
1348
1206
|
return;
|
|
@@ -1366,10 +1224,10 @@ function useBoundFieldState({
|
|
|
1366
1224
|
setLocalValue(cachedValue);
|
|
1367
1225
|
}
|
|
1368
1226
|
}, [cachedValue, externalValue, preferCachedOverExternal, valuePath]);
|
|
1369
|
-
|
|
1227
|
+
React7.useEffect(() => {
|
|
1370
1228
|
rememberPathValue(valuePath, localValue);
|
|
1371
1229
|
}, [valuePath, localValue]);
|
|
1372
|
-
const updateLocalValue =
|
|
1230
|
+
const updateLocalValue = React7.useCallback(
|
|
1373
1231
|
(nextValue) => {
|
|
1374
1232
|
dirtyRef.current = true;
|
|
1375
1233
|
setLocalValue(nextValue);
|
|
@@ -1389,7 +1247,7 @@ function emitFieldChange(nextValue, valuePath, updateLocalValue, onDataChange, o
|
|
|
1389
1247
|
onChange?.(nextValue);
|
|
1390
1248
|
}
|
|
1391
1249
|
function useControlId(id) {
|
|
1392
|
-
const autoId =
|
|
1250
|
+
const autoId = React7.useId();
|
|
1393
1251
|
return id ?? autoId;
|
|
1394
1252
|
}
|
|
1395
1253
|
function readActionEvent(action) {
|
|
@@ -1476,7 +1334,7 @@ var Switch = ({ id, label, value, bind_path_token, onChange, onDataChange }) =>
|
|
|
1476
1334
|
/* @__PURE__ */ jsx("span", { style: { fontSize: 13, color: "#555" }, children: label })
|
|
1477
1335
|
] });
|
|
1478
1336
|
};
|
|
1479
|
-
var
|
|
1337
|
+
var Button5 = ({ label, variant = "default", onClick, action, onAction }) => {
|
|
1480
1338
|
const handleClick = () => {
|
|
1481
1339
|
if (onClick) {
|
|
1482
1340
|
onClick();
|
|
@@ -1506,7 +1364,7 @@ var A2uiComponents = {
|
|
|
1506
1364
|
TextField,
|
|
1507
1365
|
Select,
|
|
1508
1366
|
Switch,
|
|
1509
|
-
Button:
|
|
1367
|
+
Button: Button5,
|
|
1510
1368
|
Divider,
|
|
1511
1369
|
Tag,
|
|
1512
1370
|
Progress,
|
|
@@ -1516,7 +1374,7 @@ var A2uiComponents = {
|
|
|
1516
1374
|
ReportViewer
|
|
1517
1375
|
};
|
|
1518
1376
|
|
|
1519
|
-
// src/components/
|
|
1377
|
+
// src/components/CustomComponents/a2ui-runtime/controller/meta.ts
|
|
1520
1378
|
function readProp(current, props, key) {
|
|
1521
1379
|
return current[key] ?? props?.[key];
|
|
1522
1380
|
}
|
|
@@ -1622,7 +1480,7 @@ function collectActionDisplayMeta(commands, surfaceId, context) {
|
|
|
1622
1480
|
return Object.keys(labels).length || Object.keys(valueLabels).length ? { labels, valueLabels } : null;
|
|
1623
1481
|
}
|
|
1624
1482
|
|
|
1625
|
-
// src/components/
|
|
1483
|
+
// src/components/CustomComponents/a2ui-runtime/controller/action.ts
|
|
1626
1484
|
function extractPathFromRef2(value) {
|
|
1627
1485
|
if (typeof value === "string") {
|
|
1628
1486
|
if (value.startsWith("$bind:/")) return value.slice("$bind:".length);
|
|
@@ -1760,7 +1618,7 @@ function buildDispatchContext(surfaceId, rawContext, commands) {
|
|
|
1760
1618
|
};
|
|
1761
1619
|
}
|
|
1762
1620
|
|
|
1763
|
-
// src/components/
|
|
1621
|
+
// src/components/CustomComponents/a2ui-runtime/controller/visibility.ts
|
|
1764
1622
|
function extractSurfaceId(cmd) {
|
|
1765
1623
|
if (!cmd || typeof cmd !== "object") return "";
|
|
1766
1624
|
return cmd.createSurface?.surfaceId ?? cmd.updateComponents?.surfaceId ?? cmd.updateDataModel?.surfaceId ?? cmd.deleteSurface?.surfaceId ?? "";
|
|
@@ -1781,7 +1639,7 @@ function resolveVisibleSurfaceIds(commands, dismissedSurfaceIds = []) {
|
|
|
1781
1639
|
return Array.from(states.entries()).filter(([sid, st]) => !st.deleted && !dismissedSurfaceIds.includes(sid)).map(([sid]) => sid);
|
|
1782
1640
|
}
|
|
1783
1641
|
|
|
1784
|
-
// src/components/
|
|
1642
|
+
// src/components/CustomComponents/a2ui-runtime/controller/wizard.ts
|
|
1785
1643
|
function readString(obj, ...keys) {
|
|
1786
1644
|
for (const k of keys) {
|
|
1787
1645
|
const v = obj?.[k];
|
|
@@ -1990,7 +1848,7 @@ function buildWizardUpdateComponentsCommand(schema, stepId) {
|
|
|
1990
1848
|
};
|
|
1991
1849
|
}
|
|
1992
1850
|
|
|
1993
|
-
// src/components/
|
|
1851
|
+
// src/components/CustomComponents/a2ui-runtime/controller/runtime.ts
|
|
1994
1852
|
function createA2uiRuntimeState() {
|
|
1995
1853
|
return {
|
|
1996
1854
|
processedMessageCursors: [],
|
|
@@ -2190,7 +2048,7 @@ function selectA2uiRuntimeView(state, dismissedSurfaceIds) {
|
|
|
2190
2048
|
};
|
|
2191
2049
|
}
|
|
2192
2050
|
|
|
2193
|
-
// src/components/
|
|
2051
|
+
// src/components/CustomComponents/a2ui-runtime/controller/index.ts
|
|
2194
2052
|
function applyA2uiRuntimeEffects(effects) {
|
|
2195
2053
|
effects.forEach((effect) => {
|
|
2196
2054
|
if (effect.type === "reset-model-store") {
|
|
@@ -2243,15 +2101,15 @@ function useA2uiController(params) {
|
|
|
2243
2101
|
handleRuntimeAction
|
|
2244
2102
|
};
|
|
2245
2103
|
}
|
|
2246
|
-
var A2uiRuntimeContext =
|
|
2104
|
+
var A2uiRuntimeContext = React7.createContext({
|
|
2247
2105
|
commands: [],
|
|
2248
2106
|
onAction: () => void 0,
|
|
2249
2107
|
surfaceIdsByMessageIndex: {}
|
|
2250
2108
|
});
|
|
2251
2109
|
|
|
2252
|
-
// src/components/
|
|
2110
|
+
// src/components/CustomComponents/a2ui-runtime/renderer/useA2uiRuntimeView.ts
|
|
2253
2111
|
function useA2uiRuntimeView() {
|
|
2254
|
-
return
|
|
2112
|
+
return React7.useContext(A2uiRuntimeContext);
|
|
2255
2113
|
}
|
|
2256
2114
|
function A2uiMessageCards({ messageIndex }) {
|
|
2257
2115
|
const { surfaceIdsByMessageIndex } = useA2uiRuntimeView();
|
|
@@ -2260,7 +2118,7 @@ function A2uiMessageCards({ messageIndex }) {
|
|
|
2260
2118
|
return /* @__PURE__ */ jsx("div", { children: surfaceIds.map((surfaceId) => /* @__PURE__ */ jsx(XCard.Card, { id: surfaceId }, surfaceId)) });
|
|
2261
2119
|
}
|
|
2262
2120
|
|
|
2263
|
-
// src/components/
|
|
2121
|
+
// src/components/CustomComponents/a2ui-runtime/renderer/protocol.ts
|
|
2264
2122
|
function isSubmitLikeActionName2(name) {
|
|
2265
2123
|
const normalized = String(name || "").trim();
|
|
2266
2124
|
return normalized === "submit" || normalized === "confirm" || normalized.startsWith("submit_") || normalized.endsWith(".confirm");
|
|
@@ -2357,13 +2215,8 @@ function shouldHideA2uiPlan(item) {
|
|
|
2357
2215
|
return candidates.some((plan) => {
|
|
2358
2216
|
const kind = typeof plan.kind === "string" ? plan.kind.toLowerCase() : "";
|
|
2359
2217
|
const surfaceId = typeof plan.surface_id === "string" ? plan.surface_id : "";
|
|
2360
|
-
return (kind === "form" || kind === "wizard" || kind === "dashboard") && !!surfaceId;
|
|
2361
|
-
});
|
|
2362
|
-
}
|
|
2363
|
-
function formatMixedContent2(content) {
|
|
2364
|
-
return content.replace(/<!DOCTYPE html>[\s\S]*?<\/html>/gi, (match) => `\`\`\`html
|
|
2365
|
-
${match}
|
|
2366
|
-
\`\`\``);
|
|
2218
|
+
return (kind === "form" || kind === "wizard" || kind === "dashboard") && !!surfaceId;
|
|
2219
|
+
});
|
|
2367
2220
|
}
|
|
2368
2221
|
function extractPlanPayload(plan) {
|
|
2369
2222
|
if (!plan || typeof plan !== "object") return null;
|
|
@@ -2413,16 +2266,7 @@ function ViewerPlan({ payload }) {
|
|
|
2413
2266
|
|
|
2414
2267
|
${description || ""}`.trim() : "";
|
|
2415
2268
|
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
|
|
2416
|
-
header ? /* @__PURE__ */ jsx(
|
|
2417
|
-
XMarkdown,
|
|
2418
|
-
{
|
|
2419
|
-
openLinksInNewTab: true,
|
|
2420
|
-
className: classNames5("x-markdown-light", "xMarkdownStyle"),
|
|
2421
|
-
components: { code: code_highlight_default, agentnavigate: agent_navigate_default },
|
|
2422
|
-
config: getMarkdownConfig(),
|
|
2423
|
-
content: formatMixedContent2(header)
|
|
2424
|
-
}
|
|
2425
|
-
) : null,
|
|
2269
|
+
header ? /* @__PURE__ */ jsx(XMarkdown_default, { content: header }) : null,
|
|
2426
2270
|
artifacts.map((artifact, index) => renderArtifact(artifact, index))
|
|
2427
2271
|
] });
|
|
2428
2272
|
}
|
|
@@ -2440,16 +2284,7 @@ function A2uiPlanNode({ item }) {
|
|
|
2440
2284
|
${JSON.stringify(item.plan, null, 2)}
|
|
2441
2285
|
\`\`\`` : "";
|
|
2442
2286
|
if (!title && !content) return null;
|
|
2443
|
-
return /* @__PURE__ */ jsx(
|
|
2444
|
-
XMarkdown,
|
|
2445
|
-
{
|
|
2446
|
-
openLinksInNewTab: true,
|
|
2447
|
-
className: classNames5("x-markdown-light", "xMarkdownStyle"),
|
|
2448
|
-
components: { code: code_highlight_default, agentnavigate: agent_navigate_default },
|
|
2449
|
-
config: getMarkdownConfig(),
|
|
2450
|
-
content: formatMixedContent2(`${title}${content}`)
|
|
2451
|
-
}
|
|
2452
|
-
);
|
|
2287
|
+
return /* @__PURE__ */ jsx(XMarkdown_default, { content: `${title}${content}` });
|
|
2453
2288
|
}
|
|
2454
2289
|
function extractSurfaceId3(command) {
|
|
2455
2290
|
if (!command || typeof command !== "object") return "";
|
|
@@ -2488,19 +2323,19 @@ function A2uiRuntimeProvider({ messages, children }) {
|
|
|
2488
2323
|
const chatStore = useChatStore();
|
|
2489
2324
|
const conversationState = useSnapshot(chatStore.conversation);
|
|
2490
2325
|
const conversationId = conversationState.active.id;
|
|
2491
|
-
const processedMessageCursorsRef =
|
|
2492
|
-
const latestCommandIndexBySurfaceRef =
|
|
2493
|
-
const commandIndexRef =
|
|
2494
|
-
const [latestCommandIndexBySurface, setLatestCommandIndexBySurface] =
|
|
2495
|
-
const [dismissedAtBySurface, setDismissedAtBySurface] =
|
|
2496
|
-
|
|
2326
|
+
const processedMessageCursorsRef = React7.useRef([]);
|
|
2327
|
+
const latestCommandIndexBySurfaceRef = React7.useRef({});
|
|
2328
|
+
const commandIndexRef = React7.useRef(-1);
|
|
2329
|
+
const [latestCommandIndexBySurface, setLatestCommandIndexBySurface] = React7.useState({});
|
|
2330
|
+
const [dismissedAtBySurface, setDismissedAtBySurface] = React7.useState({});
|
|
2331
|
+
React7.useEffect(() => {
|
|
2497
2332
|
processedMessageCursorsRef.current = [];
|
|
2498
2333
|
latestCommandIndexBySurfaceRef.current = {};
|
|
2499
2334
|
commandIndexRef.current = -1;
|
|
2500
2335
|
setLatestCommandIndexBySurface({});
|
|
2501
2336
|
setDismissedAtBySurface({});
|
|
2502
2337
|
}, [conversationId]);
|
|
2503
|
-
|
|
2338
|
+
React7.useEffect(() => {
|
|
2504
2339
|
const { shouldReplayAll, nextCursors, pendingItems } = diffMessages(messages, processedMessageCursorsRef.current);
|
|
2505
2340
|
const itemsToProcess = shouldReplayAll ? messages.flatMap((message3) => {
|
|
2506
2341
|
const items = Array.isArray(message3?.content) ? message3.content : [];
|
|
@@ -2523,10 +2358,10 @@ function A2uiRuntimeProvider({ messages, children }) {
|
|
|
2523
2358
|
commandIndexRef.current = nextCommandIndex;
|
|
2524
2359
|
setLatestCommandIndexBySurface(nextLatestCommandIndexBySurface);
|
|
2525
2360
|
}, [messages]);
|
|
2526
|
-
const dismissedSurfaceIds =
|
|
2361
|
+
const dismissedSurfaceIds = React7.useMemo(() => {
|
|
2527
2362
|
return Object.entries(dismissedAtBySurface).filter(([surfaceId, dismissedAt]) => (latestCommandIndexBySurface[surfaceId] ?? -1) <= dismissedAt).map(([surfaceId]) => surfaceId);
|
|
2528
2363
|
}, [dismissedAtBySurface, latestCommandIndexBySurface]);
|
|
2529
|
-
const dispatchA2uiAction =
|
|
2364
|
+
const dispatchA2uiAction = React7.useCallback(
|
|
2530
2365
|
async (payload) => {
|
|
2531
2366
|
const actionPayload = normalizeA2uiActionPayload(payload);
|
|
2532
2367
|
if (!actionPayload.name) return;
|
|
@@ -2553,7 +2388,7 @@ function A2uiRuntimeProvider({ messages, children }) {
|
|
|
2553
2388
|
conversationMessages: messages,
|
|
2554
2389
|
dismissedSurfaceIds
|
|
2555
2390
|
});
|
|
2556
|
-
const onAction =
|
|
2391
|
+
const onAction = React7.useCallback(
|
|
2557
2392
|
(payload) => {
|
|
2558
2393
|
const result = handleRuntimeAction(payload);
|
|
2559
2394
|
if (result.handled || !result.name) return;
|
|
@@ -2566,7 +2401,7 @@ function A2uiRuntimeProvider({ messages, children }) {
|
|
|
2566
2401
|
},
|
|
2567
2402
|
[commands, dispatchA2uiAction, handleRuntimeAction, runtimeState.modelPathBySurface]
|
|
2568
2403
|
);
|
|
2569
|
-
const contextValue =
|
|
2404
|
+
const contextValue = React7.useMemo(
|
|
2570
2405
|
() => ({ commands, onAction, surfaceIdsByMessageIndex: anchoredSurfaceIdsByMessageIndex }),
|
|
2571
2406
|
[anchoredSurfaceIdsByMessageIndex, commands, onAction]
|
|
2572
2407
|
);
|
|
@@ -2575,12 +2410,218 @@ function A2uiRuntimeProvider({ messages, children }) {
|
|
|
2575
2410
|
function A2uiRenderer(props) {
|
|
2576
2411
|
return /* @__PURE__ */ jsx(A2uiRuntimeProvider, { ...props });
|
|
2577
2412
|
}
|
|
2413
|
+
|
|
2414
|
+
// src/components/CustomComponents/tool-renders/index.module.less
|
|
2415
|
+
var index_module_default = {
|
|
2416
|
+
iconContainer: "index_module_iconContainer",
|
|
2417
|
+
toolName: "index_module_toolName",
|
|
2418
|
+
duration: "index_module_duration",
|
|
2419
|
+
statusIcon: "index_module_statusIcon",
|
|
2420
|
+
sectionLabel: "index_module_sectionLabel",
|
|
2421
|
+
markdownContainer: "index_module_markdownContainer",
|
|
2422
|
+
sectionBlock: "index_module_sectionBlock",
|
|
2423
|
+
todoList: "index_module_todoList",
|
|
2424
|
+
todoItem: "index_module_todoItem",
|
|
2425
|
+
statusIconWrapper: "index_module_statusIconWrapper",
|
|
2426
|
+
todoContent: "index_module_todoContent",
|
|
2427
|
+
todoText: "index_module_todoText",
|
|
2428
|
+
completed: "index_module_completed",
|
|
2429
|
+
emptyText: "index_module_emptyText"
|
|
2430
|
+
};
|
|
2431
|
+
var DefaultToolRender = ({ argsContent, resultContent, errorMessage, item }) => {
|
|
2432
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2433
|
+
(item.content || item.arguments) && argsContent && /* @__PURE__ */ jsxs("div", { className: index_module_default.sectionBlock, children: [
|
|
2434
|
+
/* @__PURE__ */ jsx(Typography.Text, { className: index_module_default.sectionLabel, children: "\u8F93\u5165\u53C2\u6570" }),
|
|
2435
|
+
/* @__PURE__ */ jsx("div", { className: index_module_default.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: argsContent.isJson ? `\`\`\`json
|
|
2436
|
+
${argsContent.text}
|
|
2437
|
+
\`\`\`` : argsContent.text }) })
|
|
2438
|
+
] }),
|
|
2439
|
+
item.result && resultContent && /* @__PURE__ */ jsxs("div", { className: index_module_default.sectionBlock, children: [
|
|
2440
|
+
/* @__PURE__ */ jsx(Typography.Text, { className: index_module_default.sectionLabel, children: "\u8FD4\u56DE\u7ED3\u679C" }),
|
|
2441
|
+
/* @__PURE__ */ jsx("div", { className: index_module_default.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: resultContent.isJson ? `\`\`\`json
|
|
2442
|
+
${resultContent.text}
|
|
2443
|
+
\`\`\`` : resultContent.text }) })
|
|
2444
|
+
] }),
|
|
2445
|
+
errorMessage && /* @__PURE__ */ jsxs("div", { className: index_module_default.sectionBlock, children: [
|
|
2446
|
+
/* @__PURE__ */ jsx(Typography.Text, { className: index_module_default.sectionLabel, children: "\u9519\u8BEF\u4FE1\u606F" }),
|
|
2447
|
+
/* @__PURE__ */ jsx("div", { className: index_module_default.markdownContainer, children: /* @__PURE__ */ jsx(XMarkdown_default, { content: `\`\`\`
|
|
2448
|
+
${errorMessage}
|
|
2449
|
+
\`\`\`` }) })
|
|
2450
|
+
] })
|
|
2451
|
+
] });
|
|
2452
|
+
};
|
|
2453
|
+
var default_render_default = DefaultToolRender;
|
|
2454
|
+
var TodoWriteRender = ({ args, result }) => {
|
|
2455
|
+
const { token } = theme.useToken();
|
|
2456
|
+
const todos = Array.isArray(result) ? result : result?.todos || (Array.isArray(args) ? args : args?.todos) || [];
|
|
2457
|
+
const getStatusIcon = (status) => {
|
|
2458
|
+
switch (status) {
|
|
2459
|
+
case "completed":
|
|
2460
|
+
return /* @__PURE__ */ jsx(CheckCircleOutlined, { style: { color: token.colorSuccess } });
|
|
2461
|
+
case "in_progress":
|
|
2462
|
+
return /* @__PURE__ */ jsx(ClockCircleOutlined, { style: { color: token.colorPrimary } });
|
|
2463
|
+
case "pending":
|
|
2464
|
+
default:
|
|
2465
|
+
return /* @__PURE__ */ jsx(ClockCircleOutlined, { style: { color: token.colorTextTertiary } });
|
|
2466
|
+
}
|
|
2467
|
+
};
|
|
2468
|
+
if (!todos || todos.length === 0) {
|
|
2469
|
+
return /* @__PURE__ */ jsx(Typography.Text, { type: "secondary", className: index_module_default.emptyText, children: "\u6682\u65E0\u4EFB\u52A1" });
|
|
2470
|
+
}
|
|
2471
|
+
return /* @__PURE__ */ jsx(
|
|
2472
|
+
List,
|
|
2473
|
+
{
|
|
2474
|
+
size: "small",
|
|
2475
|
+
dataSource: todos,
|
|
2476
|
+
renderItem: (item) => /* @__PURE__ */ jsxs(List.Item, { className: index_module_default.todoItem, children: [
|
|
2477
|
+
/* @__PURE__ */ jsx("div", { className: index_module_default.statusIconWrapper, children: getStatusIcon(item.status) }),
|
|
2478
|
+
/* @__PURE__ */ jsx("div", { className: index_module_default.todoContent, children: /* @__PURE__ */ jsx(Typography.Text, { className: `${index_module_default.todoText} ${item.status === "completed" ? index_module_default.completed : ""}`, children: item.title || item.content }) })
|
|
2479
|
+
] }),
|
|
2480
|
+
className: index_module_default.todoList
|
|
2481
|
+
}
|
|
2482
|
+
);
|
|
2483
|
+
};
|
|
2484
|
+
var todo_write_render_default = TodoWriteRender;
|
|
2485
|
+
var toolRenders = {
|
|
2486
|
+
todo_write: {
|
|
2487
|
+
component: todo_write_render_default,
|
|
2488
|
+
defaultExpanded: false,
|
|
2489
|
+
alwaysShowContent: (args, result) => {
|
|
2490
|
+
const todos = Array.isArray(result) ? result : result?.todos || (Array.isArray(args) ? args : args?.todos) || [];
|
|
2491
|
+
return todos && todos.length > 0;
|
|
2492
|
+
},
|
|
2493
|
+
hideStatus: true,
|
|
2494
|
+
disableExpandOnError: true
|
|
2495
|
+
}
|
|
2496
|
+
};
|
|
2497
|
+
var getToolRenderConfig = (toolName) => {
|
|
2498
|
+
if (toolName && toolRenders[toolName]) {
|
|
2499
|
+
return toolRenders[toolName];
|
|
2500
|
+
}
|
|
2501
|
+
return {
|
|
2502
|
+
component: default_render_default,
|
|
2503
|
+
defaultExpanded: false,
|
|
2504
|
+
alwaysShowContent: false
|
|
2505
|
+
};
|
|
2506
|
+
};
|
|
2507
|
+
var formatContent = (content) => {
|
|
2508
|
+
try {
|
|
2509
|
+
if (!content) return { text: "", isJson: false, parsed: null };
|
|
2510
|
+
if (typeof content === "object") {
|
|
2511
|
+
return { text: JSON.stringify(content, null, 2), isJson: true, parsed: content };
|
|
2512
|
+
}
|
|
2513
|
+
const parsed = JSON.parse(content);
|
|
2514
|
+
if (typeof parsed === "object" && parsed !== null) {
|
|
2515
|
+
return { text: JSON.stringify(parsed, null, 2), isJson: true, parsed };
|
|
2516
|
+
}
|
|
2517
|
+
return { text: content, isJson: false, parsed: null };
|
|
2518
|
+
} catch {
|
|
2519
|
+
return { text: typeof content === "string" ? content : "", isJson: false, parsed: null };
|
|
2520
|
+
}
|
|
2521
|
+
};
|
|
2522
|
+
var ToolCallItem = ({ item }) => {
|
|
2523
|
+
const { token } = theme.useToken();
|
|
2524
|
+
const renderConfig = getToolRenderConfig(item.toolName);
|
|
2525
|
+
const CustomRender = renderConfig.component;
|
|
2526
|
+
const status = useMemo(() => {
|
|
2527
|
+
if (item.status) return item.status;
|
|
2528
|
+
if (item.errorMessage) return "error";
|
|
2529
|
+
if (item.result) return "success";
|
|
2530
|
+
return "running";
|
|
2531
|
+
}, [item.status, item.errorMessage, item.result]);
|
|
2532
|
+
const argsContent = useMemo(() => formatContent(item.arguments || item.content), [item.arguments, item.content]);
|
|
2533
|
+
const resultContent = useMemo(() => item.result ? formatContent(item.result) : null, [item.result]);
|
|
2534
|
+
const hasContent = useMemo(() => {
|
|
2535
|
+
if (renderConfig.disableExpandOnError && status === "error") return false;
|
|
2536
|
+
let alwaysShow = false;
|
|
2537
|
+
if (typeof renderConfig.alwaysShowContent === "function") {
|
|
2538
|
+
alwaysShow = renderConfig.alwaysShowContent(argsContent.parsed, resultContent?.parsed);
|
|
2539
|
+
} else if (renderConfig.alwaysShowContent) {
|
|
2540
|
+
alwaysShow = renderConfig.alwaysShowContent;
|
|
2541
|
+
}
|
|
2542
|
+
if (alwaysShow) return true;
|
|
2543
|
+
return Boolean(item.errorMessage);
|
|
2544
|
+
}, [renderConfig.disableExpandOnError, renderConfig.alwaysShowContent, item.errorMessage, status, argsContent.parsed, resultContent?.parsed]);
|
|
2545
|
+
const isDefaultExpanded = useMemo(() => {
|
|
2546
|
+
if (typeof renderConfig.defaultExpanded === "function") {
|
|
2547
|
+
return renderConfig.defaultExpanded(argsContent.parsed, resultContent?.parsed);
|
|
2548
|
+
}
|
|
2549
|
+
return renderConfig.defaultExpanded;
|
|
2550
|
+
}, [renderConfig.defaultExpanded, argsContent.parsed, resultContent?.parsed]);
|
|
2551
|
+
const statusConfig = {
|
|
2552
|
+
running: {
|
|
2553
|
+
icon: /* @__PURE__ */ jsx(LoadingOutlined, {}),
|
|
2554
|
+
color: token.colorPrimary
|
|
2555
|
+
},
|
|
2556
|
+
success: {
|
|
2557
|
+
icon: null,
|
|
2558
|
+
color: token.colorSuccess
|
|
2559
|
+
},
|
|
2560
|
+
error: {
|
|
2561
|
+
icon: null,
|
|
2562
|
+
color: token.colorSuccess
|
|
2563
|
+
},
|
|
2564
|
+
pending: {
|
|
2565
|
+
icon: /* @__PURE__ */ jsx(LoadingOutlined, {}),
|
|
2566
|
+
color: token.colorTextSecondary
|
|
2567
|
+
}
|
|
2568
|
+
}[status] || {
|
|
2569
|
+
icon: /* @__PURE__ */ jsx(LoadingOutlined, {}),
|
|
2570
|
+
color: token.colorPrimary
|
|
2571
|
+
};
|
|
2572
|
+
const renderIcon = () => {
|
|
2573
|
+
if (!item.toolIcon) {
|
|
2574
|
+
return /* @__PURE__ */ jsx(ToolOutlined, { style: { fontSize: 14, color: token.colorTextSecondary } });
|
|
2575
|
+
}
|
|
2576
|
+
const isUrl = /^(http|\/)/.test(item.toolIcon);
|
|
2577
|
+
if (isUrl) {
|
|
2578
|
+
return /* @__PURE__ */ jsx("img", { src: item.toolIcon, alt: "tool-icon", style: { width: "100%", height: "100%", objectFit: "contain" } });
|
|
2579
|
+
}
|
|
2580
|
+
return /* @__PURE__ */ jsx("span", { style: { fontSize: 14, lineHeight: 1 }, children: item.toolIcon });
|
|
2581
|
+
};
|
|
2582
|
+
return /* @__PURE__ */ jsx(
|
|
2583
|
+
Collapse,
|
|
2584
|
+
{
|
|
2585
|
+
style: { width: "70%" },
|
|
2586
|
+
collapsible: hasContent ? void 0 : "disabled",
|
|
2587
|
+
defaultActiveKey: isDefaultExpanded && hasContent ? [item.toolCallId || "fallback-key"] : void 0,
|
|
2588
|
+
expandIconPlacement: "end",
|
|
2589
|
+
styles: {
|
|
2590
|
+
header: {
|
|
2591
|
+
padding: "6px 10px"
|
|
2592
|
+
}
|
|
2593
|
+
},
|
|
2594
|
+
items: [
|
|
2595
|
+
{
|
|
2596
|
+
key: item.toolCallId || "fallback-key",
|
|
2597
|
+
showArrow: hasContent,
|
|
2598
|
+
label: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 8, style: { flex: 1, minWidth: 0 }, children: [
|
|
2599
|
+
/* @__PURE__ */ jsx("div", { className: index_module_default.iconContainer, children: renderIcon() }),
|
|
2600
|
+
/* @__PURE__ */ jsx("span", { className: index_module_default.toolName, children: item.title || item.toolName || "Unknown Tool" }),
|
|
2601
|
+
(status === "running" || status === "pending") && /* @__PURE__ */ jsx("div", { className: index_module_default.statusIcon, style: { color: statusConfig.color }, children: statusConfig.icon }),
|
|
2602
|
+
item.duration && /* @__PURE__ */ jsxs(Typography.Text, { className: index_module_default.duration, children: [
|
|
2603
|
+
item.duration,
|
|
2604
|
+
"ms"
|
|
2605
|
+
] })
|
|
2606
|
+
] }),
|
|
2607
|
+
children: /* @__PURE__ */ jsx(
|
|
2608
|
+
CustomRender,
|
|
2609
|
+
{
|
|
2610
|
+
item,
|
|
2611
|
+
args: argsContent.parsed,
|
|
2612
|
+
result: resultContent?.parsed,
|
|
2613
|
+
argsContent,
|
|
2614
|
+
resultContent,
|
|
2615
|
+
errorMessage: item.errorMessage
|
|
2616
|
+
}
|
|
2617
|
+
)
|
|
2618
|
+
}
|
|
2619
|
+
]
|
|
2620
|
+
}
|
|
2621
|
+
);
|
|
2622
|
+
};
|
|
2623
|
+
var tool_call_item_default = ToolCallItem;
|
|
2578
2624
|
var RENDERABLE_MESSAGE_TYPES = ["runStarted", "toolCall", "toolResult", "text", "stepError", "files", "plan"];
|
|
2579
|
-
function formatMixedContent3(content) {
|
|
2580
|
-
return content.replace(/<!DOCTYPE html>[\s\S]*?<\/html>/gi, (match) => `\`\`\`html
|
|
2581
|
-
${match}
|
|
2582
|
-
\`\`\``);
|
|
2583
|
-
}
|
|
2584
2625
|
function QuestionSummary({ content }) {
|
|
2585
2626
|
const answer = content.replace(/^Question:\s*/, "").trim() || "\u5DF2\u56DE\u7B54";
|
|
2586
2627
|
return /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", flexDirection: "column", gap: 4 }, children: [
|
|
@@ -2588,51 +2629,28 @@ function QuestionSummary({ content }) {
|
|
|
2588
2629
|
/* @__PURE__ */ jsx("span", { style: { fontSize: 13, color: "#262626", lineHeight: 1.6, whiteSpace: "pre-wrap" }, children: answer })
|
|
2589
2630
|
] });
|
|
2590
2631
|
}
|
|
2591
|
-
var RunStartedNode =
|
|
2632
|
+
var RunStartedNode = React7.memo(({ loading }) => {
|
|
2592
2633
|
if (!loading) return null;
|
|
2593
2634
|
return /* @__PURE__ */ jsx(Flex, { gap: 8, align: "center", className: styles_module_default.runStartedNode, children: /* @__PURE__ */ jsx(LoadingOutlined, { style: { color: "#1677ff" } }) });
|
|
2594
2635
|
});
|
|
2595
|
-
var ToolCallNode =
|
|
2636
|
+
var ToolCallNode = React7.memo(({ item }) => {
|
|
2596
2637
|
return /* @__PURE__ */ jsx(tool_call_item_default, { item });
|
|
2597
2638
|
});
|
|
2598
|
-
var TextNode =
|
|
2639
|
+
var TextNode = React7.memo(({ item, role, customComponents }) => {
|
|
2599
2640
|
const content = toA2uiDisplayText(role, item?.messageContent);
|
|
2600
2641
|
if (typeof content === "string" && content.startsWith("Question:")) {
|
|
2601
2642
|
return /* @__PURE__ */ jsx(QuestionSummary, { content });
|
|
2602
2643
|
}
|
|
2603
2644
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2604
2645
|
!!item.reasoningContent && /* @__PURE__ */ jsx(Think, { title: "\u6DF1\u5EA6\u601D\u8003", children: item.reasoningContent }),
|
|
2605
|
-
!!content && /* @__PURE__ */ jsx(
|
|
2606
|
-
XMarkdown,
|
|
2607
|
-
{
|
|
2608
|
-
openLinksInNewTab: true,
|
|
2609
|
-
className: classNames5("x-markdown-light", "xMarkdownStyle"),
|
|
2610
|
-
components: {
|
|
2611
|
-
code: code_highlight_default,
|
|
2612
|
-
agentnavigate: agent_navigate_default,
|
|
2613
|
-
a: PreviewLinkComponent,
|
|
2614
|
-
...customComponents
|
|
2615
|
-
},
|
|
2616
|
-
config: getMarkdownConfig(),
|
|
2617
|
-
content: formatMixedContent3(content)
|
|
2618
|
-
}
|
|
2619
|
-
)
|
|
2646
|
+
!!content && /* @__PURE__ */ jsx(XMarkdown_default, { components: customComponents, content })
|
|
2620
2647
|
] });
|
|
2621
2648
|
});
|
|
2622
|
-
var StepErrorNode =
|
|
2649
|
+
var StepErrorNode = React7.memo(({ item, customComponents }) => {
|
|
2623
2650
|
if (!item.errorMessage) return null;
|
|
2624
|
-
return /* @__PURE__ */ jsx(
|
|
2625
|
-
XMarkdown,
|
|
2626
|
-
{
|
|
2627
|
-
openLinksInNewTab: true,
|
|
2628
|
-
className: classNames5("x-markdown-light", "xMarkdownStyle"),
|
|
2629
|
-
components: { code: code_highlight_default, agentnavigate: agent_navigate_default, ...customComponents },
|
|
2630
|
-
config: getMarkdownConfig(),
|
|
2631
|
-
content: item.errorMessage
|
|
2632
|
-
}
|
|
2633
|
-
);
|
|
2651
|
+
return /* @__PURE__ */ jsx(XMarkdown_default, { components: customComponents, content: item.errorMessage });
|
|
2634
2652
|
});
|
|
2635
|
-
var FilesNode =
|
|
2653
|
+
var FilesNode = React7.memo(({ item }) => {
|
|
2636
2654
|
const chatStore = useChatStore();
|
|
2637
2655
|
const configState = useSnapshot(chatStore.config);
|
|
2638
2656
|
const agentState = useSnapshot(chatStore.agent);
|
|
@@ -2659,7 +2677,7 @@ var FilesNode = React9.memo(({ item }) => {
|
|
|
2659
2677
|
}, [item.files]);
|
|
2660
2678
|
return /* @__PURE__ */ jsx(FileCard.List, { items: fileItems });
|
|
2661
2679
|
});
|
|
2662
|
-
var MessageRender_default =
|
|
2680
|
+
var MessageRender_default = React7.memo(({ role, message: message3, messageIndex = -1, loading, containerRef, customComponents }) => {
|
|
2663
2681
|
const content = useMemo(() => {
|
|
2664
2682
|
return (message3.content || []).filter((item) => {
|
|
2665
2683
|
if (!RENDERABLE_MESSAGE_TYPES.includes(item.type)) {
|
|
@@ -2674,26 +2692,65 @@ var MessageRender_default = React9.memo(({ role, message: message3, messageIndex
|
|
|
2674
2692
|
return true;
|
|
2675
2693
|
});
|
|
2676
2694
|
}, [loading, message3.content]);
|
|
2695
|
+
const quoteMsg = useMemo(() => {
|
|
2696
|
+
const quoteMsg2 = {};
|
|
2697
|
+
if (message3.params) {
|
|
2698
|
+
try {
|
|
2699
|
+
const citation = JSON.parse(message3.params).citation;
|
|
2700
|
+
if (citation) {
|
|
2701
|
+
quoteMsg2.messageContent = citation;
|
|
2702
|
+
}
|
|
2703
|
+
} catch (e) {
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
return isEmptyObj(quoteMsg2) ? null : quoteMsg2;
|
|
2707
|
+
}, [message3.params, message3.quoteMsg]);
|
|
2677
2708
|
if (content.length === 0) return null;
|
|
2678
2709
|
return /* @__PURE__ */ jsxs(Flex, { ref: containerRef, vertical: true, gap: 8, children: [
|
|
2679
2710
|
content.map((item, index) => {
|
|
2680
2711
|
return /* @__PURE__ */ jsx(
|
|
2681
2712
|
Bubble,
|
|
2682
2713
|
{
|
|
2714
|
+
role: role.user,
|
|
2683
2715
|
className: "m-t-8",
|
|
2684
2716
|
placement: role.placement,
|
|
2685
2717
|
variant: item.type === "files" ? "borderless" : void 0,
|
|
2686
2718
|
content: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2687
2719
|
item.type === "runStarted" && /* @__PURE__ */ jsx(RunStartedNode, { loading }, `flow-start-${index}`),
|
|
2688
2720
|
(item.type === "toolCall" || item.type === "toolResult") && /* @__PURE__ */ jsx(ToolCallNode, { item }, `tool-call-${item.toolCallId || index}`),
|
|
2689
|
-
item.type === "text" && /* @__PURE__ */ jsx(TextNode, { item, role: message3.role, customComponents }, `message-${index}`),
|
|
2721
|
+
item.type === "text" && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(TextNode, { item, role: message3.role, customComponents }, `message-${index}`) }),
|
|
2690
2722
|
item.type === "stepError" && /* @__PURE__ */ jsx(StepErrorNode, { item, customComponents }, `step-error-${index}`),
|
|
2691
2723
|
item.type === "files" && /* @__PURE__ */ jsx(FilesNode, { item }, `files-${index}`),
|
|
2692
2724
|
item.type === "plan" && /* @__PURE__ */ jsx(A2uiPlanNode, { item }, `plan-${index}`)
|
|
2693
2725
|
] })
|
|
2694
|
-
}
|
|
2726
|
+
},
|
|
2727
|
+
`message-${index}`
|
|
2695
2728
|
);
|
|
2696
2729
|
}),
|
|
2730
|
+
quoteMsg && /* @__PURE__ */ jsx(
|
|
2731
|
+
Bubble,
|
|
2732
|
+
{
|
|
2733
|
+
className: styles_module_default.chatQuoteMsg,
|
|
2734
|
+
placement: role.placement,
|
|
2735
|
+
variant: "borderless",
|
|
2736
|
+
content: /* @__PURE__ */ jsx(Flex, { vertical: true, gap: 8, children: quoteMsg.messageContent && /* @__PURE__ */ jsx(
|
|
2737
|
+
Tooltip,
|
|
2738
|
+
{
|
|
2739
|
+
arrow: false,
|
|
2740
|
+
classNames: {
|
|
2741
|
+
root: styles_module_default.quoteTooltip,
|
|
2742
|
+
container: `${styles_module_default.quoteTooltipContainer} scroll-fade-in`
|
|
2743
|
+
},
|
|
2744
|
+
title: /* @__PURE__ */ jsx(XMarkdown_default, { content: quoteMsg.messageContent }),
|
|
2745
|
+
getPopupContainer: (node) => node,
|
|
2746
|
+
children: /* @__PURE__ */ jsxs(Flex, { children: [
|
|
2747
|
+
/* @__PURE__ */ jsx("span", { children: "\u3010\u5F15\u7528\u6D88\u606F\u3011\uFF1A" }),
|
|
2748
|
+
/* @__PURE__ */ jsx(Flex, { flex: 1, className: "text-ellipsis-2", children: quoteMsg.messageContent })
|
|
2749
|
+
] })
|
|
2750
|
+
}
|
|
2751
|
+
) })
|
|
2752
|
+
}
|
|
2753
|
+
),
|
|
2697
2754
|
messageIndex >= 0 ? /* @__PURE__ */ jsx(A2uiMessageCards, { messageIndex }) : null
|
|
2698
2755
|
] });
|
|
2699
2756
|
});
|
|
@@ -3515,18 +3572,20 @@ function createChatStore() {
|
|
|
3515
3572
|
}
|
|
3516
3573
|
processMessageContent(newMessage);
|
|
3517
3574
|
};
|
|
3518
|
-
const sendMessage = async (message3,
|
|
3575
|
+
const sendMessage = async (message3, msgFiles = [], params) => {
|
|
3519
3576
|
const conversationId = conversation.active.id;
|
|
3520
3577
|
if (conversation.messages[conversationId].loading) return;
|
|
3521
|
-
let msgContent = "";
|
|
3578
|
+
let msgContent = "", files;
|
|
3522
3579
|
const references = conversation.messages[conversationId].references;
|
|
3523
3580
|
if (message3) {
|
|
3524
3581
|
msgContent = message3;
|
|
3582
|
+
files = msgFiles;
|
|
3525
3583
|
} else {
|
|
3526
3584
|
if (references?.type === 1 && references?.content?.msgContent) {
|
|
3527
|
-
msgContent = references.content.msgContent + "\n";
|
|
3585
|
+
msgContent = references.content.msgContent + "\n\n";
|
|
3528
3586
|
}
|
|
3529
3587
|
msgContent = msgContent + conversation.messages[conversationId].content;
|
|
3588
|
+
files = conversation.messages[conversationId].files;
|
|
3530
3589
|
}
|
|
3531
3590
|
if (!msgContent) return;
|
|
3532
3591
|
const canProceed = await config.hooks?.onBeforeSend?.(msgContent, files || []);
|
|
@@ -3556,7 +3615,7 @@ function createChatStore() {
|
|
|
3556
3615
|
conversationId,
|
|
3557
3616
|
message: msgContent,
|
|
3558
3617
|
convMeta: config.params.convMeta,
|
|
3559
|
-
files
|
|
3618
|
+
files,
|
|
3560
3619
|
params,
|
|
3561
3620
|
spec: {
|
|
3562
3621
|
...conversation.active.spec,
|
|
@@ -3567,7 +3626,7 @@ function createChatStore() {
|
|
|
3567
3626
|
};
|
|
3568
3627
|
const extraParams = deepCopy(config.params?.params || {});
|
|
3569
3628
|
const userInputParams = variablesToObject(agent.agentInfo.userInput || []);
|
|
3570
|
-
Object.assign(extraParams, userInputParams);
|
|
3629
|
+
Object.assign(extraParams, userInputParams, message3 ? {} : { ...references?.params, params });
|
|
3571
3630
|
sendParams.params = extraParams;
|
|
3572
3631
|
if (!message3) {
|
|
3573
3632
|
setContent("");
|
|
@@ -3673,7 +3732,7 @@ function createChatStore() {
|
|
|
3673
3732
|
}
|
|
3674
3733
|
|
|
3675
3734
|
// src/ui/common/styles.module.less
|
|
3676
|
-
var
|
|
3735
|
+
var styles_module_default3 = {
|
|
3677
3736
|
chatHeader: "styles_module_chatHeader",
|
|
3678
3737
|
chatTitle: "styles_module_chatTitle",
|
|
3679
3738
|
popover: "styles_module_popover",
|
|
@@ -3735,7 +3794,7 @@ var ConversationList_default = () => {
|
|
|
3735
3794
|
children: /* @__PURE__ */ jsx(
|
|
3736
3795
|
Conversations,
|
|
3737
3796
|
{
|
|
3738
|
-
className:
|
|
3797
|
+
className: styles_module_default3.conversations,
|
|
3739
3798
|
items: conversationList,
|
|
3740
3799
|
activeKey: conversationState.active.id,
|
|
3741
3800
|
onActiveChange: async (id) => chatStore.switchConversation(id),
|
|
@@ -3750,17 +3809,17 @@ var ChatHeader_default = ({ title = true, avatar = true, closeBtn = false, newCo
|
|
|
3750
3809
|
const chatStore = useChatStore();
|
|
3751
3810
|
const agentState = useSnapshot(chatStore.agent);
|
|
3752
3811
|
const configState = useSnapshot(chatStore.config);
|
|
3753
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", className:
|
|
3812
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", className: classNames2(styles_module_default3.chatHeader, "zero-chat-header"), children: [
|
|
3754
3813
|
/* @__PURE__ */ jsxs(Flex, { gap: 4, align: "center", children: [
|
|
3755
3814
|
/* @__PURE__ */ jsx(
|
|
3756
3815
|
RenderWrapper,
|
|
3757
3816
|
{
|
|
3758
3817
|
control: avatar,
|
|
3759
|
-
DefaultComponent: /* @__PURE__ */ jsx(Avatar, { size: 22, src: agentState.agentInfo.iconUrl, alt: agentState.agentInfo.name })
|
|
3818
|
+
DefaultComponent: /* @__PURE__ */ jsx(Avatar, { size: 22, src: agentState.agentInfo.iconUrl || getChatCopilotLogo(), alt: agentState.agentInfo.name })
|
|
3760
3819
|
}
|
|
3761
3820
|
),
|
|
3762
3821
|
" ",
|
|
3763
|
-
/* @__PURE__ */ jsx(RenderWrapper, { control: title, DefaultComponent: /* @__PURE__ */ jsx("div", { className:
|
|
3822
|
+
/* @__PURE__ */ jsx(RenderWrapper, { control: title, DefaultComponent: /* @__PURE__ */ jsx("div", { className: styles_module_default3.chatTitle, children: agentState.agentInfo.name }) })
|
|
3764
3823
|
] }),
|
|
3765
3824
|
/* @__PURE__ */ jsxs(Space, { size: 2, children: [
|
|
3766
3825
|
/* @__PURE__ */ jsx(
|
|
@@ -3779,7 +3838,7 @@ var ChatHeader_default = ({ title = true, avatar = true, closeBtn = false, newCo
|
|
|
3779
3838
|
{
|
|
3780
3839
|
getPopupContainer: (e) => e,
|
|
3781
3840
|
placement: "bottom",
|
|
3782
|
-
classNames: { container:
|
|
3841
|
+
classNames: { container: styles_module_default3.popover },
|
|
3783
3842
|
content: /* @__PURE__ */ jsx(ConversationList_default, {}),
|
|
3784
3843
|
trigger: ["click"],
|
|
3785
3844
|
children: /* @__PURE__ */ jsx(Button, { title: "\u5386\u53F2\u4F1A\u8BDD", type: "text", size: "large", icon: /* @__PURE__ */ jsx(CommentOutlined, {}) })
|
|
@@ -3807,7 +3866,7 @@ var ConversationListHeader_default = ({ title = true, avatar = true, newConversa
|
|
|
3807
3866
|
RenderWrapper,
|
|
3808
3867
|
{
|
|
3809
3868
|
control: avatar,
|
|
3810
|
-
DefaultComponent: /* @__PURE__ */ jsx(Avatar, { size: 50, src: agentState.agentInfo?.iconUrl, shape: "square", style: { flexShrink: 0 }, children: (agentState.agentInfo?.name || "AI").slice(0, 1) })
|
|
3869
|
+
DefaultComponent: /* @__PURE__ */ jsx(Avatar, { size: 50, src: agentState.agentInfo?.iconUrl || getChatCopilotLogo(), shape: "square", style: { flexShrink: 0 }, children: (agentState.agentInfo?.name || "AI").slice(0, 1) })
|
|
3811
3870
|
}
|
|
3812
3871
|
),
|
|
3813
3872
|
/* @__PURE__ */ jsx(
|
|
@@ -3815,8 +3874,8 @@ var ConversationListHeader_default = ({ title = true, avatar = true, newConversa
|
|
|
3815
3874
|
{
|
|
3816
3875
|
control: title,
|
|
3817
3876
|
DefaultComponent: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Flex, { vertical: true, gap: 4, flex: 1, style: { minWidth: 0 }, children: [
|
|
3818
|
-
/* @__PURE__ */ jsx(Text2, { strong: true, className:
|
|
3819
|
-
/* @__PURE__ */ jsx(Text2, { type: "secondary", ellipsis: true, className:
|
|
3877
|
+
/* @__PURE__ */ jsx(Text2, { strong: true, className: classNames2("fz-16"), children: agentState.agentInfo.name }),
|
|
3878
|
+
/* @__PURE__ */ jsx(Text2, { type: "secondary", ellipsis: true, className: classNames2("fz-12"), children: agentState.agentInfo.description })
|
|
3820
3879
|
] }) })
|
|
3821
3880
|
}
|
|
3822
3881
|
)
|
|
@@ -3831,7 +3890,7 @@ var ConversationListHeader_default = ({ title = true, avatar = true, newConversa
|
|
|
3831
3890
|
block: true,
|
|
3832
3891
|
type: "primary",
|
|
3833
3892
|
onClick: () => chatStore.createConversation(),
|
|
3834
|
-
className:
|
|
3893
|
+
className: classNames2(styles_module_default3.createConversationButton),
|
|
3835
3894
|
icon: /* @__PURE__ */ jsx(PlusOutlined, {}),
|
|
3836
3895
|
children: "\u65B0\u5EFA\u4F1A\u8BDD"
|
|
3837
3896
|
}
|
|
@@ -3841,7 +3900,7 @@ var ConversationListHeader_default = ({ title = true, avatar = true, newConversa
|
|
|
3841
3900
|
] });
|
|
3842
3901
|
};
|
|
3843
3902
|
var ConversationListPanel = ({ header }) => {
|
|
3844
|
-
return /* @__PURE__ */ jsxs(Flex, { vertical: true, className:
|
|
3903
|
+
return /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames2("height-full", "zero-chat-conversations", styles_module_default3.conversationListPanel), children: [
|
|
3845
3904
|
/* @__PURE__ */ jsx(RenderWrapper, { control: header, DefaultComponent: ConversationListHeader_default }),
|
|
3846
3905
|
/* @__PURE__ */ jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsx(ConversationList_default, {}) })
|
|
3847
3906
|
] });
|
|
@@ -3856,13 +3915,19 @@ var WelcomeItem_default = ({ icon = true, title = true, description = true, prom
|
|
|
3856
3915
|
description: item
|
|
3857
3916
|
}));
|
|
3858
3917
|
}, [agentState.agentInfo?.config?.onboarding?.guiding]);
|
|
3859
|
-
return /* @__PURE__ */ jsxs(Flex, { vertical: true, justify: "center", className:
|
|
3918
|
+
return /* @__PURE__ */ jsxs(Flex, { vertical: true, justify: "center", className: styles_module_default3.chatWelcomeWrap, children: [
|
|
3860
3919
|
/* @__PURE__ */ jsx(
|
|
3861
3920
|
Welcome,
|
|
3862
3921
|
{
|
|
3863
|
-
className:
|
|
3922
|
+
className: classNames2(styles_module_default3.chatWelcome, "p-t-32"),
|
|
3864
3923
|
variant: "borderless",
|
|
3865
|
-
icon: /* @__PURE__ */ jsx(
|
|
3924
|
+
icon: /* @__PURE__ */ jsx(
|
|
3925
|
+
RenderWrapper,
|
|
3926
|
+
{
|
|
3927
|
+
control: icon,
|
|
3928
|
+
DefaultComponent: /* @__PURE__ */ jsx(Avatar, { shape: "square", size: 58, src: agentState.agentInfo?.iconUrl || getChatCopilotLogo() })
|
|
3929
|
+
}
|
|
3930
|
+
),
|
|
3866
3931
|
title: /* @__PURE__ */ jsx(RenderWrapper, { control: title, DefaultComponent: `\u4F60\u597D\uFF0C\u6211\u662F${agentState.agentInfo?.name || ""}` }),
|
|
3867
3932
|
description: /* @__PURE__ */ jsx(
|
|
3868
3933
|
RenderWrapper,
|
|
@@ -3880,7 +3945,7 @@ var WelcomeItem_default = ({ icon = true, title = true, description = true, prom
|
|
|
3880
3945
|
DefaultComponent: /* @__PURE__ */ jsx(
|
|
3881
3946
|
Prompts,
|
|
3882
3947
|
{
|
|
3883
|
-
className:
|
|
3948
|
+
className: classNames2("m-t-16", styles_module_default3.promptItem),
|
|
3884
3949
|
wrap: true,
|
|
3885
3950
|
onItemClick: (info) => chatStore.sendMessage(info.data.description),
|
|
3886
3951
|
items: recommendQuestions
|
|
@@ -4036,28 +4101,34 @@ var BubbleListItems_default = ({
|
|
|
4036
4101
|
}, [agentActions, chatStore, conversationMessages, conversationRoles, conversationState.active.id, isDebug, isWorkFlow]);
|
|
4037
4102
|
const firstMessagesRecord = useMemo(() => {
|
|
4038
4103
|
return (firstMessages || []).map((firstMessage, index) => {
|
|
4039
|
-
const {
|
|
4040
|
-
const roleObj = getRole(
|
|
4104
|
+
const { member, content, contentRender, ...args } = firstMessage;
|
|
4105
|
+
const roleObj = getRole(member);
|
|
4041
4106
|
return {
|
|
4042
4107
|
key: `firstMessage-${index}`,
|
|
4043
4108
|
role: roleObj.user,
|
|
4044
4109
|
placement: roleObj.placement,
|
|
4045
4110
|
avatar: roleObj.avatar,
|
|
4111
|
+
styles: {
|
|
4112
|
+
body: {
|
|
4113
|
+
width: "auto"
|
|
4114
|
+
}
|
|
4115
|
+
},
|
|
4046
4116
|
variant: "borderless",
|
|
4047
|
-
...args
|
|
4117
|
+
...args,
|
|
4118
|
+
content: contentRender ? contentRender({ index, member }) : content
|
|
4048
4119
|
};
|
|
4049
4120
|
});
|
|
4050
4121
|
}, [firstMessages, conversationRoles]);
|
|
4051
4122
|
const welcomeMessageRecord = useMemo(() => {
|
|
4052
|
-
|
|
4053
|
-
return [
|
|
4123
|
+
const isExist = shouldRender(welcomeMessage);
|
|
4124
|
+
return isExist ? [
|
|
4054
4125
|
{
|
|
4055
4126
|
key: "welcome-message",
|
|
4056
|
-
content: /* @__PURE__ */ jsx(
|
|
4127
|
+
content: /* @__PURE__ */ jsx(RenderWrapper, { control: welcomeMessage, DefaultComponent: WelcomeItem_default }),
|
|
4057
4128
|
variant: "borderless"
|
|
4058
4129
|
}
|
|
4059
|
-
];
|
|
4060
|
-
}, [welcomeMessage]);
|
|
4130
|
+
] : [];
|
|
4131
|
+
}, [welcomeMessage, agentState.agentInfo.id]);
|
|
4061
4132
|
const bubbleListItems = useMemo(() => {
|
|
4062
4133
|
const list = [];
|
|
4063
4134
|
list.push(...firstMessagesRecord);
|
|
@@ -4101,7 +4172,7 @@ var BubbleListItems_default = ({
|
|
|
4101
4172
|
autoScroll: false,
|
|
4102
4173
|
ref: listRef,
|
|
4103
4174
|
items: bubbleListItems,
|
|
4104
|
-
className:
|
|
4175
|
+
className: classNames2(styles_module_default3.bubbleList, "height-full", "scroll-fade-in"),
|
|
4105
4176
|
onScroll: handleScroll
|
|
4106
4177
|
},
|
|
4107
4178
|
conversationState.active.id
|
|
@@ -4148,9 +4219,9 @@ window._iconfont_svg_string_5021436 = '<svg><symbol id="icon-MiniMax" viewBox="0
|
|
|
4148
4219
|
}
|
|
4149
4220
|
})(window);
|
|
4150
4221
|
|
|
4151
|
-
// src/components/
|
|
4222
|
+
// src/components/IconFont/index.ts
|
|
4152
4223
|
var IconFont = createFromIconfontCN({});
|
|
4153
|
-
var
|
|
4224
|
+
var IconFont_default = IconFont;
|
|
4154
4225
|
var { Text: Text4 } = Typography;
|
|
4155
4226
|
var FeaturesRenderer_default = ({ skillsBtn, knowledgeBtn }) => {
|
|
4156
4227
|
const chatStore = useChatStore();
|
|
@@ -4159,10 +4230,10 @@ var FeaturesRenderer_default = ({ skillsBtn, knowledgeBtn }) => {
|
|
|
4159
4230
|
/* @__PURE__ */ jsxs(
|
|
4160
4231
|
Flex,
|
|
4161
4232
|
{
|
|
4162
|
-
className:
|
|
4233
|
+
className: classNames2(styles_module_default3.resourceBtn, { [styles_module_default3.resourceBtnActive]: agentState.model.reasoning }),
|
|
4163
4234
|
onClick: () => chatStore.setAgentModel({ ...agentState.model, reasoning: !agentState.model.reasoning }),
|
|
4164
4235
|
children: [
|
|
4165
|
-
/* @__PURE__ */ jsx(
|
|
4236
|
+
/* @__PURE__ */ jsx(IconFont_default, { type: "icon-remark" }),
|
|
4166
4237
|
/* @__PURE__ */ jsx(Text4, { style: { color: agentState.model.reasoning ? "#fff" : "#000" }, children: "\u6DF1\u5EA6\u601D\u8003" })
|
|
4167
4238
|
]
|
|
4168
4239
|
}
|
|
@@ -4174,10 +4245,10 @@ var FeaturesRenderer_default = ({ skillsBtn, knowledgeBtn }) => {
|
|
|
4174
4245
|
DefaultComponent: /* @__PURE__ */ jsxs(
|
|
4175
4246
|
Flex,
|
|
4176
4247
|
{
|
|
4177
|
-
className:
|
|
4248
|
+
className: classNames2(styles_module_default3.resourceBtn, { [styles_module_default3.resourceBtnActive]: agentState.model.reasoning }),
|
|
4178
4249
|
onClick: () => chatStore.setAgentModel({ ...agentState.model, reasoning: !agentState.model.reasoning }),
|
|
4179
4250
|
children: [
|
|
4180
|
-
/* @__PURE__ */ jsx(
|
|
4251
|
+
/* @__PURE__ */ jsx(IconFont_default, { type: "icon-remark" }),
|
|
4181
4252
|
/* @__PURE__ */ jsx(Text4, { style: { color: agentState.model.reasoning ? "#fff" : "#000" }, children: "\u6280\u80FD" })
|
|
4182
4253
|
]
|
|
4183
4254
|
}
|
|
@@ -4191,10 +4262,10 @@ var FeaturesRenderer_default = ({ skillsBtn, knowledgeBtn }) => {
|
|
|
4191
4262
|
DefaultComponent: /* @__PURE__ */ jsxs(
|
|
4192
4263
|
Flex,
|
|
4193
4264
|
{
|
|
4194
|
-
className:
|
|
4265
|
+
className: classNames2(styles_module_default3.resourceBtn, { [styles_module_default3.resourceBtnActive]: agentState.model.reasoning }),
|
|
4195
4266
|
onClick: () => chatStore.setAgentModel({ ...agentState.model, reasoning: !agentState.model.reasoning }),
|
|
4196
4267
|
children: [
|
|
4197
|
-
/* @__PURE__ */ jsx(
|
|
4268
|
+
/* @__PURE__ */ jsx(IconFont_default, { type: "icon-remark" }),
|
|
4198
4269
|
/* @__PURE__ */ jsx(Text4, { style: { color: agentState.model.reasoning ? "#fff" : "#000" }, children: "\u77E5\u8BC6\u5E93" })
|
|
4199
4270
|
]
|
|
4200
4271
|
}
|
|
@@ -4260,8 +4331,8 @@ var ChatSender_default2 = forwardRef(
|
|
|
4260
4331
|
open: !!referenceContent,
|
|
4261
4332
|
onOpenChange: () => chatStore.setReferences(),
|
|
4262
4333
|
classNames: {
|
|
4263
|
-
header:
|
|
4264
|
-
content: shouldRender(referencesBtn) ? "" :
|
|
4334
|
+
header: styles_module_default3.senderReferenceHeaderTitle,
|
|
4335
|
+
content: shouldRender(referencesBtn) ? "" : styles_module_default3.senderReferenceHeaderContent
|
|
4265
4336
|
},
|
|
4266
4337
|
children: /* @__PURE__ */ jsx(
|
|
4267
4338
|
RenderWrapper,
|
|
@@ -4279,20 +4350,17 @@ var ChatSender_default2 = forwardRef(
|
|
|
4279
4350
|
) });
|
|
4280
4351
|
}
|
|
4281
4352
|
);
|
|
4282
|
-
|
|
4283
|
-
// src/assets/images/logo.png
|
|
4284
|
-
var logo_default = "./logo-BX4TAWHK.png";
|
|
4285
4353
|
var ChatSenderHeader = () => {
|
|
4286
|
-
return /* @__PURE__ */ jsxs("div", { className:
|
|
4287
|
-
/* @__PURE__ */ jsxs("div", { className:
|
|
4288
|
-
/* @__PURE__ */ jsx("div", { className:
|
|
4289
|
-
/* @__PURE__ */ jsx("div", { className:
|
|
4354
|
+
return /* @__PURE__ */ jsxs("div", { className: styles_module_default3.logoArea, children: [
|
|
4355
|
+
/* @__PURE__ */ jsxs("div", { className: styles_module_default3.logoContainer, children: [
|
|
4356
|
+
/* @__PURE__ */ jsx("div", { className: styles_module_default3.staticHalo }),
|
|
4357
|
+
/* @__PURE__ */ jsx("div", { className: styles_module_default3.logoHoverWrapper, children: /* @__PURE__ */ jsx("img", { src: getChatCopilotLogo(), alt: "LoLR.AI Logo", className: styles_module_default3.logoImage }) })
|
|
4290
4358
|
] }),
|
|
4291
|
-
/* @__PURE__ */ jsxs("h1", { className:
|
|
4359
|
+
/* @__PURE__ */ jsxs("h1", { className: styles_module_default3.greetingTitle, children: [
|
|
4292
4360
|
"\u4F60\u597D\uFF0C\u6211\u662F ",
|
|
4293
|
-
/* @__PURE__ */ jsx("span", { className:
|
|
4361
|
+
/* @__PURE__ */ jsx("span", { className: styles_module_default3.gradientText, children: "LoLR.AI" })
|
|
4294
4362
|
] }),
|
|
4295
|
-
/* @__PURE__ */ jsx("p", { className:
|
|
4363
|
+
/* @__PURE__ */ jsx("p", { className: styles_module_default3.greetingSubtitle, children: "\u4ECA\u5929\u60F3\u63A2\u7D22\u70B9\u4EC0\u4E48\uFF1F" })
|
|
4296
4364
|
] });
|
|
4297
4365
|
};
|
|
4298
4366
|
var ChatSenderHeader_default = ChatSenderHeader;
|
|
@@ -4330,7 +4398,7 @@ var MonacoEditor = ({ value = "", onChange, placeholder, height = 200, readOnly
|
|
|
4330
4398
|
}
|
|
4331
4399
|
) });
|
|
4332
4400
|
};
|
|
4333
|
-
var
|
|
4401
|
+
var MonacoEditor_default = MonacoEditor;
|
|
4334
4402
|
var { Text: Text5 } = Typography;
|
|
4335
4403
|
var START_NODE_TYPE = "start";
|
|
4336
4404
|
var FormFileUpload = ({ value, onChange, multiple = false }) => {
|
|
@@ -4414,7 +4482,7 @@ var FormFileUpload = ({ value, onChange, multiple = false }) => {
|
|
|
4414
4482
|
};
|
|
4415
4483
|
var FormMonacoEditor = ({ value, onChange }) => {
|
|
4416
4484
|
const { token } = theme.useToken();
|
|
4417
|
-
return /* @__PURE__ */ jsx("div", { style: { backgroundColor: token.colorFillAlter, padding: 8, borderRadius: token.borderRadius }, children: /* @__PURE__ */ jsx(
|
|
4485
|
+
return /* @__PURE__ */ jsx("div", { style: { backgroundColor: token.colorFillAlter, padding: 8, borderRadius: token.borderRadius }, children: /* @__PURE__ */ jsx(MonacoEditor_default, { language: "json", placeholder: "\u8BF7\u8F93\u5165\u503C...", height: 80, value, onChange }) });
|
|
4418
4486
|
};
|
|
4419
4487
|
var UserInputPanel = () => {
|
|
4420
4488
|
const chatStore = useChatStore();
|
|
@@ -4591,12 +4659,12 @@ var UserInputPanel = () => {
|
|
|
4591
4659
|
label: "\u53C2\u6570\u8BBE\u7F6E",
|
|
4592
4660
|
extra: genExtra(),
|
|
4593
4661
|
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4594
|
-
/* @__PURE__ */ jsx(Form, { form, layout: "vertical", onValuesChange: handleValuesChange, style: { maxHeight: 500, overflow: "auto", paddingRight: 16 }, children: inputs.length > 0 ? /* @__PURE__ */ jsx(Flex, { vertical: true, gap: 12, children: inputs.map((item) => /* @__PURE__ */ jsx(
|
|
4662
|
+
/* @__PURE__ */ jsx(Form, { form, layout: "vertical", onValuesChange: handleValuesChange, style: { maxHeight: 500, overflow: "auto", paddingRight: 16 }, children: inputs.length > 0 ? /* @__PURE__ */ jsx(Flex, { vertical: true, gap: 12, children: inputs.map((item) => /* @__PURE__ */ jsx(React7.Fragment, { children: renderFormItem(item) }, item.name)) }) : /* @__PURE__ */ jsx("div", { style: { padding: "10px", color: "#999", textAlign: "center" }, children: "\u6682\u65E0\u7528\u6237\u8F93\u5165\u5B57\u6BB5" }) }),
|
|
4595
4663
|
/* @__PURE__ */ jsx(Flex, { align: "center", justify: "center", className: "m-t-16", children: /* @__PURE__ */ jsx(Button, { type: "primary", onClick: handleStartChat, children: "\u5F00\u59CB\u4F1A\u8BDD" }) })
|
|
4596
4664
|
] })
|
|
4597
4665
|
}
|
|
4598
4666
|
];
|
|
4599
|
-
return /* @__PURE__ */ jsx("div", { className:
|
|
4667
|
+
return /* @__PURE__ */ jsx("div", { className: styles_module_default3.userInputCollapse, children: /* @__PURE__ */ jsx(
|
|
4600
4668
|
Collapse,
|
|
4601
4669
|
{
|
|
4602
4670
|
activeKey,
|
|
@@ -4618,7 +4686,7 @@ var UserInputPanel = () => {
|
|
|
4618
4686
|
var UserInputPanel_default = UserInputPanel;
|
|
4619
4687
|
|
|
4620
4688
|
// src/ui/layouts/components/styles.module.less
|
|
4621
|
-
var
|
|
4689
|
+
var styles_module_default4 = {
|
|
4622
4690
|
bodyWidth: "styles_module_bodyWidth",
|
|
4623
4691
|
inputContainer: "styles_module_inputContainer",
|
|
4624
4692
|
disclaimerNotice: "styles_module_disclaimerNotice",
|
|
@@ -4642,19 +4710,19 @@ var ChatMainPanel = memo(
|
|
|
4642
4710
|
);
|
|
4643
4711
|
const configState = useSnapshot(chatStore.config);
|
|
4644
4712
|
const agentState = useSnapshot(chatStore.agent);
|
|
4645
|
-
return /* @__PURE__ */ jsxs(Flex, { vertical: true, className:
|
|
4713
|
+
return /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames2("height-full"), children: [
|
|
4646
4714
|
/* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.chatHeader, DefaultComponent: ChatHeader_default }),
|
|
4647
|
-
/* @__PURE__ */ jsxs(Flex, { justify: "center", align: "center", vertical: true, gap: 24, className:
|
|
4715
|
+
/* @__PURE__ */ jsxs(Flex, { justify: "center", align: "center", vertical: true, gap: 24, className: classNames2("height-full", styles_module_default4.bodyWidth), children: [
|
|
4648
4716
|
shouldRender(agentState.agentInfo.userInput && agentState.agentInfo.userInput.length > 0) && /* @__PURE__ */ jsx(RenderWrapper, { DefaultComponent: UserInputPanel_default }),
|
|
4649
4717
|
shouldRender(configState.layout.messageList) && /* @__PURE__ */ jsx("div", { className: "full-scroll", style: { width: "100%" }, children: /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.messageList, DefaultComponent: BubbleListItems_default }) }),
|
|
4650
4718
|
/* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.senderHeader, DefaultComponent: /* @__PURE__ */ jsx(ChatSenderHeader_default, {}) }),
|
|
4651
|
-
/* @__PURE__ */ jsxs(Flex, { className:
|
|
4719
|
+
/* @__PURE__ */ jsxs(Flex, { className: styles_module_default4.inputContainer, vertical: true, gap: 8, children: [
|
|
4652
4720
|
/* @__PURE__ */ jsx(RenderWrapper, { ref: senderRef, DefaultComponent: ChatSender_default2 }),
|
|
4653
4721
|
/* @__PURE__ */ jsx(
|
|
4654
4722
|
RenderWrapper,
|
|
4655
4723
|
{
|
|
4656
4724
|
control: configState.layout.disclaimerNotice,
|
|
4657
|
-
DefaultComponent: /* @__PURE__ */ jsx("div", { className:
|
|
4725
|
+
DefaultComponent: /* @__PURE__ */ jsx("div", { className: styles_module_default4.disclaimerNotice, children: "\u5185\u5BB9\u7531AI\u751F\u6210\uFF0C\u4EC5\u4F9B\u53C2\u8003\uFF0C\u8BF7\u4ED4\u7EC6\u7504\u522B" })
|
|
4658
4726
|
}
|
|
4659
4727
|
),
|
|
4660
4728
|
/* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.senderFooter })
|
|
@@ -4664,6 +4732,7 @@ var ChatMainPanel = memo(
|
|
|
4664
4732
|
})
|
|
4665
4733
|
);
|
|
4666
4734
|
var ChatMainPanel_default = ChatMainPanel;
|
|
4735
|
+
var { Text: Text6 } = Typography;
|
|
4667
4736
|
var ChatPreviewPanel = memo(({ agentId, conversationId, file }) => {
|
|
4668
4737
|
const chatStore = useChatStore();
|
|
4669
4738
|
const configState = useSnapshot(chatStore.config);
|
|
@@ -4690,11 +4759,14 @@ var ChatPreviewPanel = memo(({ agentId, conversationId, file }) => {
|
|
|
4690
4759
|
}
|
|
4691
4760
|
};
|
|
4692
4761
|
return /* @__PURE__ */ jsxs(Flex, { vertical: true, style: { height: "100%", overflow: "hidden" }, children: [
|
|
4693
|
-
/* @__PURE__ */ jsxs(Flex, { justify: "
|
|
4694
|
-
|
|
4695
|
-
/* @__PURE__ */
|
|
4762
|
+
/* @__PURE__ */ jsxs(Flex, { justify: "space-between", className: styles_module_default4.previewHeader, children: [
|
|
4763
|
+
/* @__PURE__ */ jsx(Text6, { strong: true, children: file?.fileName || file?.path || "" }),
|
|
4764
|
+
/* @__PURE__ */ jsxs(Flex, { children: [
|
|
4765
|
+
file?.path && /* @__PURE__ */ jsx("div", { className: styles_module_default4.previewCloseBtn, onClick: handleDownload, children: /* @__PURE__ */ jsx(Button, { type: "text", icon: /* @__PURE__ */ jsx(DownloadOutlined, {}), className: styles_module_default4.closeIcon }) }),
|
|
4766
|
+
/* @__PURE__ */ jsx("div", { className: classNames2(styles_module_default4.previewCloseBtn, styles_module_default4.rotateIcon), onClick: () => chatStore.setPreview({ path: "", fileName: "" }), children: /* @__PURE__ */ jsx(Button, { type: "text", icon: /* @__PURE__ */ jsx(CloseOutlined, {}), className: styles_module_default4.closeIcon }) })
|
|
4767
|
+
] })
|
|
4696
4768
|
] }),
|
|
4697
|
-
/* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsx(
|
|
4769
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsx(LuyaFilePreview, { fileUrl, suffix }) })
|
|
4698
4770
|
] });
|
|
4699
4771
|
});
|
|
4700
4772
|
var ChatPreviewPanel_default = ChatPreviewPanel;
|
|
@@ -4800,12 +4872,12 @@ var layouts_default = forwardRef(({ theme: theme4, params, hooks, layout, config
|
|
|
4800
4872
|
useEffect(() => {
|
|
4801
4873
|
hooks?.onBeforeInit?.();
|
|
4802
4874
|
}, []);
|
|
4803
|
-
return /* @__PURE__ */ jsx(XProvider, { theme: { cssVar: {}, ...theme4 }, children: /* @__PURE__ */ jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsx(Spin, { spinning: configState.loading, classNames: { root: index_module_default2.spinWrapper }, children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className:
|
|
4875
|
+
return /* @__PURE__ */ jsx(XProvider, { theme: { cssVar: {}, ...theme4 }, children: /* @__PURE__ */ jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsx(Spin, { spinning: configState.loading, classNames: { root: index_module_default2.spinWrapper }, children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames2(index_module_default2.chatLayout, "zero-chat-layout", "height-full"), children: [
|
|
4804
4876
|
/* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.globalHeader, DefaultComponent: ChatHeader_default }),
|
|
4805
4877
|
/* @__PURE__ */ jsxs(Flex, { ref: containerRef, className: "full-scroll", children: [
|
|
4806
4878
|
/* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.leftPanel }),
|
|
4807
4879
|
/* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.conversationList, DefaultComponent: ConversationListPanel_default }),
|
|
4808
|
-
/* @__PURE__ */ jsxs(Splitter, { className:
|
|
4880
|
+
/* @__PURE__ */ jsxs(Splitter, { className: classNames2("flex-1", index_module_default2.animatedSplitter, { [index_module_default2.hideSplitterBar]: !hasPreView }), children: [
|
|
4809
4881
|
/* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, max: 800, min: 400, size: sizes[1], children: /* @__PURE__ */ jsx(ChatMainPanel_default, { ref: senderRef }) }),
|
|
4810
4882
|
/* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, min: 600, size: sizes[0], children: /* @__PURE__ */ jsx(
|
|
4811
4883
|
ChatPreviewPanel_default,
|