@zero-library/chat-copilot 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -503,13 +503,6 @@ function createChatStore() {
503
503
  const getModels = async () => {
504
504
  const { data } = await config.services.request.fetchModelList();
505
505
  config.models = data;
506
- if (data?.length) {
507
- setAgentModel({
508
- providerName: data[0].providerName,
509
- modelName: data[0].models[0].modelName,
510
- reasoning: true
511
- });
512
- }
513
506
  };
514
507
  const setServices = ({ http, websocket } = {}) => {
515
508
  const httpConfig = { baseURL: "/luya/v1", headers: { [TOKEN_KEY]: tokenManager.get() }, ...http?.config };
@@ -590,7 +583,7 @@ function createChatStore() {
590
583
  loading: false
591
584
  });
592
585
  const setAgentModel = (model) => {
593
- agent.model = model;
586
+ agent.model = { ...agent.model, ...model };
594
587
  };
595
588
  const getUserInput = async (agentId) => {
596
589
  agent.loading = true;
@@ -605,6 +598,12 @@ function createChatStore() {
605
598
  };
606
599
  const setAgent = (agentInfo) => {
607
600
  agent.agentInfo = agentInfo;
601
+ if (agentInfo.agentType === 2 /* AUTONOMOUS */) {
602
+ setAgentModel({
603
+ modelName: agent.agentInfo.spec?.model?.modelName || "",
604
+ providerName: agent.agentInfo.spec?.model?.providerName || ""
605
+ });
606
+ }
608
607
  };
609
608
  const setUserInput = (userInput) => {
610
609
  if (config.params?.convMeta?.mode === CONV_MODE.PROD && agent.agentInfo.agentType === 1 /* FLOW */) {
@@ -619,6 +618,12 @@ function createChatStore() {
619
618
  try {
620
619
  const { data } = await config.services.request.fetchAgentInfo(id || "");
621
620
  agent.agentInfo = data;
621
+ if (agent.agentInfo.agentType === 2 /* AUTONOMOUS */) {
622
+ setAgentModel({
623
+ modelName: agent.agentInfo.spec?.model?.modelName || "",
624
+ providerName: agent.agentInfo.spec?.model?.providerName || ""
625
+ });
626
+ }
622
627
  config.hooks?.onAfterSwitchAgent?.(data);
623
628
  } finally {
624
629
  config.loading = false;
@@ -1155,7 +1160,7 @@ function createChatStore() {
1155
1160
  messages.push(finalMsg);
1156
1161
  } else {
1157
1162
  const prevContent = messages[idx]?.content || [];
1158
- messages[idx].content = [...prevContent, newMessage.content[0]];
1163
+ messages[idx].content = [...prevContent, ...newMessage.content];
1159
1164
  }
1160
1165
  conversation.messages[newMessage.conversationId].loading = true;
1161
1166
  break;
@@ -1940,7 +1945,10 @@ var styles_module_default3 = {
1940
1945
  fileEdit: "styles_module_fileEdit",
1941
1946
  fileEditHeader: "styles_module_fileEditHeader",
1942
1947
  fileEditContent: "styles_module_fileEditContent",
1943
- mdEdit: "styles_module_mdEdit"
1948
+ mdEdit: "styles_module_mdEdit",
1949
+ chart: "styles_module_chart",
1950
+ chartSkeleton: "styles_module_chartSkeleton",
1951
+ chartSkeletonIcon: "styles_module_chartSkeletonIcon"
1944
1952
  };
1945
1953
  var AppCard_default = ({ data, loading }) => {
1946
1954
  const chatStore = useChatStore();
@@ -1958,6 +1966,65 @@ var AppCard_default = ({ data, loading }) => {
1958
1966
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ellipsis", title: data.appName, children: data.appName })
1959
1967
  ] }) });
1960
1968
  };
1969
+ var chartTypes = [
1970
+ "Line",
1971
+ "Column",
1972
+ "Bar",
1973
+ "Area",
1974
+ "Pie",
1975
+ "DualAxes",
1976
+ "Scatter",
1977
+ "WordCloud",
1978
+ "Funnel",
1979
+ "Heatmap",
1980
+ "Histogram",
1981
+ "Liquid",
1982
+ "BidirectionalBar",
1983
+ "Box",
1984
+ "Bullet",
1985
+ "CirclePacking",
1986
+ "Gauge",
1987
+ "Radar",
1988
+ "Rose",
1989
+ "Sankey",
1990
+ "Stock",
1991
+ "Sunburst",
1992
+ "Treemap",
1993
+ "Venn",
1994
+ "Waterfall",
1995
+ "MindMap",
1996
+ "Fishbone",
1997
+ "IndentedTree",
1998
+ "Dendrogram",
1999
+ "OrganizationChart",
2000
+ "FlowGraph",
2001
+ "FlowDirectionGraph",
2002
+ "NetworkGraph"
2003
+ // …如果还有其他图表也继续加
2004
+ ];
2005
+ var CHART_COMPONENTS = Object.fromEntries(
2006
+ chartTypes.map((type) => [
2007
+ type,
2008
+ () => import('@ant-design/charts').then((mod) => ({
2009
+ default: mod[type]
2010
+ }))
2011
+ ])
2012
+ );
2013
+ var Charts_default = ({ data, loading }) => {
2014
+ const { type, config } = data;
2015
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames2__default.default(styles_module_default3.chart, "scroll-fade-in"), children: loading ? (
2016
+ // Antd 骨架屏
2017
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Skeleton.Node, { active: true, className: styles_module_default3.chartSkeleton, children: /* @__PURE__ */ jsxRuntime.jsx(icons.DotChartOutlined, { className: styles_module_default3.chartSkeletonIcon }) })
2018
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
2019
+ common.LazyComponent,
2020
+ {
2021
+ type,
2022
+ ...config,
2023
+ customComponents: CHART_COMPONENTS,
2024
+ unknownContent: /* @__PURE__ */ jsxRuntime.jsx(antd.Alert, { title: "\u4E0D\u652F\u6301\u7684\u56FE\u8868", description: `\u5F53\u524D\u56FE\u8868\u7C7B\u578B "${type}" \u6682\u672A\u5B9E\u73B0\uFF0C\u8BF7\u68C0\u67E5\u56FE\u8868\u7C7B\u578B\u662F\u5426\u6B63\u786E\u3002`, type: "warning", showIcon: true })
2025
+ }
2026
+ ) });
2027
+ };
1961
2028
  var CodeHighlight_default = ({ className, data }) => {
1962
2029
  const lang = className?.match(/language-(\w+)/)?.[1] || "";
1963
2030
  if (typeof data !== "string") return null;
@@ -2009,6 +2076,44 @@ var FileView_default = ({ data, loading }) => {
2009
2076
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ellipsis", title: data.fileName, children: data.fileName })
2010
2077
  ] }) });
2011
2078
  };
2079
+ var DocDrawer_default = ({ title, open, onClose, paramsStr }) => {
2080
+ const chatStore = useChatStore();
2081
+ valtio.useSnapshot(chatStore.config);
2082
+ const [content, setContent] = React6.useState("");
2083
+ const [loading, setLoading] = React6.useState(false);
2084
+ const getContent = async () => {
2085
+ try {
2086
+ setLoading(true);
2087
+ setContent("");
2088
+ } finally {
2089
+ setLoading(false);
2090
+ }
2091
+ };
2092
+ React6.useEffect(() => {
2093
+ getContent();
2094
+ }, [paramsStr]);
2095
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Drawer, { title, push: false, size: "100%", open, onClose, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, children: content ? /* @__PURE__ */ jsxRuntime.jsx(XMarkdown__default.default, { content }) : /* @__PURE__ */ jsxRuntime.jsx(antd.Empty, { className: "m-t-32" }) }) });
2096
+ };
2097
+ var IndexQuote_default = ({ data, loading, message: message3 }) => {
2098
+ const [open, setOpen] = React6.useState(false);
2099
+ const citation = React6.useMemo(() => {
2100
+ const citations = message3.content?.find((item) => item.type === "citation")?.citations ?? [];
2101
+ return citations?.find((item) => String(item.citationId) === String(data.citationId));
2102
+ }, [data.citationId, message3.content]);
2103
+ const onClick = () => {
2104
+ if (!citation?.citationUrl) return;
2105
+ if (common.isExternal(citation.citationUrl)) {
2106
+ window.open(citation.citationUrl, "_blank");
2107
+ } else {
2108
+ setOpen(true);
2109
+ }
2110
+ };
2111
+ const Content = /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { align: "center", gap: 8, children: /* @__PURE__ */ jsxRuntime.jsx("a", { onClick, children: citation?.citationName }) }) });
2112
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "inline-block m-l-8", children: [
2113
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Popover, { content: Content, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Tag, { variant: "filled", color: "processing", className: "cursor-pointer", children: data?.citationName }) }) }),
2114
+ open && /* @__PURE__ */ jsxRuntime.jsx(DocDrawer_default, { paramsStr: citation?.citationUrl, title: citation?.citationName, open, onClose: () => setOpen(false) })
2115
+ ] });
2116
+ };
2012
2117
  var MdEdit_default = ({ data, loading }) => {
2013
2118
  const chatStore = useChatStore();
2014
2119
  const [value, setValue] = React6.useState("");
@@ -2066,6 +2171,9 @@ var PreviewLink_default = ({ data, loading, domNode, ...rest }) => {
2066
2171
  };
2067
2172
  return /* @__PURE__ */ jsxRuntime.jsx("a", { ...rest, onClick: handleClick, children: data });
2068
2173
  };
2174
+ var Think_default = ({ data }) => {
2175
+ return /* @__PURE__ */ jsxRuntime.jsx(xV2.Think, { title: "\u6DF1\u5EA6\u601D\u8003", className: "m-b-16", children: data });
2176
+ };
2069
2177
 
2070
2178
  // src/components/XMarkdown/styles.module.less
2071
2179
  var styles_module_default4 = {
@@ -2113,12 +2221,14 @@ var XMarkdown_default = ({ message: message3, components, content, ...rest }) =>
2113
2221
  const markdownComponents = React6.useMemo(
2114
2222
  () => adaptMarkdownComponents(
2115
2223
  {
2224
+ think: Think_default,
2116
2225
  code: CodeHighlight_default,
2117
2226
  agentnavigate: AgentNavigate_default,
2118
2227
  a: PreviewLink_default,
2119
2228
  appcard: AppCard_default,
2120
2229
  fileview: FileView_default,
2121
- // indexquote: IndexQuote,
2230
+ charts: Charts_default,
2231
+ indexquote: IndexQuote_default,
2122
2232
  mdedit: MdEdit_default,
2123
2233
  fileedit: FileEdit_default,
2124
2234
  ...components
@@ -2489,7 +2599,7 @@ var Button7 = ({ label, variant = "default", onClick, action, onAction }) => {
2489
2599
  return /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: variant === "primary" ? "primary" : "default", danger: variant === "danger", onClick: handleClick, style: { borderRadius: 8 }, children: label });
2490
2600
  };
2491
2601
  var Divider = () => /* @__PURE__ */ jsxRuntime.jsx(antd.Divider, { style: { margin: "8px 0" } });
2492
- var Tag = ({ text, color }) => /* @__PURE__ */ jsxRuntime.jsx(antd.Tag, { color, children: text });
2602
+ var Tag2 = ({ text, color }) => /* @__PURE__ */ jsxRuntime.jsx(antd.Tag, { color, children: text });
2493
2603
  var Progress = ({
2494
2604
  percent,
2495
2605
  status = "normal",
@@ -2507,7 +2617,7 @@ var A2uiComponents = {
2507
2617
  Switch,
2508
2618
  Button: Button7,
2509
2619
  Divider,
2510
- Tag,
2620
+ Tag: Tag2,
2511
2621
  Progress,
2512
2622
  ArtifactCard,
2513
2623
  TableViewer,