@axiom-lattice/react-sdk 2.0.3 → 2.0.4

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.js CHANGED
@@ -33,6 +33,7 @@ var index_exports = {};
33
33
  __export(index_exports, {
34
34
  AxiomLatticeProvider: () => AxiomLatticeProvider,
35
35
  Chating: () => Chating,
36
+ FileExplorer: () => FileExplorer,
36
37
  MDMermaid: () => MDMermaid,
37
38
  MDResponse: () => MDResponse,
38
39
  MDViewFormItem: () => MDViewFormItem,
@@ -124,9 +125,22 @@ function useChat(threadId, options = {}) {
124
125
  }, [options.initialMessages]);
125
126
  const handleStreamEvent = (0, import_react2.useCallback)((chunk) => {
126
127
  chunkMessageMerger.current.push(chunk);
128
+ let todos;
129
+ if (chunk.type === "tool" && chunk.data && typeof chunk.data.content === "string" && chunk.data.content.startsWith("```todo_list")) {
130
+ try {
131
+ const content = chunk.data.content;
132
+ const match = content.match(/```todo_list\s*([\s\S]*?)\s*```/);
133
+ if (match && match[1]) {
134
+ todos = JSON.parse(match[1]);
135
+ }
136
+ } catch (e) {
137
+ console.error("Failed to parse todo list from chunk", e);
138
+ }
139
+ }
127
140
  const updatedMessages = chunkMessageMerger.current.getMessages();
128
141
  setState((prev) => ({
129
142
  ...prev,
143
+ todos: todos || prev.todos,
130
144
  messages: updatedMessages,
131
145
  isLoading: true,
132
146
  streamingMessage: null
@@ -257,14 +271,14 @@ function useChat(threadId, options = {}) {
257
271
  }
258
272
  setState((prev) => ({ ...prev, isLoading: true, error: null }));
259
273
  try {
260
- const fetchedMessages = await client.getMessages({
261
- threadId,
262
- limit
263
- });
274
+ const agentState = await client.getAgentState(threadId);
275
+ const fetchedMessages = await client.getMessages({ threadId });
264
276
  chunkMessageMerger.current.reset();
265
277
  chunkMessageMerger.current.initialMessages(fetchedMessages);
266
278
  setState((prev) => ({
267
279
  ...prev,
280
+ agentState,
281
+ todos: agentState?.values?.todos,
268
282
  messages: chunkMessageMerger.current.getMessages(),
269
283
  isLoading: false
270
284
  }));
@@ -1570,22 +1584,204 @@ var IFrameCard = ({ src }) => {
1570
1584
  };
1571
1585
 
1572
1586
  // src/components/Chat/Chating.tsx
1573
- var import_icons5 = require("@ant-design/icons");
1587
+ var import_icons6 = require("@ant-design/icons");
1574
1588
  var import_x = require("@ant-design/x");
1575
- var import_antd6 = require("antd");
1589
+ var import_antd7 = require("antd");
1576
1590
  var import_ErrorBoundary = __toESM(require("antd/es/alert/ErrorBoundary"));
1577
- var import_react10 = __toESM(require("react"));
1591
+ var import_react11 = __toESM(require("react"));
1578
1592
  var import_react_i18next = require("react-i18next");
1593
+
1594
+ // src/components/FileExplorer.tsx
1595
+ var import_react10 = require("react");
1596
+ var import_antd6 = require("antd");
1597
+ var import_icons5 = require("@ant-design/icons");
1598
+ var import_antd_style5 = require("antd-style");
1579
1599
  var import_jsx_runtime10 = require("react/jsx-runtime");
1600
+ var useStyles2 = (0, import_antd_style5.createStyles)(({ token, css }) => ({
1601
+ container: css`
1602
+ height: 100%;
1603
+ background: ${token.colorBgContainer};
1604
+ border: 1px solid ${token.colorBorder};
1605
+ border-radius: ${token.borderRadiusLG}px;
1606
+ overflow: hidden;
1607
+ display: flex;
1608
+ flex-direction: column;
1609
+ `,
1610
+ tabs: css`
1611
+ height: 100%;
1612
+
1613
+ .ant-tabs-nav {
1614
+ margin-bottom: 0 !important;
1615
+ padding: 0 16px;
1616
+ border-bottom: 1px solid ${token.colorBorderSecondary};
1617
+ }
1618
+
1619
+ .ant-tabs-content-holder {
1620
+ height: 100%;
1621
+ overflow: hidden;
1622
+ }
1623
+
1624
+ .ant-tabs-content {
1625
+ height: 100%;
1626
+ }
1627
+
1628
+ .ant-tabs-tabpane {
1629
+ height: 100%;
1630
+ outline: none;
1631
+ }
1632
+ `,
1633
+ contentBody: css`
1634
+ padding: 24px;
1635
+ height: 100%;
1636
+ overflow-y: auto;
1637
+
1638
+ pre {
1639
+ margin: 0 !important;
1640
+ border-radius: ${token.borderRadius}px !important;
1641
+ }
1642
+ `,
1643
+ emptyState: css`
1644
+ display: flex;
1645
+ flex-direction: column;
1646
+ align-items: center;
1647
+ justify-content: center;
1648
+ height: 100%;
1649
+ color: ${token.colorTextQuaternary};
1650
+ `
1651
+ }));
1652
+ var getFileIcon = (filename) => {
1653
+ const ext = filename.split(".").pop()?.toLowerCase();
1654
+ switch (ext) {
1655
+ case "ts":
1656
+ case "tsx":
1657
+ case "js":
1658
+ case "jsx":
1659
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons5.CodeOutlined, {});
1660
+ case "html":
1661
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons5.Html5Outlined, {});
1662
+ case "css":
1663
+ case "less":
1664
+ case "scss":
1665
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons5.FileUnknownOutlined, {});
1666
+ // Or a style icon if available
1667
+ case "md":
1668
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons5.FileMarkdownOutlined, {});
1669
+ case "json":
1670
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons5.FileTextOutlined, {});
1671
+ case "png":
1672
+ case "jpg":
1673
+ case "jpeg":
1674
+ case "gif":
1675
+ case "svg":
1676
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons5.FileImageOutlined, {});
1677
+ default:
1678
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons5.FileOutlined, {});
1679
+ }
1680
+ };
1681
+ function getLanguageFromFileName(filename) {
1682
+ const ext = filename.split(".").pop()?.toLowerCase();
1683
+ switch (ext) {
1684
+ case "ts":
1685
+ case "tsx":
1686
+ return "typescript";
1687
+ case "js":
1688
+ case "jsx":
1689
+ return "javascript";
1690
+ case "py":
1691
+ return "python";
1692
+ case "md":
1693
+ return "markdown";
1694
+ case "json":
1695
+ return "json";
1696
+ case "html":
1697
+ return "html";
1698
+ case "css":
1699
+ return "css";
1700
+ case "java":
1701
+ return "java";
1702
+ case "go":
1703
+ return "go";
1704
+ case "rs":
1705
+ return "rust";
1706
+ case "c":
1707
+ return "c";
1708
+ case "cpp":
1709
+ return "cpp";
1710
+ case "yaml":
1711
+ case "yml":
1712
+ return "yaml";
1713
+ case "sql":
1714
+ return "sql";
1715
+ case "sh":
1716
+ case "bash":
1717
+ return "bash";
1718
+ default:
1719
+ return "text";
1720
+ }
1721
+ }
1722
+ var FileExplorer = ({
1723
+ files = [],
1724
+ className,
1725
+ style,
1726
+ title = "EXPLORER"
1727
+ }) => {
1728
+ const { styles, cx } = useStyles2();
1729
+ const [fileList, setFileList] = (0, import_react10.useState)([]);
1730
+ (0, import_react10.useEffect)(() => {
1731
+ if (Array.isArray(files)) {
1732
+ setFileList(files);
1733
+ } else {
1734
+ const list = Object.keys(files).map((key) => ({
1735
+ name: key,
1736
+ content: files[key]
1737
+ }));
1738
+ setFileList(list);
1739
+ }
1740
+ }, [files]);
1741
+ const items = (0, import_react10.useMemo)(() => {
1742
+ return fileList.map((file) => {
1743
+ const language = file.language || getLanguageFromFileName(file.name);
1744
+ const content = `\`\`\`${language}
1745
+ ${file.content}
1746
+ \`\`\``;
1747
+ return {
1748
+ key: file.name,
1749
+ label: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
1750
+ getFileIcon(file.name),
1751
+ file.name
1752
+ ] }),
1753
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: styles.contentBody, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(MDResponse, { content }) })
1754
+ };
1755
+ });
1756
+ }, [fileList, styles]);
1757
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: cx(styles.container, className), style, children: fileList.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1758
+ import_antd6.Tabs,
1759
+ {
1760
+ defaultActiveKey: fileList[0]?.name,
1761
+ items,
1762
+ className: styles.tabs,
1763
+ tabBarStyle: { margin: 0 }
1764
+ }
1765
+ ) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: styles.emptyState, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1766
+ import_antd6.Empty,
1767
+ {
1768
+ description: "No file selected",
1769
+ image: import_antd6.Empty.PRESENTED_IMAGE_SIMPLE
1770
+ }
1771
+ ) }) });
1772
+ };
1773
+
1774
+ // src/components/Chat/Chating.tsx
1775
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1580
1776
  var LazyBubble = ({
1581
1777
  message: message2,
1582
1778
  renderContent,
1583
1779
  autoLoadRightPanel
1584
1780
  }) => {
1585
- const ref = (0, import_react10.useRef)(null);
1586
- const [isVisible, setIsVisible] = (0, import_react10.useState)(false);
1587
- const [wasEverVisible, setWasEverVisible] = (0, import_react10.useState)(false);
1588
- (0, import_react10.useEffect)(() => {
1781
+ const ref = (0, import_react11.useRef)(null);
1782
+ const [isVisible, setIsVisible] = (0, import_react11.useState)(false);
1783
+ const [wasEverVisible, setWasEverVisible] = (0, import_react11.useState)(false);
1784
+ (0, import_react11.useEffect)(() => {
1589
1785
  const observer = new IntersectionObserver(
1590
1786
  ([entry]) => {
1591
1787
  const visible = entry.isIntersecting;
@@ -1605,21 +1801,21 @@ var LazyBubble = ({
1605
1801
  }
1606
1802
  };
1607
1803
  }, [wasEverVisible]);
1608
- (0, import_react10.useEffect)(() => {
1804
+ (0, import_react11.useEffect)(() => {
1609
1805
  autoLoadRightPanel?.();
1610
1806
  }, []);
1611
1807
  const getPlaceholder = () => {
1612
1808
  const estimatedHeight = message2.content ? Math.min(100, message2.content.length / 5) : 100;
1613
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { style: { height: `${estimatedHeight}px`, minHeight: "50px" } });
1809
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { height: `${estimatedHeight}px`, minHeight: "50px" } });
1614
1810
  };
1615
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ErrorBoundary.default, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { ref, style: { width: "100%" }, children: isVisible || wasEverVisible ? renderContent(message2) : getPlaceholder() }) });
1811
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ErrorBoundary.default, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { ref, style: { width: "100%" }, children: isVisible || wasEverVisible ? renderContent(message2) : getPlaceholder() }) });
1616
1812
  };
1617
- var MemoizedBubbleList = (0, import_react10.memo)(
1813
+ var MemoizedBubbleList = (0, import_react11.memo)(
1618
1814
  ({
1619
1815
  items,
1620
1816
  roles,
1621
1817
  className
1622
- }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1818
+ }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1623
1819
  import_x.Bubble.List,
1624
1820
  {
1625
1821
  autoScroll: true,
@@ -1652,15 +1848,18 @@ var Chating = ({
1652
1848
  extra,
1653
1849
  attachment_placeholder,
1654
1850
  extraMeta = [],
1655
- uploadAction = "/api/file_storage/upload?path=temp"
1851
+ uploadAction = "/api/file_storage/upload?path=temp",
1852
+ files,
1853
+ todos
1656
1854
  }) => {
1657
1855
  const { t } = (0, import_react_i18next.useTranslation)();
1658
- const [content, setContent] = (0, import_react10.useState)("");
1659
- const [attachedFiles, setAttachedFiles] = (0, import_react10.useState)([]);
1660
- const [headerOpen, setHeaderOpen] = (0, import_react10.useState)(false);
1661
- const attachmentsRef = (0, import_react10.useRef)(null);
1662
- const senderRef = import_react10.default.useRef(null);
1663
- (0, import_react10.useEffect)(() => {
1856
+ const [content, setContent] = (0, import_react11.useState)("");
1857
+ const [attachedFiles, setAttachedFiles] = (0, import_react11.useState)([]);
1858
+ const [headerOpen, setHeaderOpen] = (0, import_react11.useState)(false);
1859
+ const [fileExplorerVisible, setFileExplorerVisible] = (0, import_react11.useState)(false);
1860
+ const attachmentsRef = (0, import_react11.useRef)(null);
1861
+ const senderRef = import_react11.default.useRef(null);
1862
+ (0, import_react11.useEffect)(() => {
1664
1863
  regsiterElement("action_show_attachments_uploader", {
1665
1864
  card_view: () => null,
1666
1865
  action: (data) => {
@@ -1669,19 +1868,19 @@ var Chating = ({
1669
1868
  }
1670
1869
  });
1671
1870
  }, []);
1672
- const messageLengthRef = (0, import_react10.useRef)(messages?.length ?? 0);
1673
- (0, import_react10.useEffect)(() => {
1871
+ const messageLengthRef = (0, import_react11.useRef)(messages?.length ?? 0);
1872
+ (0, import_react11.useEffect)(() => {
1674
1873
  if (messages?.length) {
1675
1874
  messageLengthRef.current = messages?.length;
1676
1875
  }
1677
1876
  }, [messages?.length]);
1678
- const renderContent = (0, import_react10.useCallback)(
1877
+ const renderContent = (0, import_react11.useCallback)(
1679
1878
  (message2) => {
1680
- const { content: content2, files, id } = message2;
1879
+ const { content: content2, files: files2, id } = message2;
1681
1880
  try {
1682
1881
  const json = JSON.parse(content2);
1683
1882
  if (json.action && json.message) {
1684
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1883
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1685
1884
  MDResponse,
1686
1885
  {
1687
1886
  content: json.message,
@@ -1697,7 +1896,7 @@ ${JSON.stringify(tool_call)}
1697
1896
  \`\`\``;
1698
1897
  }) || [];
1699
1898
  const content_md = [content2, ...tool_calls_md].join("\n");
1700
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_antd6.Space, { direction: "vertical", style: { width: "100%" }, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1899
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd7.Space, { direction: "vertical", style: { width: "100%" }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1701
1900
  MDResponse,
1702
1901
  {
1703
1902
  content: content_md,
@@ -1707,12 +1906,12 @@ ${JSON.stringify(tool_call)}
1707
1906
  },
1708
1907
  [handleMDResponseEvent]
1709
1908
  );
1710
- const items = (0, import_react10.useMemo)(
1909
+ const items = (0, import_react11.useMemo)(
1711
1910
  () => messages.map((message2, index) => ({
1712
1911
  key: message2.id,
1713
1912
  role: message2.role,
1714
1913
  typing: false,
1715
- content: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1914
+ content: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1716
1915
  LazyBubble,
1717
1916
  {
1718
1917
  message: message2,
@@ -1762,13 +1961,13 @@ ${JSON.stringify(tool_call)}
1762
1961
  const onSubmit = (nextContent) => {
1763
1962
  if (!nextContent && attachedFiles.length === 0) return;
1764
1963
  if (attachedFiles.filter((f) => f.status !== "done").length > 0) {
1765
- import_antd6.message.warning("\u6587\u4EF6\u8FD8\u5728\u4E0A\u4F20\u4E2D...");
1964
+ import_antd7.message.warning("\u6587\u4EF6\u8FD8\u5728\u4E0A\u4F20\u4E2D...");
1766
1965
  return;
1767
1966
  }
1768
1967
  if (!nextContent && attachedFiles.length > 0) {
1769
1968
  nextContent = default_submit_message || "\u8BB0\u8D26";
1770
1969
  }
1771
- const files = attachedFiles.map(
1970
+ const files2 = attachedFiles.map(
1772
1971
  (file) => isArchiveFile(file) ? {
1773
1972
  name: file.response.zipFileName || file.response.rarFileName,
1774
1973
  id: file.response.zipFileId || file.response.rarFileId,
@@ -1786,14 +1985,14 @@ ${JSON.stringify(tool_call)}
1786
1985
  id: file.response.id
1787
1986
  }
1788
1987
  );
1789
- const files_md = files.length > 0 ? [
1988
+ const files_md = files2.length > 0 ? [
1790
1989
  "",
1791
1990
  "\u6211\u5DF2\u7ECF\u63D0\u4EA4\u4E86\u4EE5\u4E0B\u6587\u4EF6\uFF1A",
1792
1991
  "```attachments",
1793
- JSON.stringify(files),
1992
+ JSON.stringify(files2),
1794
1993
  "```"
1795
1994
  ].join("\n") : "";
1796
- sendMessage({ input: { message: nextContent + files_md, files } });
1995
+ sendMessage({ input: { message: nextContent + files_md, files: files2 } });
1797
1996
  setContent("");
1798
1997
  setAttachedFiles([]);
1799
1998
  setHeaderOpen(false);
@@ -1806,7 +2005,7 @@ ${JSON.stringify(tool_call)}
1806
2005
  setHeaderOpen(true);
1807
2006
  }
1808
2007
  if (info.file?.response?.error || info.file.status === "error") {
1809
- import_antd6.message.error(
2008
+ import_antd7.message.error(
1810
2009
  `${info.file.name} file upload failed.${info.file?.response?.message}`
1811
2010
  );
1812
2011
  }
@@ -1818,22 +2017,22 @@ ${JSON.stringify(tool_call)}
1818
2017
  const beforeUpload = (file) => {
1819
2018
  const isLessThan20MB = file.size / 1024 / 1024 < 20;
1820
2019
  if (!isLessThan20MB) {
1821
- import_antd6.message.error(
2020
+ import_antd7.message.error(
1822
2021
  `File must be smaller than 20MB! ${file.name} is too large.`
1823
2022
  );
1824
2023
  return false;
1825
2024
  }
1826
2025
  return true;
1827
2026
  };
1828
- const attachmentsNode = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_antd6.Badge, { dot: attachedFiles.length > 0 && !headerOpen, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1829
- import_antd6.Button,
2027
+ const attachmentsNode = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd7.Badge, { dot: attachedFiles.length > 0 && !headerOpen, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2028
+ import_antd7.Button,
1830
2029
  {
1831
2030
  type: "text",
1832
- icon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons5.PaperClipOutlined, {}),
2031
+ icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons6.PaperClipOutlined, {}),
1833
2032
  onClick: () => setHeaderOpen(!headerOpen)
1834
2033
  }
1835
2034
  ) });
1836
- const senderHeader = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2035
+ const senderHeader = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1837
2036
  import_x.Sender.Header,
1838
2037
  {
1839
2038
  title: "Attachments",
@@ -1845,7 +2044,7 @@ ${JSON.stringify(tool_call)}
1845
2044
  }
1846
2045
  },
1847
2046
  forceRender: true,
1848
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2047
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1849
2048
  import_x.Attachments,
1850
2049
  {
1851
2050
  ref: attachmentsRef,
@@ -1867,7 +2066,7 @@ ${JSON.stringify(tool_call)}
1867
2066
  multiple: true,
1868
2067
  maxCount: 10,
1869
2068
  placeholder: (type) => ({
1870
- icon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons5.CloudUploadOutlined, {}),
2069
+ icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons6.CloudUploadOutlined, {}),
1871
2070
  title: "\u4E0A\u4F20\u6587\u4EF6",
1872
2071
  description: attachment_placeholder
1873
2072
  })
@@ -1899,7 +2098,7 @@ ${JSON.stringify(tool_call)}
1899
2098
  }
1900
2099
  }
1901
2100
  };
1902
- const extraMetaComponents = (0, import_react10.useMemo)(() => {
2101
+ const extraMetaComponents = (0, import_react11.useMemo)(() => {
1903
2102
  if (extraMeta?.length > 0) {
1904
2103
  return extraMeta.map((meta) => {
1905
2104
  const Element = getElement(meta.id)?.card_view;
@@ -1908,7 +2107,7 @@ ${JSON.stringify(tool_call)}
1908
2107
  try {
1909
2108
  } catch (error2) {
1910
2109
  }
1911
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2110
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1912
2111
  Element,
1913
2112
  {
1914
2113
  component_key: meta.id,
@@ -1924,20 +2123,63 @@ ${JSON.stringify(tool_call)}
1924
2123
  }
1925
2124
  return void 0;
1926
2125
  }, [extraMeta]);
1927
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1928
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { children: [
1929
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2126
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
2127
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { children: [
2128
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1930
2129
  import_x.Welcome,
1931
2130
  {
1932
2131
  style: { padding: 8 },
1933
2132
  variant: "borderless",
1934
2133
  description,
1935
- icon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_antd6.Avatar, { src: avatar || "/images/avatar.jpeg", size: 48 }),
2134
+ icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd7.Avatar, { src: avatar || "/images/avatar.jpeg", size: 48 }),
1936
2135
  title: name || "Fina",
1937
- extra: extra || extraMetaComponents && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_antd6.Space, { align: "center", style: { marginRight: 16 }, children: extraMetaComponents })
2136
+ extra: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_antd7.Space, { children: [
2137
+ extra,
2138
+ todos && todos.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2139
+ import_antd7.Popover,
2140
+ {
2141
+ content: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { width: 400 }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2142
+ Todo,
2143
+ {
2144
+ data: todos,
2145
+ component_key: "header_todos",
2146
+ eventHandler: handleMDResponseEvent
2147
+ }
2148
+ ) }),
2149
+ title: "Todos",
2150
+ trigger: "click",
2151
+ placement: "bottomRight",
2152
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd7.Tooltip, { title: "Todos", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2153
+ import_antd7.Badge,
2154
+ {
2155
+ count: todos.filter((item) => item.status !== "completed").length,
2156
+ size: "small",
2157
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd7.Button, { icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons6.CheckSquareOutlined, {}), type: "text" })
2158
+ }
2159
+ ) })
2160
+ }
2161
+ ),
2162
+ files && Object.keys(files).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd7.Tooltip, { title: "File Explorer", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2163
+ import_antd7.Badge,
2164
+ {
2165
+ count: Object.keys(files).length,
2166
+ size: "small",
2167
+ color: "blue",
2168
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2169
+ import_antd7.Button,
2170
+ {
2171
+ type: "text",
2172
+ icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons6.FileTextOutlined, {}),
2173
+ onClick: () => setFileExplorerVisible(true)
2174
+ }
2175
+ )
2176
+ }
2177
+ ) }),
2178
+ extraMetaComponents && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd7.Space, { align: "center", style: { marginRight: 16 }, children: extraMetaComponents })
2179
+ ] })
1938
2180
  }
1939
2181
  ),
1940
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2182
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1941
2183
  "div",
1942
2184
  {
1943
2185
  style: {
@@ -1946,17 +2188,36 @@ ${JSON.stringify(tool_call)}
1946
2188
  }
1947
2189
  )
1948
2190
  ] }),
1949
- items.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2191
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2192
+ import_antd7.Modal,
2193
+ {
2194
+ title: "File Explorer",
2195
+ open: fileExplorerVisible,
2196
+ onCancel: () => setFileExplorerVisible(false),
2197
+ footer: null,
2198
+ width: 1e3,
2199
+ destroyOnClose: true,
2200
+ styles: { body: { height: "70vh", padding: 0 } },
2201
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2202
+ FileExplorer,
2203
+ {
2204
+ files,
2205
+ style: { height: "100%", border: "none" }
2206
+ }
2207
+ )
2208
+ }
2209
+ ),
2210
+ items.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1950
2211
  MemoizedBubbleList,
1951
2212
  {
1952
2213
  items,
1953
2214
  roles,
1954
2215
  className: styles.messages
1955
2216
  }
1956
- ) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { style: { flex: 1 } }),
1957
- isLoading ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_x.Bubble, { loading: isLoading, variant: "borderless" }) }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_x.Prompts, { items: senderPromptsItems, onItemClick: onPromptsItemClick }),
1958
- error && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { style: { padding: "0 16px 8px" }, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1959
- import_antd6.Alert,
2217
+ ) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { flex: 1 } }),
2218
+ isLoading ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_x.Bubble, { loading: isLoading, variant: "borderless" }) }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_x.Prompts, { items: senderPromptsItems, onItemClick: onPromptsItemClick }),
2219
+ error && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { padding: "0 16px 8px" }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2220
+ import_antd7.Alert,
1960
2221
  {
1961
2222
  type: "error",
1962
2223
  banner: true,
@@ -1965,7 +2226,7 @@ ${JSON.stringify(tool_call)}
1965
2226
  message: `${error.message}`
1966
2227
  }
1967
2228
  ) }),
1968
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2229
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1969
2230
  import_x.Sender,
1970
2231
  {
1971
2232
  allowSpeech: true,
@@ -1980,7 +2241,7 @@ ${JSON.stringify(tool_call)}
1980
2241
  className: styles.sender,
1981
2242
  actions: (ori, { components }) => {
1982
2243
  const { SendButton, LoadingButton } = components;
1983
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_antd6.Flex, { justify: "space-between", align: "center", children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(LoadingButton, { type: "default" }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2244
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd7.Flex, { justify: "space-between", align: "center", children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(LoadingButton, { type: "default" }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1984
2245
  SendButton,
1985
2246
  {
1986
2247
  type: "primary",
@@ -1989,8 +2250,8 @@ ${JSON.stringify(tool_call)}
1989
2250
  }
1990
2251
  ) });
1991
2252
  },
1992
- onPasteFile: (_, files) => {
1993
- Array.from(files).forEach((file) => {
2253
+ onPasteFile: (_, files2) => {
2254
+ Array.from(files2).forEach((file) => {
1994
2255
  attachmentsRef.current?.upload(file);
1995
2256
  });
1996
2257
  setHeaderOpen(true);
@@ -2001,19 +2262,19 @@ ${JSON.stringify(tool_call)}
2001
2262
  };
2002
2263
 
2003
2264
  // src/components/Chat/ThinkingChain.tsx
2004
- var import_icons6 = require("@ant-design/icons");
2265
+ var import_icons7 = require("@ant-design/icons");
2005
2266
  var import_x2 = require("@ant-design/x");
2006
- var import_jsx_runtime11 = require("react/jsx-runtime");
2267
+ var import_jsx_runtime12 = require("react/jsx-runtime");
2007
2268
  function getStatusIcon2(status) {
2008
2269
  switch (status) {
2009
2270
  case "success":
2010
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons6.CheckCircleOutlined, {});
2271
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.CheckCircleOutlined, {});
2011
2272
  case "error":
2012
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons6.InfoCircleOutlined, {});
2273
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.InfoCircleOutlined, {});
2013
2274
  case "pending":
2014
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons6.LoadingOutlined, {});
2275
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.LoadingOutlined, {});
2015
2276
  default:
2016
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons6.CheckCircleOutlined, {});
2277
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.CheckCircleOutlined, {});
2017
2278
  }
2018
2279
  }
2019
2280
  var ThinkingChain = ({ message: message2 }) => {
@@ -2022,12 +2283,12 @@ var ThinkingChain = ({ message: message2 }) => {
2022
2283
  {
2023
2284
  key: message2.id,
2024
2285
  title,
2025
- content: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(MDResponse, { content: message2.content }),
2286
+ content: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MDResponse, { content: message2.content }),
2026
2287
  status: message2.status,
2027
2288
  icon: getStatusIcon2(message2.status)
2028
2289
  }
2029
2290
  ];
2030
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2291
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2031
2292
  import_x2.ThoughtChain,
2032
2293
  {
2033
2294
  items,
@@ -2041,20 +2302,20 @@ var ThinkingChainGroup = ({ message: message2 }) => {
2041
2302
  const children = message2.items?.map((item) => ({
2042
2303
  key: item.id,
2043
2304
  title: item.name || item.content.split("\n")[0],
2044
- content: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(MDResponse, { content: item.content }),
2305
+ content: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MDResponse, { content: item.content }),
2045
2306
  status: item.status,
2046
2307
  icon: getStatusIcon2(item.status)
2047
2308
  }));
2048
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_x2.ThoughtChain, { items: children, collapsible: true, size: "small" });
2309
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_x2.ThoughtChain, { items: children, collapsible: true, size: "small" });
2049
2310
  };
2050
2311
 
2051
2312
  // src/components/Chat/SideAppViewBrowser.tsx
2052
- var import_icons7 = require("@ant-design/icons");
2053
- var import_antd7 = require("antd");
2054
- var import_antd_style5 = require("antd-style");
2055
- var import_react11 = require("react");
2056
- var import_jsx_runtime12 = require("react/jsx-runtime");
2057
- var useStyle4 = (0, import_antd_style5.createStyles)(({ token, css }) => {
2313
+ var import_icons8 = require("@ant-design/icons");
2314
+ var import_antd8 = require("antd");
2315
+ var import_antd_style6 = require("antd-style");
2316
+ var import_react12 = require("react");
2317
+ var import_jsx_runtime13 = require("react/jsx-runtime");
2318
+ var useStyle4 = (0, import_antd_style6.createStyles)(({ token, css }) => {
2058
2319
  return {
2059
2320
  tabContainer: css`
2060
2321
  .ant-tabs-content-holder {
@@ -2073,9 +2334,9 @@ var useStyle4 = (0, import_antd_style5.createStyles)(({ token, css }) => {
2073
2334
  };
2074
2335
  });
2075
2336
  var EmptySideAppView = ({ component_key, data }) => {
2076
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { children: [
2077
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: "\u672A\u627E\u5230\u5BF9\u5E94\u7684\u7EC4\u4EF6\u89C6\u56FE" }),
2078
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("pre", { children: JSON.stringify({ component_key, data }, null, 2) })
2337
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { children: [
2338
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: "\u672A\u627E\u5230\u5BF9\u5E94\u7684\u7EC4\u4EF6\u89C6\u56FE" }),
2339
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("pre", { children: JSON.stringify({ component_key, data }, null, 2) })
2079
2340
  ] });
2080
2341
  };
2081
2342
  var SideAppViewBrowser = ({
@@ -2085,9 +2346,9 @@ var SideAppViewBrowser = ({
2085
2346
  onChangeSize
2086
2347
  }) => {
2087
2348
  const { styles } = useStyle4();
2088
- const [activeKey, setActiveKey] = (0, import_react11.useState)(JSON.stringify(open_uri));
2089
- const [currentSize, setCurrentSize] = (0, import_react11.useState)(open_uri.size || "large");
2090
- const [items, setItems] = (0, import_react11.useState)([]);
2349
+ const [activeKey, setActiveKey] = (0, import_react12.useState)(JSON.stringify(open_uri));
2350
+ const [currentSize, setCurrentSize] = (0, import_react12.useState)(open_uri.size || "large");
2351
+ const [items, setItems] = (0, import_react12.useState)([]);
2091
2352
  const add = (key, label, children) => {
2092
2353
  const newActiveKey = key;
2093
2354
  const newPanes = [...items];
@@ -2123,7 +2384,7 @@ var SideAppViewBrowser = ({
2123
2384
  remove(targetKey);
2124
2385
  }
2125
2386
  };
2126
- (0, import_react11.useEffect)(() => {
2387
+ (0, import_react12.useEffect)(() => {
2127
2388
  const SideAppView = getElement(open_uri.component_key).side_app_view || EmptySideAppView;
2128
2389
  const key = JSON.stringify(open_uri);
2129
2390
  if (items.find((item) => item.key === key)) {
@@ -2133,7 +2394,7 @@ var SideAppViewBrowser = ({
2133
2394
  add(
2134
2395
  key,
2135
2396
  open_uri.message || open_uri.data.message || "\u672A\u547D\u540D",
2136
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2397
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2137
2398
  SideAppView,
2138
2399
  {
2139
2400
  component_key: open_uri.component_key,
@@ -2143,7 +2404,7 @@ var SideAppViewBrowser = ({
2143
2404
  )
2144
2405
  );
2145
2406
  }, [open_uri]);
2146
- (0, import_react11.useEffect)(() => {
2407
+ (0, import_react12.useEffect)(() => {
2147
2408
  if (open_uri.size && open_uri.size !== currentSize) {
2148
2409
  setCurrentSize(open_uri.size);
2149
2410
  }
@@ -2181,26 +2442,26 @@ var SideAppViewBrowser = ({
2181
2442
  const getSizeIcon = (size) => {
2182
2443
  switch (size) {
2183
2444
  case "middle":
2184
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.CompressOutlined, {});
2445
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons8.CompressOutlined, {});
2185
2446
  case "large":
2186
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.ExpandOutlined, {});
2447
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons8.ExpandOutlined, {});
2187
2448
  case "full":
2188
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.FullscreenOutlined, {});
2449
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons8.FullscreenOutlined, {});
2189
2450
  default:
2190
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.ExpandOutlined, {});
2451
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons8.ExpandOutlined, {});
2191
2452
  }
2192
2453
  };
2193
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2194
- import_antd7.Tabs,
2454
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2455
+ import_antd8.Tabs,
2195
2456
  {
2196
2457
  className: styles.tabContainer,
2197
2458
  type: "editable-card",
2198
2459
  style: { height: "100%" },
2199
2460
  hideAdd: true,
2200
2461
  tabBarExtraContent: {
2201
- right: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { style: { display: "flex", gap: "4px" }, children: [
2202
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2203
- import_antd7.Button,
2462
+ right: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { style: { display: "flex", gap: "4px" }, children: [
2463
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2464
+ import_antd8.Button,
2204
2465
  {
2205
2466
  style: { margin: "8px 0" },
2206
2467
  size: "large",
@@ -2210,13 +2471,13 @@ var SideAppViewBrowser = ({
2210
2471
  title: `\u5F53\u524D\u5C3A\u5BF8: ${getSizeLabel(currentSize)}, \u70B9\u51FB\u5207\u6362`
2211
2472
  }
2212
2473
  ),
2213
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2214
- import_antd7.Button,
2474
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2475
+ import_antd8.Button,
2215
2476
  {
2216
2477
  style: { margin: "8px 0" },
2217
2478
  size: "large",
2218
2479
  type: "text",
2219
- icon: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.CloseOutlined, {}),
2480
+ icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons8.CloseOutlined, {}),
2220
2481
  onClick: () => {
2221
2482
  onClose();
2222
2483
  }
@@ -2233,8 +2494,8 @@ var SideAppViewBrowser = ({
2233
2494
  };
2234
2495
 
2235
2496
  // src/components/Chat/context.tsx
2236
- var import_react12 = require("react");
2237
- var chatContext = (0, import_react12.createContext)({
2497
+ var import_react13 = require("react");
2498
+ var chatContext = (0, import_react13.createContext)({
2238
2499
  eventHandler: (component_key, data, message2) => {
2239
2500
  }
2240
2501
  });
@@ -2242,6 +2503,7 @@ var chatContext = (0, import_react12.createContext)({
2242
2503
  0 && (module.exports = {
2243
2504
  AxiomLatticeProvider,
2244
2505
  Chating,
2506
+ FileExplorer,
2245
2507
  MDMermaid,
2246
2508
  MDResponse,
2247
2509
  MDViewFormItem,