@axiom-lattice/react-sdk 2.0.2 → 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
  }));
@@ -321,6 +335,12 @@ function useChat(threadId, options = {}) {
321
335
  streamingMessage: null
322
336
  }));
323
337
  }, []);
338
+ const clearError = (0, import_react2.useCallback)(() => {
339
+ setState((prev) => ({
340
+ ...prev,
341
+ error: null
342
+ }));
343
+ }, []);
324
344
  (0, import_react2.useEffect)(() => {
325
345
  if (threadId) {
326
346
  loadMessages();
@@ -339,7 +359,8 @@ function useChat(threadId, options = {}) {
339
359
  sendMessage,
340
360
  stopStreaming,
341
361
  loadMessages,
342
- clearMessages
362
+ clearMessages,
363
+ clearError
343
364
  };
344
365
  }
345
366
 
@@ -1563,22 +1584,204 @@ var IFrameCard = ({ src }) => {
1563
1584
  };
1564
1585
 
1565
1586
  // src/components/Chat/Chating.tsx
1566
- var import_icons5 = require("@ant-design/icons");
1587
+ var import_icons6 = require("@ant-design/icons");
1567
1588
  var import_x = require("@ant-design/x");
1568
- var import_antd6 = require("antd");
1589
+ var import_antd7 = require("antd");
1569
1590
  var import_ErrorBoundary = __toESM(require("antd/es/alert/ErrorBoundary"));
1570
- var import_react10 = __toESM(require("react"));
1591
+ var import_react11 = __toESM(require("react"));
1571
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");
1572
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");
1573
1776
  var LazyBubble = ({
1574
1777
  message: message2,
1575
1778
  renderContent,
1576
1779
  autoLoadRightPanel
1577
1780
  }) => {
1578
- const ref = (0, import_react10.useRef)(null);
1579
- const [isVisible, setIsVisible] = (0, import_react10.useState)(false);
1580
- const [wasEverVisible, setWasEverVisible] = (0, import_react10.useState)(false);
1581
- (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)(() => {
1582
1785
  const observer = new IntersectionObserver(
1583
1786
  ([entry]) => {
1584
1787
  const visible = entry.isIntersecting;
@@ -1598,21 +1801,21 @@ var LazyBubble = ({
1598
1801
  }
1599
1802
  };
1600
1803
  }, [wasEverVisible]);
1601
- (0, import_react10.useEffect)(() => {
1804
+ (0, import_react11.useEffect)(() => {
1602
1805
  autoLoadRightPanel?.();
1603
1806
  }, []);
1604
1807
  const getPlaceholder = () => {
1605
1808
  const estimatedHeight = message2.content ? Math.min(100, message2.content.length / 5) : 100;
1606
- 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" } });
1607
1810
  };
1608
- 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() }) });
1609
1812
  };
1610
- var MemoizedBubbleList = (0, import_react10.memo)(
1813
+ var MemoizedBubbleList = (0, import_react11.memo)(
1611
1814
  ({
1612
1815
  items,
1613
1816
  roles,
1614
1817
  className
1615
- }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1818
+ }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1616
1819
  import_x.Bubble.List,
1617
1820
  {
1618
1821
  autoScroll: true,
@@ -1632,10 +1835,12 @@ var Chating = ({
1632
1835
  tenant_id,
1633
1836
  messages,
1634
1837
  isLoading,
1838
+ error,
1635
1839
  sendMessage,
1636
1840
  stopStreaming,
1637
1841
  onOpenSidePanel,
1638
1842
  onReminderClick,
1843
+ onClearError,
1639
1844
  styles,
1640
1845
  reminderCount,
1641
1846
  handleMDResponseEvent,
@@ -1643,15 +1848,18 @@ var Chating = ({
1643
1848
  extra,
1644
1849
  attachment_placeholder,
1645
1850
  extraMeta = [],
1646
- uploadAction = "/api/file_storage/upload?path=temp"
1851
+ uploadAction = "/api/file_storage/upload?path=temp",
1852
+ files,
1853
+ todos
1647
1854
  }) => {
1648
1855
  const { t } = (0, import_react_i18next.useTranslation)();
1649
- const [content, setContent] = (0, import_react10.useState)("");
1650
- const [attachedFiles, setAttachedFiles] = (0, import_react10.useState)([]);
1651
- const [headerOpen, setHeaderOpen] = (0, import_react10.useState)(false);
1652
- const attachmentsRef = (0, import_react10.useRef)(null);
1653
- const senderRef = import_react10.default.useRef(null);
1654
- (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)(() => {
1655
1863
  regsiterElement("action_show_attachments_uploader", {
1656
1864
  card_view: () => null,
1657
1865
  action: (data) => {
@@ -1660,19 +1868,19 @@ var Chating = ({
1660
1868
  }
1661
1869
  });
1662
1870
  }, []);
1663
- const messageLengthRef = (0, import_react10.useRef)(messages?.length ?? 0);
1664
- (0, import_react10.useEffect)(() => {
1871
+ const messageLengthRef = (0, import_react11.useRef)(messages?.length ?? 0);
1872
+ (0, import_react11.useEffect)(() => {
1665
1873
  if (messages?.length) {
1666
1874
  messageLengthRef.current = messages?.length;
1667
1875
  }
1668
1876
  }, [messages?.length]);
1669
- const renderContent = (0, import_react10.useCallback)(
1877
+ const renderContent = (0, import_react11.useCallback)(
1670
1878
  (message2) => {
1671
- const { content: content2, files, id } = message2;
1879
+ const { content: content2, files: files2, id } = message2;
1672
1880
  try {
1673
1881
  const json = JSON.parse(content2);
1674
1882
  if (json.action && json.message) {
1675
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1883
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1676
1884
  MDResponse,
1677
1885
  {
1678
1886
  content: json.message,
@@ -1680,7 +1888,7 @@ var Chating = ({
1680
1888
  }
1681
1889
  );
1682
1890
  }
1683
- } catch (error) {
1891
+ } catch (error2) {
1684
1892
  }
1685
1893
  const tool_calls_md = message2.tool_calls?.map((tool_call) => {
1686
1894
  return `\`\`\`tool_call
@@ -1688,7 +1896,7 @@ ${JSON.stringify(tool_call)}
1688
1896
  \`\`\``;
1689
1897
  }) || [];
1690
1898
  const content_md = [content2, ...tool_calls_md].join("\n");
1691
- 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)(
1692
1900
  MDResponse,
1693
1901
  {
1694
1902
  content: content_md,
@@ -1698,12 +1906,12 @@ ${JSON.stringify(tool_call)}
1698
1906
  },
1699
1907
  [handleMDResponseEvent]
1700
1908
  );
1701
- const items = (0, import_react10.useMemo)(
1909
+ const items = (0, import_react11.useMemo)(
1702
1910
  () => messages.map((message2, index) => ({
1703
1911
  key: message2.id,
1704
1912
  role: message2.role,
1705
1913
  typing: false,
1706
- content: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1914
+ content: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1707
1915
  LazyBubble,
1708
1916
  {
1709
1917
  message: message2,
@@ -1730,8 +1938,8 @@ ${JSON.stringify(tool_call)}
1730
1938
  element.action(jsonData);
1731
1939
  }
1732
1940
  }
1733
- } catch (error) {
1734
- console.error(error);
1941
+ } catch (error2) {
1942
+ console.error(error2);
1735
1943
  }
1736
1944
  }
1737
1945
  }
@@ -1753,13 +1961,13 @@ ${JSON.stringify(tool_call)}
1753
1961
  const onSubmit = (nextContent) => {
1754
1962
  if (!nextContent && attachedFiles.length === 0) return;
1755
1963
  if (attachedFiles.filter((f) => f.status !== "done").length > 0) {
1756
- import_antd6.message.warning("\u6587\u4EF6\u8FD8\u5728\u4E0A\u4F20\u4E2D...");
1964
+ import_antd7.message.warning("\u6587\u4EF6\u8FD8\u5728\u4E0A\u4F20\u4E2D...");
1757
1965
  return;
1758
1966
  }
1759
1967
  if (!nextContent && attachedFiles.length > 0) {
1760
1968
  nextContent = default_submit_message || "\u8BB0\u8D26";
1761
1969
  }
1762
- const files = attachedFiles.map(
1970
+ const files2 = attachedFiles.map(
1763
1971
  (file) => isArchiveFile(file) ? {
1764
1972
  name: file.response.zipFileName || file.response.rarFileName,
1765
1973
  id: file.response.zipFileId || file.response.rarFileId,
@@ -1777,14 +1985,14 @@ ${JSON.stringify(tool_call)}
1777
1985
  id: file.response.id
1778
1986
  }
1779
1987
  );
1780
- const files_md = files.length > 0 ? [
1988
+ const files_md = files2.length > 0 ? [
1781
1989
  "",
1782
1990
  "\u6211\u5DF2\u7ECF\u63D0\u4EA4\u4E86\u4EE5\u4E0B\u6587\u4EF6\uFF1A",
1783
1991
  "```attachments",
1784
- JSON.stringify(files),
1992
+ JSON.stringify(files2),
1785
1993
  "```"
1786
1994
  ].join("\n") : "";
1787
- sendMessage({ input: { message: nextContent + files_md, files } });
1995
+ sendMessage({ input: { message: nextContent + files_md, files: files2 } });
1788
1996
  setContent("");
1789
1997
  setAttachedFiles([]);
1790
1998
  setHeaderOpen(false);
@@ -1797,7 +2005,7 @@ ${JSON.stringify(tool_call)}
1797
2005
  setHeaderOpen(true);
1798
2006
  }
1799
2007
  if (info.file?.response?.error || info.file.status === "error") {
1800
- import_antd6.message.error(
2008
+ import_antd7.message.error(
1801
2009
  `${info.file.name} file upload failed.${info.file?.response?.message}`
1802
2010
  );
1803
2011
  }
@@ -1809,22 +2017,22 @@ ${JSON.stringify(tool_call)}
1809
2017
  const beforeUpload = (file) => {
1810
2018
  const isLessThan20MB = file.size / 1024 / 1024 < 20;
1811
2019
  if (!isLessThan20MB) {
1812
- import_antd6.message.error(
2020
+ import_antd7.message.error(
1813
2021
  `File must be smaller than 20MB! ${file.name} is too large.`
1814
2022
  );
1815
2023
  return false;
1816
2024
  }
1817
2025
  return true;
1818
2026
  };
1819
- const attachmentsNode = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_antd6.Badge, { dot: attachedFiles.length > 0 && !headerOpen, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1820
- 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,
1821
2029
  {
1822
2030
  type: "text",
1823
- icon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons5.PaperClipOutlined, {}),
2031
+ icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons6.PaperClipOutlined, {}),
1824
2032
  onClick: () => setHeaderOpen(!headerOpen)
1825
2033
  }
1826
2034
  ) });
1827
- const senderHeader = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2035
+ const senderHeader = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1828
2036
  import_x.Sender.Header,
1829
2037
  {
1830
2038
  title: "Attachments",
@@ -1836,7 +2044,7 @@ ${JSON.stringify(tool_call)}
1836
2044
  }
1837
2045
  },
1838
2046
  forceRender: true,
1839
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2047
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1840
2048
  import_x.Attachments,
1841
2049
  {
1842
2050
  ref: attachmentsRef,
@@ -1858,7 +2066,7 @@ ${JSON.stringify(tool_call)}
1858
2066
  multiple: true,
1859
2067
  maxCount: 10,
1860
2068
  placeholder: (type) => ({
1861
- icon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons5.CloudUploadOutlined, {}),
2069
+ icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons6.CloudUploadOutlined, {}),
1862
2070
  title: "\u4E0A\u4F20\u6587\u4EF6",
1863
2071
  description: attachment_placeholder
1864
2072
  })
@@ -1890,16 +2098,16 @@ ${JSON.stringify(tool_call)}
1890
2098
  }
1891
2099
  }
1892
2100
  };
1893
- const extraMetaComponents = (0, import_react10.useMemo)(() => {
2101
+ const extraMetaComponents = (0, import_react11.useMemo)(() => {
1894
2102
  if (extraMeta?.length > 0) {
1895
2103
  return extraMeta.map((meta) => {
1896
2104
  const Element = getElement(meta.id)?.card_view;
1897
2105
  if (Element) {
1898
2106
  let childrenData;
1899
2107
  try {
1900
- } catch (error) {
2108
+ } catch (error2) {
1901
2109
  }
1902
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2110
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1903
2111
  Element,
1904
2112
  {
1905
2113
  component_key: meta.id,
@@ -1915,20 +2123,63 @@ ${JSON.stringify(tool_call)}
1915
2123
  }
1916
2124
  return void 0;
1917
2125
  }, [extraMeta]);
1918
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1919
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { children: [
1920
- /* @__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)(
1921
2129
  import_x.Welcome,
1922
2130
  {
1923
2131
  style: { padding: 8 },
1924
2132
  variant: "borderless",
1925
2133
  description,
1926
- 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 }),
1927
2135
  title: name || "Fina",
1928
- 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
+ ] })
1929
2180
  }
1930
2181
  ),
1931
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2182
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1932
2183
  "div",
1933
2184
  {
1934
2185
  style: {
@@ -1937,16 +2188,45 @@ ${JSON.stringify(tool_call)}
1937
2188
  }
1938
2189
  )
1939
2190
  ] }),
1940
- 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)(
1941
2211
  MemoizedBubbleList,
1942
2212
  {
1943
2213
  items,
1944
2214
  roles,
1945
2215
  className: styles.messages
1946
2216
  }
1947
- ) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { style: { flex: 1 } }),
1948
- 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 }),
1949
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
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,
2221
+ {
2222
+ type: "error",
2223
+ banner: true,
2224
+ closable: true,
2225
+ onClose: () => onClearError?.(),
2226
+ message: `${error.message}`
2227
+ }
2228
+ ) }),
2229
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1950
2230
  import_x.Sender,
1951
2231
  {
1952
2232
  allowSpeech: true,
@@ -1961,7 +2241,7 @@ ${JSON.stringify(tool_call)}
1961
2241
  className: styles.sender,
1962
2242
  actions: (ori, { components }) => {
1963
2243
  const { SendButton, LoadingButton } = components;
1964
- 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)(
1965
2245
  SendButton,
1966
2246
  {
1967
2247
  type: "primary",
@@ -1970,8 +2250,8 @@ ${JSON.stringify(tool_call)}
1970
2250
  }
1971
2251
  ) });
1972
2252
  },
1973
- onPasteFile: (_, files) => {
1974
- Array.from(files).forEach((file) => {
2253
+ onPasteFile: (_, files2) => {
2254
+ Array.from(files2).forEach((file) => {
1975
2255
  attachmentsRef.current?.upload(file);
1976
2256
  });
1977
2257
  setHeaderOpen(true);
@@ -1982,19 +2262,19 @@ ${JSON.stringify(tool_call)}
1982
2262
  };
1983
2263
 
1984
2264
  // src/components/Chat/ThinkingChain.tsx
1985
- var import_icons6 = require("@ant-design/icons");
2265
+ var import_icons7 = require("@ant-design/icons");
1986
2266
  var import_x2 = require("@ant-design/x");
1987
- var import_jsx_runtime11 = require("react/jsx-runtime");
2267
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1988
2268
  function getStatusIcon2(status) {
1989
2269
  switch (status) {
1990
2270
  case "success":
1991
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons6.CheckCircleOutlined, {});
2271
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.CheckCircleOutlined, {});
1992
2272
  case "error":
1993
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons6.InfoCircleOutlined, {});
2273
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.InfoCircleOutlined, {});
1994
2274
  case "pending":
1995
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons6.LoadingOutlined, {});
2275
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.LoadingOutlined, {});
1996
2276
  default:
1997
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons6.CheckCircleOutlined, {});
2277
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.CheckCircleOutlined, {});
1998
2278
  }
1999
2279
  }
2000
2280
  var ThinkingChain = ({ message: message2 }) => {
@@ -2003,12 +2283,12 @@ var ThinkingChain = ({ message: message2 }) => {
2003
2283
  {
2004
2284
  key: message2.id,
2005
2285
  title,
2006
- content: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(MDResponse, { content: message2.content }),
2286
+ content: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MDResponse, { content: message2.content }),
2007
2287
  status: message2.status,
2008
2288
  icon: getStatusIcon2(message2.status)
2009
2289
  }
2010
2290
  ];
2011
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2291
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2012
2292
  import_x2.ThoughtChain,
2013
2293
  {
2014
2294
  items,
@@ -2022,20 +2302,20 @@ var ThinkingChainGroup = ({ message: message2 }) => {
2022
2302
  const children = message2.items?.map((item) => ({
2023
2303
  key: item.id,
2024
2304
  title: item.name || item.content.split("\n")[0],
2025
- content: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(MDResponse, { content: item.content }),
2305
+ content: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MDResponse, { content: item.content }),
2026
2306
  status: item.status,
2027
2307
  icon: getStatusIcon2(item.status)
2028
2308
  }));
2029
- 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" });
2030
2310
  };
2031
2311
 
2032
2312
  // src/components/Chat/SideAppViewBrowser.tsx
2033
- var import_icons7 = require("@ant-design/icons");
2034
- var import_antd7 = require("antd");
2035
- var import_antd_style5 = require("antd-style");
2036
- var import_react11 = require("react");
2037
- var import_jsx_runtime12 = require("react/jsx-runtime");
2038
- 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 }) => {
2039
2319
  return {
2040
2320
  tabContainer: css`
2041
2321
  .ant-tabs-content-holder {
@@ -2054,9 +2334,9 @@ var useStyle4 = (0, import_antd_style5.createStyles)(({ token, css }) => {
2054
2334
  };
2055
2335
  });
2056
2336
  var EmptySideAppView = ({ component_key, data }) => {
2057
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { children: [
2058
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: "\u672A\u627E\u5230\u5BF9\u5E94\u7684\u7EC4\u4EF6\u89C6\u56FE" }),
2059
- /* @__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) })
2060
2340
  ] });
2061
2341
  };
2062
2342
  var SideAppViewBrowser = ({
@@ -2066,9 +2346,9 @@ var SideAppViewBrowser = ({
2066
2346
  onChangeSize
2067
2347
  }) => {
2068
2348
  const { styles } = useStyle4();
2069
- const [activeKey, setActiveKey] = (0, import_react11.useState)(JSON.stringify(open_uri));
2070
- const [currentSize, setCurrentSize] = (0, import_react11.useState)(open_uri.size || "large");
2071
- 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)([]);
2072
2352
  const add = (key, label, children) => {
2073
2353
  const newActiveKey = key;
2074
2354
  const newPanes = [...items];
@@ -2104,7 +2384,7 @@ var SideAppViewBrowser = ({
2104
2384
  remove(targetKey);
2105
2385
  }
2106
2386
  };
2107
- (0, import_react11.useEffect)(() => {
2387
+ (0, import_react12.useEffect)(() => {
2108
2388
  const SideAppView = getElement(open_uri.component_key).side_app_view || EmptySideAppView;
2109
2389
  const key = JSON.stringify(open_uri);
2110
2390
  if (items.find((item) => item.key === key)) {
@@ -2114,7 +2394,7 @@ var SideAppViewBrowser = ({
2114
2394
  add(
2115
2395
  key,
2116
2396
  open_uri.message || open_uri.data.message || "\u672A\u547D\u540D",
2117
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2397
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2118
2398
  SideAppView,
2119
2399
  {
2120
2400
  component_key: open_uri.component_key,
@@ -2124,7 +2404,7 @@ var SideAppViewBrowser = ({
2124
2404
  )
2125
2405
  );
2126
2406
  }, [open_uri]);
2127
- (0, import_react11.useEffect)(() => {
2407
+ (0, import_react12.useEffect)(() => {
2128
2408
  if (open_uri.size && open_uri.size !== currentSize) {
2129
2409
  setCurrentSize(open_uri.size);
2130
2410
  }
@@ -2162,26 +2442,26 @@ var SideAppViewBrowser = ({
2162
2442
  const getSizeIcon = (size) => {
2163
2443
  switch (size) {
2164
2444
  case "middle":
2165
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.CompressOutlined, {});
2445
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons8.CompressOutlined, {});
2166
2446
  case "large":
2167
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.ExpandOutlined, {});
2447
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons8.ExpandOutlined, {});
2168
2448
  case "full":
2169
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.FullscreenOutlined, {});
2449
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons8.FullscreenOutlined, {});
2170
2450
  default:
2171
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.ExpandOutlined, {});
2451
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons8.ExpandOutlined, {});
2172
2452
  }
2173
2453
  };
2174
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2175
- import_antd7.Tabs,
2454
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2455
+ import_antd8.Tabs,
2176
2456
  {
2177
2457
  className: styles.tabContainer,
2178
2458
  type: "editable-card",
2179
2459
  style: { height: "100%" },
2180
2460
  hideAdd: true,
2181
2461
  tabBarExtraContent: {
2182
- right: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { style: { display: "flex", gap: "4px" }, children: [
2183
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2184
- 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,
2185
2465
  {
2186
2466
  style: { margin: "8px 0" },
2187
2467
  size: "large",
@@ -2191,13 +2471,13 @@ var SideAppViewBrowser = ({
2191
2471
  title: `\u5F53\u524D\u5C3A\u5BF8: ${getSizeLabel(currentSize)}, \u70B9\u51FB\u5207\u6362`
2192
2472
  }
2193
2473
  ),
2194
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2195
- import_antd7.Button,
2474
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2475
+ import_antd8.Button,
2196
2476
  {
2197
2477
  style: { margin: "8px 0" },
2198
2478
  size: "large",
2199
2479
  type: "text",
2200
- icon: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.CloseOutlined, {}),
2480
+ icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons8.CloseOutlined, {}),
2201
2481
  onClick: () => {
2202
2482
  onClose();
2203
2483
  }
@@ -2214,8 +2494,8 @@ var SideAppViewBrowser = ({
2214
2494
  };
2215
2495
 
2216
2496
  // src/components/Chat/context.tsx
2217
- var import_react12 = require("react");
2218
- var chatContext = (0, import_react12.createContext)({
2497
+ var import_react13 = require("react");
2498
+ var chatContext = (0, import_react13.createContext)({
2219
2499
  eventHandler: (component_key, data, message2) => {
2220
2500
  }
2221
2501
  });
@@ -2223,6 +2503,7 @@ var chatContext = (0, import_react12.createContext)({
2223
2503
  0 && (module.exports = {
2224
2504
  AxiomLatticeProvider,
2225
2505
  Chating,
2506
+ FileExplorer,
2226
2507
  MDMermaid,
2227
2508
  MDResponse,
2228
2509
  MDViewFormItem,