@axiom-lattice/react-sdk 2.0.4 → 2.1.1

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.mjs CHANGED
@@ -102,7 +102,7 @@ function useChat(threadId, options = {}) {
102
102
  stopStreamingRef.current = null;
103
103
  }
104
104
  const { input, command, streaming = true } = data;
105
- const { message: message2, files, ...rest } = input || {};
105
+ const { message: message3, files, ...rest } = input || {};
106
106
  setState((prev) => ({
107
107
  ...prev,
108
108
  isLoading: true,
@@ -111,7 +111,7 @@ function useChat(threadId, options = {}) {
111
111
  }));
112
112
  const userMessage = {
113
113
  id: Date.now().toString(),
114
- content: message2 || command?.resume?.message || "",
114
+ content: message3 || command?.resume?.message || "",
115
115
  files,
116
116
  role: "human"
117
117
  };
@@ -553,8 +553,8 @@ import ReactMarkdown from "react-markdown";
553
553
  import { Prism } from "react-syntax-highlighter";
554
554
  import { dark } from "react-syntax-highlighter/dist/cjs/styles/prism";
555
555
  import remarkGfm from "remark-gfm";
556
- import { useMemo as useMemo2, useRef as useRef4, useState as useState7 } from "react";
557
- import { createStyles as createStyles4 } from "antd-style";
556
+ import { useMemo as useMemo3, useRef as useRef5, useState as useState11 } from "react";
557
+ import { createStyles as createStyles6 } from "antd-style";
558
558
  import rehypeRaw from "rehype-raw";
559
559
 
560
560
  // src/components/GenUI/elements/confirm_feedback.tsx
@@ -578,7 +578,7 @@ var ConfirmFeedback = ({
578
578
  eventHandler,
579
579
  interactive = true
580
580
  }) => {
581
- const { message: message2, type, config, feedback, options } = data ?? {};
581
+ const { message: message3, type, config, feedback, options } = data ?? {};
582
582
  const [clicked, setClicked] = useState5(false);
583
583
  const { styles } = useStyle();
584
584
  return /* @__PURE__ */ jsx2(Card, { size: "small", className: `shadow-sm ${styles.card}`, bordered: false, children: /* @__PURE__ */ jsxs(Space, { direction: "vertical", style: { width: "100%" }, children: [
@@ -597,7 +597,7 @@ var ConfirmFeedback = ({
597
597
  children: "\u8BF7\u6C42\u786E\u8BA4"
598
598
  }
599
599
  ),
600
- /* @__PURE__ */ jsx2(MDResponse, { content: message2 }),
600
+ /* @__PURE__ */ jsx2(MDResponse, { content: message3 }),
601
601
  options ? /* @__PURE__ */ jsx2(Space, { style: { justifyContent: "flex-end", width: "100%" }, children: options?.map((option) => /* @__PURE__ */ jsx2(
602
602
  Button,
603
603
  {
@@ -678,7 +678,7 @@ var GenericDataTable = ({
678
678
  interactive = true,
679
679
  default_open_in_side_app = true
680
680
  }) => {
681
- const { dataSource, message: message2 } = data ?? {};
681
+ const { dataSource, message: message3 } = data ?? {};
682
682
  const [expandedRowKeys, setExpandedRowKeys] = useState6([]);
683
683
  const processedData = dataSource?.map((item, index) => ({
684
684
  ...item,
@@ -760,7 +760,7 @@ var GenericDataTable = ({
760
760
  {
761
761
  size: "small",
762
762
  title: () => /* @__PURE__ */ jsxs2(Flex, { justify: "space-between", align: "center", children: [
763
- /* @__PURE__ */ jsx3(Space2, { children: /* @__PURE__ */ jsx3(Text2, { strong: true, style: { fontSize: 16 }, children: message2 || "" }) }),
763
+ /* @__PURE__ */ jsx3(Space2, { children: /* @__PURE__ */ jsx3(Text2, { strong: true, style: { fontSize: 16 }, children: message3 || "" }) }),
764
764
  /* @__PURE__ */ jsxs2(Space2, { children: [
765
765
  /* @__PURE__ */ jsx3(
766
766
  Button2,
@@ -783,8 +783,8 @@ var GenericDataTable = ({
783
783
  "__open_side_app",
784
784
  {
785
785
  component_key: "generic_data_table",
786
- message: message2 || "",
787
- data: { dataSource, message: message2 },
786
+ message: message3 || "",
787
+ data: { dataSource, message: message3 },
788
788
  size: "large"
789
789
  },
790
790
  ""
@@ -1019,9 +1019,12 @@ function getStatusIcon(status) {
1019
1019
  return /* @__PURE__ */ jsx6(LoadingOutlined, { style: { color: "#1890ff" } });
1020
1020
  }
1021
1021
  }
1022
- var ToolCall = ({ data }) => {
1022
+ var ToolCall = ({ data, eventHandler }) => {
1023
1023
  const toolCallData = data;
1024
1024
  const formatToolName = (name) => {
1025
+ if (!name) {
1026
+ return "";
1027
+ }
1025
1028
  return name.replace(/([a-z])([A-Z])/g, "$1 $2").split(/[_-]/).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
1026
1029
  };
1027
1030
  const formatArgsPreview = (args) => {
@@ -1078,6 +1081,14 @@ var ToolCall = ({ data }) => {
1078
1081
  const expandIcon = ({ isActive }) => {
1079
1082
  return getStatusIcon(toolCallData.status);
1080
1083
  };
1084
+ const toolCallElement = getElement(toolCallData.name.toLowerCase());
1085
+ if (toolCallElement) {
1086
+ return toolCallElement.card_view({
1087
+ data: toolCallData,
1088
+ component_key: toolCallData.id,
1089
+ eventHandler
1090
+ });
1091
+ }
1081
1092
  return /* @__PURE__ */ jsx6(
1082
1093
  Collapse,
1083
1094
  {
@@ -1102,9 +1113,9 @@ var ToolCall = ({ data }) => {
1102
1113
  import { Card as Card4, List, Typography as Typography5, Space as Space5 } from "antd";
1103
1114
  import { createStyles as createStyles3 } from "antd-style";
1104
1115
  import {
1116
+ ArrowRightOutlined,
1105
1117
  CheckCircleOutlined as CheckCircleOutlined2,
1106
- ClockCircleOutlined,
1107
- LoadingOutlined as LoadingOutlined2
1118
+ ClockCircleOutlined
1108
1119
  } from "@ant-design/icons";
1109
1120
  import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
1110
1121
  var { Text: Text4 } = Typography5;
@@ -1113,8 +1124,8 @@ var useStyle3 = createStyles3(({ token, css }) => ({
1113
1124
  max-width: 1200px;
1114
1125
  background: linear-gradient(
1115
1126
  919deg,
1116
- rgb(67 232 157 / 8%),
1117
- rgb(206 250 235 / 28%) 43%
1127
+ rgb(67 81 232 / 8%),
1128
+ rgb(249 249 249 / 28%) 43%
1118
1129
  );
1119
1130
  `,
1120
1131
  todoItem: css`
@@ -1146,7 +1157,7 @@ var Todo = ({
1146
1157
  case "completed":
1147
1158
  return /* @__PURE__ */ jsx7(CheckCircleOutlined2, { style: { color: "#52c41a" } });
1148
1159
  case "in_progress":
1149
- return /* @__PURE__ */ jsx7(LoadingOutlined2, { style: { color: "#1890ff" } });
1160
+ return /* @__PURE__ */ jsx7(ArrowRightOutlined, { style: { fontWeight: "500" } });
1150
1161
  case "pending":
1151
1162
  return /* @__PURE__ */ jsx7(ClockCircleOutlined, { style: { color: "gray" } });
1152
1163
  default:
@@ -1233,7 +1244,1028 @@ var Todo = ({
1233
1244
  ] }) });
1234
1245
  };
1235
1246
 
1236
- // src/components/GenUI/elements/index.tsx
1247
+ // src/components/GenUI/elements/WriteTodos.tsx
1248
+ import { Space as Space6, Collapse as Collapse2, Typography as Typography6 } from "antd";
1249
+ import { UnorderedListOutlined } from "@ant-design/icons";
1250
+ import CollapsePanel2 from "antd/es/collapse/CollapsePanel";
1251
+ import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
1252
+ var { Text: Text5 } = Typography6;
1253
+ var WriteTodos = ({
1254
+ data,
1255
+ component_key,
1256
+ eventHandler,
1257
+ interactive = true
1258
+ }) => {
1259
+ const toolCallData = data;
1260
+ const todos = toolCallData?.args?.todos || [];
1261
+ const totalCount = todos.length;
1262
+ const completedCount = todos.filter(
1263
+ (item) => item.status === "completed"
1264
+ ).length;
1265
+ const expandIcon = () => {
1266
+ return /* @__PURE__ */ jsx8(UnorderedListOutlined, {});
1267
+ };
1268
+ const header = /* @__PURE__ */ jsxs6(Space6, { children: [
1269
+ /* @__PURE__ */ jsx8(Text5, { strong: true, children: "Todos" }),
1270
+ /* @__PURE__ */ jsxs6(Text5, { style: { fontSize: 12 }, type: "secondary", children: [
1271
+ completedCount,
1272
+ "/",
1273
+ totalCount,
1274
+ " Done"
1275
+ ] })
1276
+ ] });
1277
+ if (!toolCallData) {
1278
+ return null;
1279
+ }
1280
+ return /* @__PURE__ */ jsx8(
1281
+ Collapse2,
1282
+ {
1283
+ size: "small",
1284
+ bordered: false,
1285
+ defaultActiveKey: [toolCallData.id],
1286
+ expandIcon,
1287
+ children: /* @__PURE__ */ jsx8(
1288
+ CollapsePanel2,
1289
+ {
1290
+ header,
1291
+ style: { minWidth: 400 },
1292
+ children: /* @__PURE__ */ jsx8(
1293
+ Todo,
1294
+ {
1295
+ data: data.args.todos,
1296
+ component_key,
1297
+ eventHandler,
1298
+ interactive
1299
+ }
1300
+ )
1301
+ },
1302
+ toolCallData.id
1303
+ )
1304
+ }
1305
+ );
1306
+ };
1307
+
1308
+ // src/components/GenUI/FileExplorer.tsx
1309
+ import { useState as useState7, useEffect as useEffect4, useMemo as useMemo2 } from "react";
1310
+ import { Splitter, Tree, Empty, Button as Button3, Tooltip, message } from "antd";
1311
+ import {
1312
+ FolderOutlined,
1313
+ FolderOpenOutlined,
1314
+ CopyOutlined,
1315
+ DownloadOutlined as DownloadOutlined2,
1316
+ CheckOutlined
1317
+ } from "@ant-design/icons";
1318
+ import { createStyles as createStyles4 } from "antd-style";
1319
+
1320
+ // src/components/GenUI/elements/getFileIcon.tsx
1321
+ import {
1322
+ CodeOutlined as CodeOutlined2,
1323
+ FileImageOutlined,
1324
+ FileMarkdownOutlined,
1325
+ FileOutlined,
1326
+ FileTextOutlined,
1327
+ FileUnknownOutlined,
1328
+ Html5Outlined
1329
+ } from "@ant-design/icons";
1330
+ import { jsx as jsx9 } from "react/jsx-runtime";
1331
+ var getFileIcon = (filename) => {
1332
+ const ext = filename?.split(".")?.pop()?.toLowerCase();
1333
+ const iconStyle = { fontSize: 14, marginRight: 4, verticalAlign: "middle" };
1334
+ switch (ext) {
1335
+ case "ts":
1336
+ case "tsx":
1337
+ return /* @__PURE__ */ jsx9(CodeOutlined2, { style: { ...iconStyle, color: "#3178c6" } });
1338
+ case "js":
1339
+ case "jsx":
1340
+ return /* @__PURE__ */ jsx9(CodeOutlined2, { style: { ...iconStyle, color: "#f7df1e" } });
1341
+ case "html":
1342
+ return /* @__PURE__ */ jsx9(Html5Outlined, { style: { ...iconStyle, color: "#e34c26" } });
1343
+ case "css":
1344
+ case "less":
1345
+ case "scss":
1346
+ return /* @__PURE__ */ jsx9(FileUnknownOutlined, { style: { ...iconStyle, color: "#563d7c" } });
1347
+ case "md":
1348
+ return /* @__PURE__ */ jsx9(FileMarkdownOutlined, { style: { ...iconStyle, color: "#083fa1" } });
1349
+ case "json":
1350
+ return /* @__PURE__ */ jsx9(FileTextOutlined, { style: { ...iconStyle, color: "#fbc02d" } });
1351
+ case "png":
1352
+ case "jpg":
1353
+ case "jpeg":
1354
+ case "gif":
1355
+ case "svg":
1356
+ return /* @__PURE__ */ jsx9(FileImageOutlined, { style: { ...iconStyle, color: "#4caf50" } });
1357
+ default:
1358
+ return /* @__PURE__ */ jsx9(FileOutlined, { style: { ...iconStyle, color: "#9e9e9e" } });
1359
+ }
1360
+ };
1361
+
1362
+ // src/components/GenUI/FileExplorer.tsx
1363
+ import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
1364
+ var useStyles = createStyles4(({ token, css }) => ({
1365
+ container: css`
1366
+ height: 100%;
1367
+ background: ${token.colorBgContainer};
1368
+ border: 1px solid ${token.colorBorder};
1369
+ border-radius: ${token.borderRadiusLG}px;
1370
+ overflow: hidden;
1371
+ display: flex;
1372
+ flex-direction: column;
1373
+ `,
1374
+ splitter: css`
1375
+ height: 100%;
1376
+ .ant-splitter-bar-dragger {
1377
+ background: transparent !important;
1378
+ &:hover {
1379
+ background: ${token.colorPrimary} !important;
1380
+ }
1381
+ }
1382
+ `,
1383
+ leftPanel: css`
1384
+ height: 100%;
1385
+ overflow: auto;
1386
+ padding: 0;
1387
+ background: ${token.colorBgContainer};
1388
+ border-right: 1px solid ${token.colorBorderSecondary};
1389
+
1390
+ /* Custom scrollbar for tree */
1391
+ &::-webkit-scrollbar {
1392
+ width: 6px;
1393
+ height: 6px;
1394
+ }
1395
+ &::-webkit-scrollbar-thumb {
1396
+ background: ${token.colorBorder};
1397
+ border-radius: 3px;
1398
+ }
1399
+ `,
1400
+ rightPanel: css`
1401
+ height: 100%;
1402
+ overflow: auto;
1403
+ padding: 0;
1404
+ background: ${token.colorBgLayout};
1405
+ position: relative;
1406
+ `,
1407
+ header: css`
1408
+ display: flex;
1409
+ justify-content: flex-end;
1410
+ padding: 8px 16px;
1411
+ background: ${token.colorBgContainer + "30"};
1412
+ backdrop-filter: blur(4px);
1413
+ -webkit-backdrop-filter: blur(4px);
1414
+ gap: 8px;
1415
+ position: sticky;
1416
+ top: 0;
1417
+ z-index: 10;
1418
+ `,
1419
+ contentBody: css`
1420
+ padding: 24px;
1421
+ min-height: 100%;
1422
+
1423
+ pre {
1424
+ margin: 0 !important;
1425
+ border-radius: ${token.borderRadius}px !important;
1426
+ }
1427
+ `,
1428
+ emptyState: css`
1429
+ display: flex;
1430
+ flex-direction: column;
1431
+ align-items: center;
1432
+ justify-content: center;
1433
+ height: 100%;
1434
+ color: ${token.colorTextQuaternary};
1435
+ `,
1436
+ fileTree: css`
1437
+ background: transparent;
1438
+ font-size: 13px;
1439
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
1440
+ "Helvetica Neue", Arial, sans-serif;
1441
+
1442
+ .ant-tree-treenode {
1443
+ padding-bottom: 0 !important;
1444
+ width: 100%;
1445
+ &:hover {
1446
+ background-color: ${token.colorFillQuaternary};
1447
+ }
1448
+ }
1449
+
1450
+ .ant-tree-node-content-wrapper {
1451
+ padding: 0 4px;
1452
+ border-radius: 0;
1453
+ transition: none;
1454
+ line-height: 24px;
1455
+ min-height: 24px;
1456
+
1457
+ &:hover {
1458
+ background-color: transparent;
1459
+ }
1460
+
1461
+ &.ant-tree-node-selected {
1462
+ background-color: ${token.controlItemBgActive} !important;
1463
+ color: ${token.colorText};
1464
+ font-weight: 500;
1465
+ }
1466
+ }
1467
+
1468
+ .ant-tree-indent-unit {
1469
+ width: 16px;
1470
+ }
1471
+
1472
+ .ant-tree-switcher {
1473
+ width: 20px;
1474
+ line-height: 24px;
1475
+
1476
+ .anticon {
1477
+ font-size: 10px;
1478
+ color: ${token.colorTextSecondary};
1479
+ }
1480
+ }
1481
+
1482
+ .ant-tree-title {
1483
+ display: inline-block;
1484
+ margin-left: 4px;
1485
+ }
1486
+ `
1487
+ }));
1488
+ var getFolderIcon = (expanded) => {
1489
+ const iconStyle = {
1490
+ fontSize: 14,
1491
+ marginRight: 4,
1492
+ color: "#dcb67a",
1493
+ verticalAlign: "middle"
1494
+ };
1495
+ return expanded ? /* @__PURE__ */ jsx10(FolderOpenOutlined, { style: iconStyle }) : /* @__PURE__ */ jsx10(FolderOutlined, { style: iconStyle });
1496
+ };
1497
+ var sortTreeNodes = (nodes) => {
1498
+ return nodes.sort((a, b) => {
1499
+ if (!!a.isLeaf === !!b.isLeaf) {
1500
+ return a.title.localeCompare(b.title);
1501
+ }
1502
+ return a.isLeaf ? 1 : -1;
1503
+ }).map((node) => {
1504
+ if (node.children) {
1505
+ return { ...node, children: sortTreeNodes(node.children) };
1506
+ }
1507
+ return node;
1508
+ });
1509
+ };
1510
+ var buildTreeData = (files, expandedKeys) => {
1511
+ const root = [];
1512
+ files.forEach((file) => {
1513
+ const parts = file.name.split("/");
1514
+ let currentLevel = root;
1515
+ parts.forEach((part, index) => {
1516
+ const isFile = index === parts.length - 1;
1517
+ const key = parts.slice(0, index + 1).join("/");
1518
+ let existingNode = currentLevel.find((node) => node.key === key);
1519
+ if (!existingNode) {
1520
+ const title = part === "" && index === 0 ? /* @__PURE__ */ jsx10(
1521
+ "span",
1522
+ {
1523
+ style: {
1524
+ color: "rgba(0, 0, 0, 0.45)",
1525
+ fontStyle: "italic",
1526
+ fontSize: 12
1527
+ },
1528
+ children: "<root>"
1529
+ }
1530
+ ) : part;
1531
+ const newNode = {
1532
+ title,
1533
+ key,
1534
+ isLeaf: isFile,
1535
+ icon: isFile ? getFileIcon(part) : getFolderIcon(expandedKeys.includes(key)),
1536
+ children: isFile ? void 0 : []
1537
+ };
1538
+ currentLevel.push(newNode);
1539
+ existingNode = newNode;
1540
+ }
1541
+ if (!isFile && existingNode.children) {
1542
+ currentLevel = existingNode.children;
1543
+ }
1544
+ });
1545
+ });
1546
+ return sortTreeNodes(root);
1547
+ };
1548
+ var FileExplorer = ({
1549
+ data,
1550
+ eventHandler,
1551
+ interactive = true,
1552
+ default_open_in_side_app = true
1553
+ }) => {
1554
+ const { files } = data ?? {};
1555
+ const { styles, cx } = useStyles();
1556
+ const [fileList, setFileList] = useState7([]);
1557
+ const [selectedKey, setSelectedKey] = useState7("");
1558
+ const [expandedKeys, setExpandedKeys] = useState7([]);
1559
+ const [copied, setCopied] = useState7(false);
1560
+ useEffect4(() => {
1561
+ if (copied) {
1562
+ const timer = setTimeout(() => setCopied(false), 2e3);
1563
+ return () => clearTimeout(timer);
1564
+ }
1565
+ }, [copied]);
1566
+ useEffect4(() => {
1567
+ let list = [];
1568
+ if (Array.isArray(files)) {
1569
+ list = files;
1570
+ } else {
1571
+ list = Object.keys(files).map((key) => ({
1572
+ ...files[key],
1573
+ name: key
1574
+ }));
1575
+ }
1576
+ setFileList(list);
1577
+ if (list.length > 0 && !selectedKey) {
1578
+ const firstFile = list[0];
1579
+ setSelectedKey(list[0].name);
1580
+ }
1581
+ }, [files]);
1582
+ const treeData = useMemo2(
1583
+ () => buildTreeData(fileList, expandedKeys),
1584
+ [fileList, expandedKeys]
1585
+ );
1586
+ useEffect4(() => {
1587
+ if (treeData.length > 0 && expandedKeys.length === 0) {
1588
+ const getAllKeys = (nodes) => {
1589
+ let keys = [];
1590
+ nodes.forEach((node) => {
1591
+ if (!node.isLeaf) {
1592
+ keys.push(node.key);
1593
+ if (node.children) {
1594
+ keys = keys.concat(getAllKeys(node.children));
1595
+ }
1596
+ }
1597
+ });
1598
+ return keys;
1599
+ };
1600
+ setExpandedKeys(getAllKeys(treeData));
1601
+ }
1602
+ }, [treeData.length]);
1603
+ const selectedFile = useMemo2(() => {
1604
+ return fileList.find((f) => f.name === selectedKey);
1605
+ }, [fileList, selectedKey]);
1606
+ const handleCopy = () => {
1607
+ if (!selectedFile) return;
1608
+ const content = Array.isArray(selectedFile.content) ? selectedFile.content.join("\n") : selectedFile.content;
1609
+ navigator.clipboard.writeText(content).then(() => {
1610
+ setCopied(true);
1611
+ message.success("Copied to clipboard");
1612
+ });
1613
+ };
1614
+ const handleDownload = () => {
1615
+ if (!selectedFile) return;
1616
+ const content = Array.isArray(selectedFile.content) ? selectedFile.content.join("\n") : selectedFile.content;
1617
+ const blob = new Blob([content], { type: "text/plain" });
1618
+ const url = URL.createObjectURL(blob);
1619
+ const a = document.createElement("a");
1620
+ a.href = url;
1621
+ const fileName = selectedFile.name.split("/").pop() || selectedFile.name;
1622
+ a.download = fileName;
1623
+ document.body.appendChild(a);
1624
+ a.click();
1625
+ document.body.removeChild(a);
1626
+ URL.revokeObjectURL(url);
1627
+ };
1628
+ const renderContent = () => {
1629
+ if (!selectedFile) {
1630
+ return /* @__PURE__ */ jsx10("div", { className: styles.emptyState, children: /* @__PURE__ */ jsx10(
1631
+ Empty,
1632
+ {
1633
+ description: "Select a file to preview",
1634
+ image: Empty.PRESENTED_IMAGE_SIMPLE
1635
+ }
1636
+ ) });
1637
+ }
1638
+ const content = Array.isArray(selectedFile.content) ? selectedFile.content.join("\n") : selectedFile.content;
1639
+ return /* @__PURE__ */ jsxs7(
1640
+ "div",
1641
+ {
1642
+ style: { minHeight: "100%", display: "flex", flexDirection: "column" },
1643
+ children: [
1644
+ /* @__PURE__ */ jsxs7("div", { className: styles.header, children: [
1645
+ /* @__PURE__ */ jsx10(Tooltip, { title: "Copy Content", children: /* @__PURE__ */ jsx10(
1646
+ Button3,
1647
+ {
1648
+ type: "text",
1649
+ icon: copied ? /* @__PURE__ */ jsx10(CheckOutlined, {}) : /* @__PURE__ */ jsx10(CopyOutlined, {}),
1650
+ onClick: handleCopy,
1651
+ size: "small"
1652
+ }
1653
+ ) }),
1654
+ /* @__PURE__ */ jsx10(Tooltip, { title: "Download File", children: /* @__PURE__ */ jsx10(
1655
+ Button3,
1656
+ {
1657
+ type: "text",
1658
+ icon: /* @__PURE__ */ jsx10(DownloadOutlined2, {}),
1659
+ onClick: handleDownload,
1660
+ size: "small"
1661
+ }
1662
+ ) })
1663
+ ] }),
1664
+ /* @__PURE__ */ jsx10("div", { className: styles.contentBody, children: /* @__PURE__ */ jsx10(MDResponse, { content }) })
1665
+ ]
1666
+ }
1667
+ );
1668
+ };
1669
+ return /* @__PURE__ */ jsx10("div", { className: styles.container, children: /* @__PURE__ */ jsxs7(Splitter, { className: styles.splitter, children: [
1670
+ /* @__PURE__ */ jsx10(Splitter.Panel, { defaultSize: "25%", min: "15%", max: "40%", children: /* @__PURE__ */ jsx10("div", { className: styles.leftPanel, children: /* @__PURE__ */ jsx10(
1671
+ Tree,
1672
+ {
1673
+ showIcon: true,
1674
+ blockNode: true,
1675
+ showLine: true,
1676
+ className: styles.fileTree,
1677
+ treeData,
1678
+ selectedKeys: selectedKey ? [selectedKey] : [],
1679
+ expandedKeys,
1680
+ onExpand: setExpandedKeys,
1681
+ onSelect: (keys, info) => {
1682
+ if (keys.length > 0) {
1683
+ const key = keys[0];
1684
+ const file = fileList.find((f) => f.name === key);
1685
+ if (file) {
1686
+ setSelectedKey(key);
1687
+ } else {
1688
+ if (expandedKeys.includes(key)) {
1689
+ setExpandedKeys(expandedKeys.filter((k) => k !== key));
1690
+ } else {
1691
+ setExpandedKeys([...expandedKeys, key]);
1692
+ }
1693
+ }
1694
+ } else if (info.node.key) {
1695
+ const key = info.node.key;
1696
+ const file = fileList.find((f) => f.name === key);
1697
+ if (!file) {
1698
+ if (expandedKeys.includes(key)) {
1699
+ setExpandedKeys(expandedKeys.filter((k) => k !== key));
1700
+ } else {
1701
+ setExpandedKeys([...expandedKeys, key]);
1702
+ }
1703
+ }
1704
+ }
1705
+ }
1706
+ }
1707
+ ) }) }),
1708
+ /* @__PURE__ */ jsx10(Splitter.Panel, { children: /* @__PURE__ */ jsx10("div", { className: styles.rightPanel, children: renderContent() }) })
1709
+ ] }) });
1710
+ };
1711
+
1712
+ // src/components/GenUI/elements/attachments_card.tsx
1713
+ import { Attachments } from "@ant-design/x";
1714
+ import {
1715
+ Card as Card5,
1716
+ Flex as Flex3,
1717
+ Space as Space7,
1718
+ Typography as Typography7,
1719
+ Row,
1720
+ Col,
1721
+ Button as Button4
1722
+ } from "antd";
1723
+ import dayjs from "dayjs";
1724
+ import { useState as useState8 } from "react";
1725
+ import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
1726
+ var AttachmentsCard = ({
1727
+ data,
1728
+ eventHandler,
1729
+ component_key,
1730
+ size = "medium",
1731
+ columns = 1,
1732
+ showDownloadButton = false
1733
+ }) => {
1734
+ const { Text: Text8 } = Typography7;
1735
+ const [showAll, setShowAll] = useState8(false);
1736
+ const getStyles = () => {
1737
+ switch (size) {
1738
+ case "small":
1739
+ return {
1740
+ padding: "0px",
1741
+ fontSize: "10px",
1742
+ cardSize: "small"
1743
+ };
1744
+ case "large":
1745
+ return {
1746
+ padding: "16px",
1747
+ fontSize: "16px",
1748
+ cardSize: "default"
1749
+ };
1750
+ default:
1751
+ return {
1752
+ padding: "8px",
1753
+ fontSize: "14px",
1754
+ cardSize: "small"
1755
+ };
1756
+ }
1757
+ };
1758
+ const styles = getStyles();
1759
+ const handleItemClick = (item) => {
1760
+ eventHandler?.(
1761
+ "__open_side_app",
1762
+ {
1763
+ component_key: "attachments",
1764
+ data: { file_id: item.id, message: "\u9884\u89C8\uFF1A" + item.name }
1765
+ },
1766
+ ""
1767
+ );
1768
+ };
1769
+ const getCardStyle = (item) => {
1770
+ if (item.is_failure && columns > 1) {
1771
+ return {
1772
+ padding: 0
1773
+ };
1774
+ }
1775
+ return { padding: 0, cursor: "pointer" };
1776
+ };
1777
+ const getFileCardStyle = (item) => {
1778
+ const baseStyle = {
1779
+ width: "100%",
1780
+ backgroundColor: "transparent",
1781
+ fontSize: styles.fontSize,
1782
+ padding: styles.padding,
1783
+ position: "relative"
1784
+ // 添加相对定位,用于绝对定位下载按钮
1785
+ };
1786
+ if (item.is_failure && columns > 1) {
1787
+ return {
1788
+ ...baseStyle,
1789
+ color: "gray"
1790
+ };
1791
+ }
1792
+ return baseStyle;
1793
+ };
1794
+ const DownloadButton = ({ item }) => {
1795
+ if (!showDownloadButton) return null;
1796
+ return /* @__PURE__ */ jsx11(
1797
+ "div",
1798
+ {
1799
+ style: {
1800
+ position: "absolute",
1801
+ top: "50%",
1802
+ right: 8,
1803
+ transform: "translateY(-50%)",
1804
+ zIndex: 10
1805
+ },
1806
+ onClick: (e) => e.stopPropagation()
1807
+ }
1808
+ );
1809
+ };
1810
+ const renderFileDescription = (item) => /* @__PURE__ */ jsx11(Space7, { direction: "vertical", size: size === "small" ? 2 : 4, children: /* @__PURE__ */ jsx11(Space7, { children: /* @__PURE__ */ jsx11(
1811
+ Text8,
1812
+ {
1813
+ type: "secondary",
1814
+ style: {
1815
+ fontSize: size === "small" ? "10px" : void 0
1816
+ },
1817
+ children: item.created_at && dayjs(item.created_at).format("YYYY-MM-DD HH:mm:ss")
1818
+ }
1819
+ ) }) });
1820
+ if (columns > 1) {
1821
+ const displayData2 = data || [];
1822
+ const shouldShowViewMore2 = displayData2.length > 4;
1823
+ const visibleData2 = showAll ? displayData2 : displayData2.slice(0, 4);
1824
+ return /* @__PURE__ */ jsxs8(Flex3, { vertical: true, gap: "small", children: [
1825
+ /* @__PURE__ */ jsx11(Row, { gutter: [8, 8], children: visibleData2.map((item) => /* @__PURE__ */ jsx11(Col, { span: 24 / columns, children: /* @__PURE__ */ jsx11(
1826
+ "div",
1827
+ {
1828
+ onClick: (evt) => {
1829
+ evt.stopPropagation();
1830
+ handleItemClick(item);
1831
+ },
1832
+ children: /* @__PURE__ */ jsxs8(Card5, { size: styles.cardSize, style: getCardStyle(item), children: [
1833
+ /* @__PURE__ */ jsx11(DownloadButton, { item }),
1834
+ /* @__PURE__ */ jsx11(
1835
+ Attachments.FileCard,
1836
+ {
1837
+ style: getFileCardStyle(item),
1838
+ item: {
1839
+ name: item.name,
1840
+ size: item.size,
1841
+ uid: item.id,
1842
+ description: renderFileDescription(item)
1843
+ }
1844
+ }
1845
+ ),
1846
+ item.files && /* @__PURE__ */ jsx11(
1847
+ AttachmentsCard,
1848
+ {
1849
+ data: item.files,
1850
+ component_key: `${component_key}_${item.id}`,
1851
+ eventHandler,
1852
+ size: "small",
1853
+ columns: 2,
1854
+ showDownloadButton
1855
+ }
1856
+ )
1857
+ ] })
1858
+ }
1859
+ ) }, item.id)) }),
1860
+ shouldShowViewMore2 && /* @__PURE__ */ jsx11(
1861
+ Button4,
1862
+ {
1863
+ type: "link",
1864
+ onClick: () => setShowAll(!showAll),
1865
+ style: { alignSelf: "center" },
1866
+ children: showAll ? "\u663E\u793A\u66F4\u5C11" : `\u663E\u793A\u66F4\u591A (${displayData2.length - 4})`
1867
+ }
1868
+ )
1869
+ ] });
1870
+ }
1871
+ const displayData = data || [];
1872
+ const shouldShowViewMore = displayData.length > 4;
1873
+ const visibleData = showAll ? displayData : displayData.slice(0, 4);
1874
+ return /* @__PURE__ */ jsxs8(Flex3, { vertical: true, gap: size === "small" ? "small" : "middle", children: [
1875
+ visibleData.map((item) => /* @__PURE__ */ jsx11("div", { onClick: () => handleItemClick(item), children: /* @__PURE__ */ jsxs8(Card5, { size: styles.cardSize, style: getCardStyle(item), children: [
1876
+ /* @__PURE__ */ jsx11(DownloadButton, { item }),
1877
+ /* @__PURE__ */ jsx11(
1878
+ Attachments.FileCard,
1879
+ {
1880
+ style: getFileCardStyle(item),
1881
+ item: {
1882
+ name: item.name,
1883
+ size: item.size,
1884
+ uid: item.id,
1885
+ description: renderFileDescription(item)
1886
+ }
1887
+ }
1888
+ ),
1889
+ item.files && /* @__PURE__ */ jsxs8("div", { style: { paddingLeft: "12px" }, children: [
1890
+ /* @__PURE__ */ jsxs8(Text8, { type: "secondary", style: { fontSize: "12px" }, children: [
1891
+ "\u5305\u542B\u6587\u4EF6(",
1892
+ item.files.length,
1893
+ ")"
1894
+ ] }),
1895
+ /* @__PURE__ */ jsx11(
1896
+ AttachmentsCard,
1897
+ {
1898
+ data: item.files,
1899
+ component_key: `${component_key}_${item.id}`,
1900
+ eventHandler,
1901
+ size: "small",
1902
+ columns: 2,
1903
+ showDownloadButton
1904
+ }
1905
+ )
1906
+ ] })
1907
+ ] }) }, item.id)),
1908
+ shouldShowViewMore && /* @__PURE__ */ jsx11(
1909
+ Button4,
1910
+ {
1911
+ type: "link",
1912
+ size: "small",
1913
+ onClick: (evt) => {
1914
+ evt.stopPropagation();
1915
+ setShowAll(!showAll);
1916
+ },
1917
+ style: { alignSelf: "center" },
1918
+ children: showAll ? "\u663E\u793A\u66F4\u5C11" : `\u663E\u793A\u66F4\u591A (${displayData.length - 4})`
1919
+ }
1920
+ )
1921
+ ] });
1922
+ };
1923
+
1924
+ // src/components/GenUI/elements/attachments_viewer_side_app.tsx
1925
+ import { Button as Button5, Empty as Empty2, Skeleton } from "antd";
1926
+ import { useState as useState9 } from "react";
1927
+ import { Fragment, jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
1928
+ function AttachmentsViewerSideApp({
1929
+ data,
1930
+ eventHandler,
1931
+ component_key
1932
+ }) {
1933
+ const [fileUri, setFileUri] = useState9();
1934
+ const [loading, setLoading] = useState9(true);
1935
+ const { file_id } = data ?? {};
1936
+ if (loading) {
1937
+ return /* @__PURE__ */ jsx12(Skeleton, { active: true });
1938
+ }
1939
+ const canPreviewInIframe = (fileName) => {
1940
+ if (!fileName) return false;
1941
+ const extension = fileName?.split(".").pop()?.toLowerCase() || "";
1942
+ const previewableExtensions = [
1943
+ // PDF文档
1944
+ "pdf",
1945
+ // 图片类型
1946
+ "jpg",
1947
+ "jpeg",
1948
+ "png",
1949
+ "gif",
1950
+ "svg",
1951
+ "bmp",
1952
+ "webp",
1953
+ // 文本类型
1954
+ "txt",
1955
+ "csv",
1956
+ "json",
1957
+ "xml",
1958
+ // 网页类型
1959
+ "html",
1960
+ "htm",
1961
+ // 音频类型
1962
+ "mp3",
1963
+ "wav",
1964
+ "ogg",
1965
+ // 视频类型
1966
+ "mp4",
1967
+ "webm"
1968
+ ];
1969
+ return previewableExtensions.includes(extension);
1970
+ };
1971
+ const isPreviewable = fileUri?.fileName ? canPreviewInIframe(fileUri.fileName) : false;
1972
+ return isPreviewable ? /* @__PURE__ */ jsx12(
1973
+ "iframe",
1974
+ {
1975
+ style: { width: "100%", height: "100%", border: 0 },
1976
+ src: fileUri?.url
1977
+ }
1978
+ ) : /* @__PURE__ */ jsx12(
1979
+ Empty2,
1980
+ {
1981
+ description: /* @__PURE__ */ jsxs9(Fragment, { children: [
1982
+ /* @__PURE__ */ jsx12("div", { children: "\u6682\u65F6\u4E0D\u652F\u6301\u9884\u89C8\uFF0C\u8BF7\u4E0B\u8F7D\u540E\u67E5\u770B\u3002" }),
1983
+ /* @__PURE__ */ jsxs9(Button5, { type: "link", href: fileUri?.url, download: fileUri?.fileName, children: [
1984
+ "\u4E0B\u8F7D",
1985
+ fileUri?.fileName
1986
+ ] })
1987
+ ] }),
1988
+ image: Empty2.PRESENTED_IMAGE_DEFAULT
1989
+ }
1990
+ );
1991
+ }
1992
+
1993
+ // src/components/GenUI/elements/WriteFile.tsx
1994
+ import { Button as Button6, Space as Space8, Typography as Typography8 } from "antd";
1995
+
1996
+ // src/components/GenUI/elements/ContentPreviewCollapse.tsx
1997
+ import { useRef as useRef3, useState as useState10, useEffect as useEffect6, useCallback as useCallback5 } from "react";
1998
+ import { Collapse as Collapse4 } from "antd";
1999
+ import { createStyles as createStyles5 } from "antd-style";
2000
+ import { DownOutlined as DownOutlined2, UpOutlined } from "@ant-design/icons";
2001
+ import CollapsePanel3 from "antd/es/collapse/CollapsePanel";
2002
+ import { Fragment as Fragment2, jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
2003
+ var DEFAULT_COLLAPSED_MAX_HEIGHT = 180;
2004
+ var DEFAULT_EXPANDED_MAX_HEIGHT = 500;
2005
+ var useStyle4 = createStyles5(
2006
+ ({ css }, { showShadow }) => ({
2007
+ collapse: css`
2008
+ .ant-collapse-header {
2009
+ position: relative;
2010
+ z-index: 1;
2011
+ transition: box-shadow 0.2s ease;
2012
+ box-shadow: ${showShadow ? "0 4px 8px -2px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)" : "none"};
2013
+ }
2014
+
2015
+ .ant-collapse-content-box {
2016
+ padding-top: 0 !important;
2017
+ }
2018
+ `,
2019
+ contentContainer: css`
2020
+ position: relative;
2021
+ overflow: hidden;
2022
+ display: flex;
2023
+ flex-direction: column;
2024
+ justify-content: flex-end;
2025
+
2026
+ &.expanded {
2027
+ overflow: auto;
2028
+ display: block;
2029
+ }
2030
+ `,
2031
+ content: css`
2032
+ flex-shrink: 0;
2033
+ `,
2034
+ toggleButton: css`
2035
+ display: flex;
2036
+ align-items: center;
2037
+ justify-content: center;
2038
+ gap: 4px;
2039
+ padding: 8px 0;
2040
+ margin-top: 8px;
2041
+ border-top: 1px solid rgba(0, 0, 0, 0.06);
2042
+ cursor: pointer;
2043
+ color: #1890ff;
2044
+ font-size: 12px;
2045
+ user-select: none;
2046
+ transition: color 0.2s;
2047
+
2048
+ &:hover {
2049
+ color: #40a9ff;
2050
+ }
2051
+ `
2052
+ })
2053
+ );
2054
+ var ContentPreviewCollapse = ({
2055
+ panelKey,
2056
+ header,
2057
+ extra,
2058
+ expandIcon,
2059
+ children,
2060
+ collapsedMaxHeight = DEFAULT_COLLAPSED_MAX_HEIGHT,
2061
+ expandedMaxHeight = DEFAULT_EXPANDED_MAX_HEIGHT,
2062
+ defaultExpanded = true,
2063
+ minWidth = 400,
2064
+ showAllText = "Show all content",
2065
+ showLessText = "Show less"
2066
+ }) => {
2067
+ const [showFullContent, setShowFullContent] = useState10(false);
2068
+ const [isOverflowing, setIsOverflowing] = useState10(false);
2069
+ const contentRef = useRef3(null);
2070
+ const showShadow = isOverflowing && !showFullContent;
2071
+ const { styles, cx } = useStyle4({ showShadow });
2072
+ const checkOverflow = useCallback5(() => {
2073
+ if (contentRef.current) {
2074
+ const scrollHeight = contentRef.current.scrollHeight;
2075
+ setIsOverflowing(scrollHeight > collapsedMaxHeight);
2076
+ }
2077
+ }, [collapsedMaxHeight]);
2078
+ useEffect6(() => {
2079
+ const element = contentRef.current;
2080
+ if (!element) return;
2081
+ checkOverflow();
2082
+ const resizeObserver = new ResizeObserver(() => {
2083
+ checkOverflow();
2084
+ });
2085
+ resizeObserver.observe(element);
2086
+ return () => {
2087
+ resizeObserver.disconnect();
2088
+ };
2089
+ }, [children, checkOverflow]);
2090
+ const handleToggleContent = (e) => {
2091
+ e.stopPropagation();
2092
+ setShowFullContent(!showFullContent);
2093
+ };
2094
+ return /* @__PURE__ */ jsx13(
2095
+ Collapse4,
2096
+ {
2097
+ className: styles.collapse,
2098
+ size: "small",
2099
+ bordered: false,
2100
+ defaultActiveKey: defaultExpanded ? [panelKey] : [],
2101
+ expandIcon,
2102
+ children: /* @__PURE__ */ jsxs10(
2103
+ CollapsePanel3,
2104
+ {
2105
+ header,
2106
+ extra,
2107
+ style: { minWidth },
2108
+ children: [
2109
+ /* @__PURE__ */ jsx13(
2110
+ "div",
2111
+ {
2112
+ className: cx(styles.contentContainer, showFullContent && "expanded"),
2113
+ style: {
2114
+ maxHeight: showFullContent ? expandedMaxHeight : collapsedMaxHeight
2115
+ },
2116
+ children: /* @__PURE__ */ jsx13("div", { ref: contentRef, className: styles.content, children })
2117
+ }
2118
+ ),
2119
+ isOverflowing && /* @__PURE__ */ jsx13("div", { className: styles.toggleButton, onClick: handleToggleContent, children: showFullContent ? /* @__PURE__ */ jsxs10(Fragment2, { children: [
2120
+ /* @__PURE__ */ jsx13(UpOutlined, { style: { fontSize: 10 } }),
2121
+ /* @__PURE__ */ jsx13("span", { children: showLessText })
2122
+ ] }) : /* @__PURE__ */ jsxs10(Fragment2, { children: [
2123
+ /* @__PURE__ */ jsx13(DownOutlined2, { style: { fontSize: 10 } }),
2124
+ /* @__PURE__ */ jsx13("span", { children: showAllText })
2125
+ ] }) })
2126
+ ]
2127
+ },
2128
+ panelKey
2129
+ )
2130
+ }
2131
+ );
2132
+ };
2133
+
2134
+ // src/components/GenUI/elements/WriteFile.tsx
2135
+ import { jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
2136
+ var { Text: Text6 } = Typography8;
2137
+ var WriteFile = ({
2138
+ data,
2139
+ component_key,
2140
+ eventHandler,
2141
+ interactive = true
2142
+ }) => {
2143
+ const toolCallData = data;
2144
+ const { file_path, content } = toolCallData?.args || {};
2145
+ if (!toolCallData) {
2146
+ return null;
2147
+ }
2148
+ const expandIcon = () => getFileIcon(file_path);
2149
+ const header = /* @__PURE__ */ jsxs11(Space8, { children: [
2150
+ /* @__PURE__ */ jsx14(Text6, { strong: true, children: "New" }),
2151
+ /* @__PURE__ */ jsx14(Text6, { title: file_path, children: file_path?.split("/")?.pop() || "" })
2152
+ ] });
2153
+ const handleItemClick = (toolCallData2) => {
2154
+ eventHandler?.(
2155
+ "__open_side_app",
2156
+ {
2157
+ component_key: "file_content_diff_view",
2158
+ message: file_path,
2159
+ data: {
2160
+ old_code: "",
2161
+ new_code: content
2162
+ }
2163
+ },
2164
+ ""
2165
+ );
2166
+ };
2167
+ return /* @__PURE__ */ jsx14(
2168
+ ContentPreviewCollapse,
2169
+ {
2170
+ panelKey: toolCallData.id,
2171
+ header,
2172
+ expandIcon,
2173
+ extra: /* @__PURE__ */ jsx14(
2174
+ Button6,
2175
+ {
2176
+ type: "link",
2177
+ size: "small",
2178
+ onClick: (evt) => {
2179
+ evt.stopPropagation();
2180
+ handleItemClick(toolCallData);
2181
+ },
2182
+ children: "Diff View"
2183
+ }
2184
+ ),
2185
+ children: /* @__PURE__ */ jsx14(MDResponse, { content })
2186
+ }
2187
+ );
2188
+ };
2189
+
2190
+ // src/components/GenUI/elements/file_content_diff_view.tsx
2191
+ import ReactDiffViewer from "@alexbruf/react-diff-viewer";
2192
+ import "@alexbruf/react-diff-viewer/index.css";
2193
+ import { jsx as jsx15 } from "react/jsx-runtime";
2194
+ var FileContentDiffView = ({
2195
+ data,
2196
+ eventHandler,
2197
+ interactive = true,
2198
+ default_open_in_side_app = true
2199
+ }) => {
2200
+ const { old_code, new_code } = data;
2201
+ return /* @__PURE__ */ jsx15(
2202
+ ReactDiffViewer,
2203
+ {
2204
+ oldValue: old_code,
2205
+ newValue: new_code,
2206
+ splitView: false
2207
+ }
2208
+ );
2209
+ };
2210
+
2211
+ // src/components/GenUI/elements/EditFile.tsx
2212
+ import { Button as Button7, Space as Space9, Typography as Typography9 } from "antd";
2213
+ import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
2214
+ var { Text: Text7 } = Typography9;
2215
+ var EditFile = ({
2216
+ data,
2217
+ component_key,
2218
+ eventHandler,
2219
+ interactive = true
2220
+ }) => {
2221
+ const toolCallData = data;
2222
+ const { file_path, new_string, old_string } = toolCallData?.args || {};
2223
+ if (!toolCallData) {
2224
+ return null;
2225
+ }
2226
+ const expandIcon = () => getFileIcon(file_path);
2227
+ const header = /* @__PURE__ */ jsxs12(Space9, { children: [
2228
+ /* @__PURE__ */ jsx16(Text7, { strong: true, children: "Edit" }),
2229
+ /* @__PURE__ */ jsx16(Text7, { title: file_path, children: file_path?.split("/")?.pop() || "" })
2230
+ ] });
2231
+ const handleItemClick = (toolCallData2) => {
2232
+ eventHandler?.(
2233
+ "__open_side_app",
2234
+ {
2235
+ component_key: "file_content_diff_view",
2236
+ message: file_path,
2237
+ data: {
2238
+ old_code: old_string,
2239
+ new_code: new_string
2240
+ }
2241
+ },
2242
+ ""
2243
+ );
2244
+ };
2245
+ return /* @__PURE__ */ jsx16(
2246
+ ContentPreviewCollapse,
2247
+ {
2248
+ panelKey: toolCallData.id,
2249
+ header,
2250
+ expandIcon,
2251
+ extra: /* @__PURE__ */ jsx16(
2252
+ Button7,
2253
+ {
2254
+ type: "link",
2255
+ size: "small",
2256
+ onClick: (evt) => {
2257
+ evt.stopPropagation();
2258
+ handleItemClick(toolCallData);
2259
+ },
2260
+ children: "Diff View"
2261
+ }
2262
+ ),
2263
+ children: /* @__PURE__ */ jsx16(MDResponse, { content: new_string })
2264
+ }
2265
+ );
2266
+ };
2267
+
2268
+ // src/components/GenUI/elements/builtIns.tsx
1237
2269
  var elements = {
1238
2270
  action_show_attachments_uploader: {
1239
2271
  card_view: () => null,
@@ -1256,8 +2288,31 @@ var elements = {
1256
2288
  },
1257
2289
  todo_list: {
1258
2290
  card_view: Todo
2291
+ },
2292
+ write_todos: {
2293
+ card_view: WriteTodos
2294
+ },
2295
+ write_file: {
2296
+ card_view: WriteFile
2297
+ },
2298
+ edit_file: {
2299
+ card_view: EditFile
2300
+ },
2301
+ file_explorer: {
2302
+ card_view: () => null,
2303
+ side_app_view: FileExplorer
2304
+ },
2305
+ attachments: {
2306
+ card_view: AttachmentsCard,
2307
+ side_app_view: AttachmentsViewerSideApp
2308
+ },
2309
+ file_content_diff_view: {
2310
+ card_view: FileContentDiffView,
2311
+ side_app_view: FileContentDiffView
1259
2312
  }
1260
2313
  };
2314
+
2315
+ // src/components/GenUI/elements/index.tsx
1261
2316
  var getElement = (language) => {
1262
2317
  if (language && elements[language]) {
1263
2318
  return elements[language];
@@ -1272,15 +2327,15 @@ var regsiterElement = (language, ElementMeta) => {
1272
2327
 
1273
2328
  // src/components/GenUI/MDMermaid.tsx
1274
2329
  import mermaid from "mermaid";
1275
- import { useEffect as useEffect4, useRef as useRef3 } from "react";
2330
+ import { useEffect as useEffect7, useRef as useRef4 } from "react";
1276
2331
  import { v4 } from "uuid";
1277
- import { jsx as jsx8 } from "react/jsx-runtime";
2332
+ import { jsx as jsx17 } from "react/jsx-runtime";
1278
2333
  var MDMermaid = ({ children = [] }) => {
1279
- const domId = useRef3(`dom${v4()}`);
2334
+ const domId = useRef4(`dom${v4()}`);
1280
2335
  const code = String(children);
1281
- const target = useRef3(null);
1282
- const targetInternal = useRef3(null);
1283
- useEffect4(() => {
2336
+ const target = useRef4(null);
2337
+ const targetInternal = useRef4(null);
2338
+ useEffect7(() => {
1284
2339
  if (target.current && code) {
1285
2340
  mermaid.initialize({
1286
2341
  startOnLoad: true,
@@ -1342,13 +2397,13 @@ var MDMermaid = ({ children = [] }) => {
1342
2397
  });
1343
2398
  }
1344
2399
  }, [code]);
1345
- return /* @__PURE__ */ jsx8("div", { style: { minWidth: 750 }, ref: target, children: /* @__PURE__ */ jsx8("code", { id: domId.current, style: { display: "none" } }) });
2400
+ return /* @__PURE__ */ jsx17("div", { style: { minWidth: 750 }, ref: target, children: /* @__PURE__ */ jsx17("code", { id: domId.current, style: { display: "none" } }) });
1346
2401
  };
1347
2402
 
1348
2403
  // src/components/GenUI/MDResponse.tsx
1349
- import { jsx as jsx9 } from "react/jsx-runtime";
2404
+ import { jsx as jsx18 } from "react/jsx-runtime";
1350
2405
  var SyntaxHighlighter = Prism;
1351
- var useStyles = createStyles4(({ token, css }) => ({
2406
+ var useStyles2 = createStyles6(({ token, css }) => ({
1352
2407
  markdownTableContainer: css`
1353
2408
  overflow-x: auto;
1354
2409
  width: 100%;
@@ -1437,26 +2492,26 @@ var MDResponse = ({
1437
2492
  noGenUI,
1438
2493
  eventHandler
1439
2494
  }) => {
1440
- const { styles } = useStyles();
1441
- const config = useMemo2(
2495
+ const { styles } = useStyles2();
2496
+ const config = useMemo3(
1442
2497
  () => ({
1443
2498
  components: {
1444
2499
  a({ node, ...props }) {
1445
2500
  if (embeddedLink) {
1446
- return /* @__PURE__ */ jsx9(IFrameCard, { src: props.href });
1447
- } else return /* @__PURE__ */ jsx9("a", { ...props });
2501
+ return /* @__PURE__ */ jsx18(IFrameCard, { src: props.href });
2502
+ } else return /* @__PURE__ */ jsx18("a", { ...props });
1448
2503
  },
1449
2504
  table({ node, ...props }) {
1450
- return /* @__PURE__ */ jsx9("div", { className: styles.markdownTableContainer, children: /* @__PURE__ */ jsx9("table", { className: styles.markdownTable, ...props }) });
2505
+ return /* @__PURE__ */ jsx18("div", { className: styles.markdownTableContainer, children: /* @__PURE__ */ jsx18("table", { className: styles.markdownTable, ...props }) });
1451
2506
  },
1452
2507
  th({ node, ...props }) {
1453
- return /* @__PURE__ */ jsx9("th", { className: styles.markdownTh, ...props });
2508
+ return /* @__PURE__ */ jsx18("th", { className: styles.markdownTh, ...props });
1454
2509
  },
1455
2510
  td({ node, ...props }) {
1456
- return /* @__PURE__ */ jsx9("td", { className: styles.markdownTd, ...props });
2511
+ return /* @__PURE__ */ jsx18("td", { className: styles.markdownTd, ...props });
1457
2512
  },
1458
2513
  tr({ node, ...props }) {
1459
- return /* @__PURE__ */ jsx9("tr", { className: styles.markdownTr, ...props });
2514
+ return /* @__PURE__ */ jsx18("tr", { className: styles.markdownTr, ...props });
1460
2515
  },
1461
2516
  code({ children, className, node, ...rest }) {
1462
2517
  const match = /language-(\w+)/.exec(className || "");
@@ -1469,23 +2524,23 @@ var MDResponse = ({
1469
2524
  childrenData = JSON.parse(children);
1470
2525
  } catch (error) {
1471
2526
  }
1472
- return /* @__PURE__ */ jsx9(
2527
+ return /* @__PURE__ */ jsx18(
1473
2528
  Element,
1474
2529
  {
1475
2530
  interactive,
1476
2531
  component_key: language,
1477
2532
  data: childrenData,
1478
- eventHandler: (e, data, message2, agent) => {
1479
- eventHandler?.(e, data, message2, agent);
2533
+ eventHandler: (e, data, message3, agent) => {
2534
+ eventHandler?.(e, data, message3, agent);
1480
2535
  }
1481
2536
  }
1482
2537
  );
1483
2538
  }
1484
2539
  switch (language) {
1485
2540
  case "mermaid":
1486
- return /* @__PURE__ */ jsx9(MDMermaid, { children });
2541
+ return /* @__PURE__ */ jsx18(MDMermaid, { children });
1487
2542
  default:
1488
- return /* @__PURE__ */ jsx9(
2543
+ return /* @__PURE__ */ jsx18(
1489
2544
  SyntaxHighlighter,
1490
2545
  {
1491
2546
  ...rest,
@@ -1497,7 +2552,7 @@ var MDResponse = ({
1497
2552
  );
1498
2553
  }
1499
2554
  } else {
1500
- return /* @__PURE__ */ jsx9("code", { ...rest, className, children });
2555
+ return /* @__PURE__ */ jsx18("code", { ...rest, className, children });
1501
2556
  }
1502
2557
  }
1503
2558
  },
@@ -1506,15 +2561,15 @@ var MDResponse = ({
1506
2561
  }),
1507
2562
  [userData, interactive, embeddedLink, styles]
1508
2563
  );
1509
- return /* @__PURE__ */ jsx9("div", { className: styles.markdownContainer, children: /* @__PURE__ */ jsx9(ReactMarkdown, { ...config, children: content }) });
2564
+ return /* @__PURE__ */ jsx18("div", { className: styles.markdownContainer, children: /* @__PURE__ */ jsx18(ReactMarkdown, { ...config, children: content }) });
1510
2565
  };
1511
2566
  var MDViewFormItem = ({ value }) => {
1512
- return /* @__PURE__ */ jsx9(MDResponse, { content: value || "" });
2567
+ return /* @__PURE__ */ jsx18(MDResponse, { content: value || "" });
1513
2568
  };
1514
2569
  var IFrameCard = ({ src }) => {
1515
- const containerRef = useRef4(null);
1516
- const [width, setWidth] = useState7("640px");
1517
- const [height, setHeight] = useState7("320px");
2570
+ const containerRef = useRef5(null);
2571
+ const [width, setWidth] = useState11("640px");
2572
+ const [height, setHeight] = useState11("320px");
1518
2573
  const valid_images = [
1519
2574
  "jpg",
1520
2575
  "jpeg",
@@ -1531,9 +2586,9 @@ var IFrameCard = ({ src }) => {
1531
2586
  }
1532
2587
  const spitedSrc = src.split(".");
1533
2588
  if (valid_images.includes(spitedSrc[spitedSrc.length - 1].toLowerCase())) {
1534
- return /* @__PURE__ */ jsx9("div", { children: /* @__PURE__ */ jsx9("img", { src, style: { width: "100%" } }) });
2589
+ return /* @__PURE__ */ jsx18("div", { children: /* @__PURE__ */ jsx18("img", { src, style: { width: "100%" } }) });
1535
2590
  } else {
1536
- return /* @__PURE__ */ jsx9("div", { children: /* @__PURE__ */ jsx9("a", { href: src, target: "_black", children: src }) });
2591
+ return /* @__PURE__ */ jsx18("div", { children: /* @__PURE__ */ jsx18("a", { href: src, target: "_black", children: src }) });
1537
2592
  }
1538
2593
  };
1539
2594
 
@@ -1541,11 +2596,10 @@ var IFrameCard = ({ src }) => {
1541
2596
  import {
1542
2597
  CloudUploadOutlined,
1543
2598
  PaperClipOutlined,
1544
- FileTextOutlined as FileTextOutlined2,
1545
- CheckSquareOutlined
2599
+ FileTextOutlined as FileTextOutlined3
1546
2600
  } from "@ant-design/icons";
1547
2601
  import {
1548
- Attachments,
2602
+ Attachments as Attachments2,
1549
2603
  Bubble,
1550
2604
  Prompts,
1551
2605
  Sender,
@@ -1555,224 +2609,34 @@ import {
1555
2609
  Alert as Alert2,
1556
2610
  Avatar,
1557
2611
  Badge,
1558
- Button as Button3,
1559
- Flex as Flex3,
1560
- Space as Space6,
1561
- message,
1562
- Modal,
1563
- Tooltip,
1564
- Popover
2612
+ Button as Button8,
2613
+ Flex as Flex5,
2614
+ Space as Space10,
2615
+ message as message2,
2616
+ Tooltip as Tooltip2,
2617
+ Popover,
2618
+ Progress
1565
2619
  } from "antd";
1566
2620
  import ErrorBoundary from "antd/es/alert/ErrorBoundary";
1567
- import React3, {
2621
+ import React4, {
1568
2622
  memo,
1569
- useCallback as useCallback5,
1570
- useEffect as useEffect6,
2623
+ useCallback as useCallback6,
2624
+ useEffect as useEffect8,
1571
2625
  useMemo as useMemo4,
1572
- useRef as useRef5,
1573
- useState as useState9
2626
+ useRef as useRef6,
2627
+ useState as useState12
1574
2628
  } from "react";
1575
2629
  import { useTranslation } from "react-i18next";
1576
-
1577
- // src/components/FileExplorer.tsx
1578
- import { useState as useState8, useEffect as useEffect5, useMemo as useMemo3 } from "react";
1579
- import { Tabs, Empty } from "antd";
1580
- import {
1581
- FileOutlined,
1582
- FileTextOutlined,
1583
- FileMarkdownOutlined,
1584
- FileImageOutlined,
1585
- CodeOutlined as CodeOutlined2,
1586
- Html5Outlined,
1587
- FileUnknownOutlined
1588
- } from "@ant-design/icons";
1589
- import { createStyles as createStyles5 } from "antd-style";
1590
- import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
1591
- var useStyles2 = createStyles5(({ token, css }) => ({
1592
- container: css`
1593
- height: 100%;
1594
- background: ${token.colorBgContainer};
1595
- border: 1px solid ${token.colorBorder};
1596
- border-radius: ${token.borderRadiusLG}px;
1597
- overflow: hidden;
1598
- display: flex;
1599
- flex-direction: column;
1600
- `,
1601
- tabs: css`
1602
- height: 100%;
1603
-
1604
- .ant-tabs-nav {
1605
- margin-bottom: 0 !important;
1606
- padding: 0 16px;
1607
- border-bottom: 1px solid ${token.colorBorderSecondary};
1608
- }
1609
-
1610
- .ant-tabs-content-holder {
1611
- height: 100%;
1612
- overflow: hidden;
1613
- }
1614
-
1615
- .ant-tabs-content {
1616
- height: 100%;
1617
- }
1618
-
1619
- .ant-tabs-tabpane {
1620
- height: 100%;
1621
- outline: none;
1622
- }
1623
- `,
1624
- contentBody: css`
1625
- padding: 24px;
1626
- height: 100%;
1627
- overflow-y: auto;
1628
-
1629
- pre {
1630
- margin: 0 !important;
1631
- border-radius: ${token.borderRadius}px !important;
1632
- }
1633
- `,
1634
- emptyState: css`
1635
- display: flex;
1636
- flex-direction: column;
1637
- align-items: center;
1638
- justify-content: center;
1639
- height: 100%;
1640
- color: ${token.colorTextQuaternary};
1641
- `
1642
- }));
1643
- var getFileIcon = (filename) => {
1644
- const ext = filename.split(".").pop()?.toLowerCase();
1645
- switch (ext) {
1646
- case "ts":
1647
- case "tsx":
1648
- case "js":
1649
- case "jsx":
1650
- return /* @__PURE__ */ jsx10(CodeOutlined2, {});
1651
- case "html":
1652
- return /* @__PURE__ */ jsx10(Html5Outlined, {});
1653
- case "css":
1654
- case "less":
1655
- case "scss":
1656
- return /* @__PURE__ */ jsx10(FileUnknownOutlined, {});
1657
- // Or a style icon if available
1658
- case "md":
1659
- return /* @__PURE__ */ jsx10(FileMarkdownOutlined, {});
1660
- case "json":
1661
- return /* @__PURE__ */ jsx10(FileTextOutlined, {});
1662
- case "png":
1663
- case "jpg":
1664
- case "jpeg":
1665
- case "gif":
1666
- case "svg":
1667
- return /* @__PURE__ */ jsx10(FileImageOutlined, {});
1668
- default:
1669
- return /* @__PURE__ */ jsx10(FileOutlined, {});
1670
- }
1671
- };
1672
- function getLanguageFromFileName(filename) {
1673
- const ext = filename.split(".").pop()?.toLowerCase();
1674
- switch (ext) {
1675
- case "ts":
1676
- case "tsx":
1677
- return "typescript";
1678
- case "js":
1679
- case "jsx":
1680
- return "javascript";
1681
- case "py":
1682
- return "python";
1683
- case "md":
1684
- return "markdown";
1685
- case "json":
1686
- return "json";
1687
- case "html":
1688
- return "html";
1689
- case "css":
1690
- return "css";
1691
- case "java":
1692
- return "java";
1693
- case "go":
1694
- return "go";
1695
- case "rs":
1696
- return "rust";
1697
- case "c":
1698
- return "c";
1699
- case "cpp":
1700
- return "cpp";
1701
- case "yaml":
1702
- case "yml":
1703
- return "yaml";
1704
- case "sql":
1705
- return "sql";
1706
- case "sh":
1707
- case "bash":
1708
- return "bash";
1709
- default:
1710
- return "text";
1711
- }
1712
- }
1713
- var FileExplorer = ({
1714
- files = [],
1715
- className,
1716
- style,
1717
- title = "EXPLORER"
1718
- }) => {
1719
- const { styles, cx } = useStyles2();
1720
- const [fileList, setFileList] = useState8([]);
1721
- useEffect5(() => {
1722
- if (Array.isArray(files)) {
1723
- setFileList(files);
1724
- } else {
1725
- const list = Object.keys(files).map((key) => ({
1726
- name: key,
1727
- content: files[key]
1728
- }));
1729
- setFileList(list);
1730
- }
1731
- }, [files]);
1732
- const items = useMemo3(() => {
1733
- return fileList.map((file) => {
1734
- const language = file.language || getLanguageFromFileName(file.name);
1735
- const content = `\`\`\`${language}
1736
- ${file.content}
1737
- \`\`\``;
1738
- return {
1739
- key: file.name,
1740
- label: /* @__PURE__ */ jsxs6("span", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
1741
- getFileIcon(file.name),
1742
- file.name
1743
- ] }),
1744
- children: /* @__PURE__ */ jsx10("div", { className: styles.contentBody, children: /* @__PURE__ */ jsx10(MDResponse, { content }) })
1745
- };
1746
- });
1747
- }, [fileList, styles]);
1748
- return /* @__PURE__ */ jsx10("div", { className: cx(styles.container, className), style, children: fileList.length > 0 ? /* @__PURE__ */ jsx10(
1749
- Tabs,
1750
- {
1751
- defaultActiveKey: fileList[0]?.name,
1752
- items,
1753
- className: styles.tabs,
1754
- tabBarStyle: { margin: 0 }
1755
- }
1756
- ) : /* @__PURE__ */ jsx10("div", { className: styles.emptyState, children: /* @__PURE__ */ jsx10(
1757
- Empty,
1758
- {
1759
- description: "No file selected",
1760
- image: Empty.PRESENTED_IMAGE_SIMPLE
1761
- }
1762
- ) }) });
1763
- };
1764
-
1765
- // src/components/Chat/Chating.tsx
1766
- import { Fragment, jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
2630
+ import { Fragment as Fragment3, jsx as jsx19, jsxs as jsxs13 } from "react/jsx-runtime";
1767
2631
  var LazyBubble = ({
1768
- message: message2,
2632
+ message: message3,
1769
2633
  renderContent,
1770
2634
  autoLoadRightPanel
1771
2635
  }) => {
1772
- const ref = useRef5(null);
1773
- const [isVisible, setIsVisible] = useState9(false);
1774
- const [wasEverVisible, setWasEverVisible] = useState9(false);
1775
- useEffect6(() => {
2636
+ const ref = useRef6(null);
2637
+ const [isVisible, setIsVisible] = useState12(false);
2638
+ const [wasEverVisible, setWasEverVisible] = useState12(false);
2639
+ useEffect8(() => {
1776
2640
  const observer = new IntersectionObserver(
1777
2641
  ([entry]) => {
1778
2642
  const visible = entry.isIntersecting;
@@ -1792,21 +2656,21 @@ var LazyBubble = ({
1792
2656
  }
1793
2657
  };
1794
2658
  }, [wasEverVisible]);
1795
- useEffect6(() => {
2659
+ useEffect8(() => {
1796
2660
  autoLoadRightPanel?.();
1797
2661
  }, []);
1798
2662
  const getPlaceholder = () => {
1799
- const estimatedHeight = message2.content ? Math.min(100, message2.content.length / 5) : 100;
1800
- return /* @__PURE__ */ jsx11("div", { style: { height: `${estimatedHeight}px`, minHeight: "50px" } });
2663
+ const estimatedHeight = message3.content ? Math.min(100, message3.content.length / 5) : 100;
2664
+ return /* @__PURE__ */ jsx19("div", { style: { height: `${estimatedHeight}px`, minHeight: "50px" } });
1801
2665
  };
1802
- return /* @__PURE__ */ jsx11(ErrorBoundary, { children: /* @__PURE__ */ jsx11("div", { ref, style: { width: "100%" }, children: isVisible || wasEverVisible ? renderContent(message2) : getPlaceholder() }) });
2666
+ return /* @__PURE__ */ jsx19(ErrorBoundary, { children: /* @__PURE__ */ jsx19("div", { ref, style: { width: "100%" }, children: isVisible || wasEverVisible ? renderContent(message3) : getPlaceholder() }) });
1803
2667
  };
1804
2668
  var MemoizedBubbleList = memo(
1805
2669
  ({
1806
2670
  items,
1807
2671
  roles,
1808
2672
  className
1809
- }) => /* @__PURE__ */ jsx11(
2673
+ }) => /* @__PURE__ */ jsx19(
1810
2674
  Bubble.List,
1811
2675
  {
1812
2676
  autoScroll: true,
@@ -1844,13 +2708,12 @@ var Chating = ({
1844
2708
  todos
1845
2709
  }) => {
1846
2710
  const { t } = useTranslation();
1847
- const [content, setContent] = useState9("");
1848
- const [attachedFiles, setAttachedFiles] = useState9([]);
1849
- const [headerOpen, setHeaderOpen] = useState9(false);
1850
- const [fileExplorerVisible, setFileExplorerVisible] = useState9(false);
1851
- const attachmentsRef = useRef5(null);
1852
- const senderRef = React3.useRef(null);
1853
- useEffect6(() => {
2711
+ const [content, setContent] = useState12("");
2712
+ const [attachedFiles, setAttachedFiles] = useState12([]);
2713
+ const [headerOpen, setHeaderOpen] = useState12(false);
2714
+ const attachmentsRef = useRef6(null);
2715
+ const senderRef = React4.useRef(null);
2716
+ useEffect8(() => {
1854
2717
  regsiterElement("action_show_attachments_uploader", {
1855
2718
  card_view: () => null,
1856
2719
  action: (data) => {
@@ -1859,19 +2722,19 @@ var Chating = ({
1859
2722
  }
1860
2723
  });
1861
2724
  }, []);
1862
- const messageLengthRef = useRef5(messages?.length ?? 0);
1863
- useEffect6(() => {
2725
+ const messageLengthRef = useRef6(messages?.length ?? 0);
2726
+ useEffect8(() => {
1864
2727
  if (messages?.length) {
1865
2728
  messageLengthRef.current = messages?.length;
1866
2729
  }
1867
2730
  }, [messages?.length]);
1868
- const renderContent = useCallback5(
1869
- (message2) => {
1870
- const { content: content2, files: files2, id } = message2;
2731
+ const renderContent = useCallback6(
2732
+ (message3) => {
2733
+ const { content: content2, files: files2, id } = message3;
1871
2734
  try {
1872
2735
  const json = JSON.parse(content2);
1873
2736
  if (json.action && json.message) {
1874
- return /* @__PURE__ */ jsx11(
2737
+ return /* @__PURE__ */ jsx19(
1875
2738
  MDResponse,
1876
2739
  {
1877
2740
  content: json.message,
@@ -1881,13 +2744,13 @@ var Chating = ({
1881
2744
  }
1882
2745
  } catch (error2) {
1883
2746
  }
1884
- const tool_calls_md = message2.tool_calls?.map((tool_call) => {
2747
+ const tool_calls_md = message3.tool_calls?.map((tool_call) => {
1885
2748
  return `\`\`\`tool_call
1886
2749
  ${JSON.stringify(tool_call)}
1887
2750
  \`\`\``;
1888
2751
  }) || [];
1889
2752
  const content_md = [content2, ...tool_calls_md].join("\n");
1890
- return /* @__PURE__ */ jsx11(Space6, { direction: "vertical", style: { width: "100%" }, children: /* @__PURE__ */ jsx11(
2753
+ return /* @__PURE__ */ jsx19(Space10, { direction: "vertical", style: { width: "100%" }, children: /* @__PURE__ */ jsx19(
1891
2754
  MDResponse,
1892
2755
  {
1893
2756
  content: content_md,
@@ -1898,17 +2761,17 @@ ${JSON.stringify(tool_call)}
1898
2761
  [handleMDResponseEvent]
1899
2762
  );
1900
2763
  const items = useMemo4(
1901
- () => messages.map((message2, index) => ({
1902
- key: message2.id,
1903
- role: message2.role,
2764
+ () => messages.map((message3, index) => ({
2765
+ key: message3.id,
2766
+ role: message3.role,
1904
2767
  typing: false,
1905
- content: /* @__PURE__ */ jsx11(
2768
+ content: /* @__PURE__ */ jsx19(
1906
2769
  LazyBubble,
1907
2770
  {
1908
- message: message2,
2771
+ message: message3,
1909
2772
  renderContent,
1910
2773
  autoLoadRightPanel: () => {
1911
- const { content: content2, role } = message2;
2774
+ const { content: content2, role } = message3;
1912
2775
  const isNewAddedMessage = messageLengthRef.current > 1 && messageLengthRef.current + 1 === messages.length;
1913
2776
  if (index === messages.length - 1 && isNewAddedMessage && role === "ai") {
1914
2777
  try {
@@ -1952,7 +2815,7 @@ ${JSON.stringify(tool_call)}
1952
2815
  const onSubmit = (nextContent) => {
1953
2816
  if (!nextContent && attachedFiles.length === 0) return;
1954
2817
  if (attachedFiles.filter((f) => f.status !== "done").length > 0) {
1955
- message.warning("\u6587\u4EF6\u8FD8\u5728\u4E0A\u4F20\u4E2D...");
2818
+ message2.warning("\u6587\u4EF6\u8FD8\u5728\u4E0A\u4F20\u4E2D...");
1956
2819
  return;
1957
2820
  }
1958
2821
  if (!nextContent && attachedFiles.length > 0) {
@@ -1996,7 +2859,7 @@ ${JSON.stringify(tool_call)}
1996
2859
  setHeaderOpen(true);
1997
2860
  }
1998
2861
  if (info.file?.response?.error || info.file.status === "error") {
1999
- message.error(
2862
+ message2.error(
2000
2863
  `${info.file.name} file upload failed.${info.file?.response?.message}`
2001
2864
  );
2002
2865
  }
@@ -2008,22 +2871,22 @@ ${JSON.stringify(tool_call)}
2008
2871
  const beforeUpload = (file) => {
2009
2872
  const isLessThan20MB = file.size / 1024 / 1024 < 20;
2010
2873
  if (!isLessThan20MB) {
2011
- message.error(
2874
+ message2.error(
2012
2875
  `File must be smaller than 20MB! ${file.name} is too large.`
2013
2876
  );
2014
2877
  return false;
2015
2878
  }
2016
2879
  return true;
2017
2880
  };
2018
- const attachmentsNode = /* @__PURE__ */ jsx11(Badge, { dot: attachedFiles.length > 0 && !headerOpen, children: /* @__PURE__ */ jsx11(
2019
- Button3,
2881
+ const attachmentsNode = /* @__PURE__ */ jsx19(Badge, { dot: attachedFiles.length > 0 && !headerOpen, children: /* @__PURE__ */ jsx19(
2882
+ Button8,
2020
2883
  {
2021
2884
  type: "text",
2022
- icon: /* @__PURE__ */ jsx11(PaperClipOutlined, {}),
2885
+ icon: /* @__PURE__ */ jsx19(PaperClipOutlined, {}),
2023
2886
  onClick: () => setHeaderOpen(!headerOpen)
2024
2887
  }
2025
2888
  ) });
2026
- const senderHeader = /* @__PURE__ */ jsx11(
2889
+ const senderHeader = /* @__PURE__ */ jsx19(
2027
2890
  Sender.Header,
2028
2891
  {
2029
2892
  title: "Attachments",
@@ -2035,8 +2898,8 @@ ${JSON.stringify(tool_call)}
2035
2898
  }
2036
2899
  },
2037
2900
  forceRender: true,
2038
- children: /* @__PURE__ */ jsx11(
2039
- Attachments,
2901
+ children: /* @__PURE__ */ jsx19(
2902
+ Attachments2,
2040
2903
  {
2041
2904
  ref: attachmentsRef,
2042
2905
  items: attachedFiles,
@@ -2057,7 +2920,7 @@ ${JSON.stringify(tool_call)}
2057
2920
  multiple: true,
2058
2921
  maxCount: 10,
2059
2922
  placeholder: (type) => ({
2060
- icon: /* @__PURE__ */ jsx11(CloudUploadOutlined, {}),
2923
+ icon: /* @__PURE__ */ jsx19(CloudUploadOutlined, {}),
2061
2924
  title: "\u4E0A\u4F20\u6587\u4EF6",
2062
2925
  description: attachment_placeholder
2063
2926
  })
@@ -2098,13 +2961,13 @@ ${JSON.stringify(tool_call)}
2098
2961
  try {
2099
2962
  } catch (error2) {
2100
2963
  }
2101
- return /* @__PURE__ */ jsx11(
2964
+ return /* @__PURE__ */ jsx19(
2102
2965
  Element,
2103
2966
  {
2104
2967
  component_key: meta.id,
2105
2968
  data: childrenData,
2106
- eventHandler: (e, data, message2, agent) => {
2107
- handleMDResponseEvent?.(e, data, message2, agent);
2969
+ eventHandler: (e, data, message3, agent) => {
2970
+ handleMDResponseEvent?.(e, data, message3, agent);
2108
2971
  }
2109
2972
  },
2110
2973
  meta.id
@@ -2114,22 +2977,22 @@ ${JSON.stringify(tool_call)}
2114
2977
  }
2115
2978
  return void 0;
2116
2979
  }, [extraMeta]);
2117
- return /* @__PURE__ */ jsxs7(Fragment, { children: [
2118
- /* @__PURE__ */ jsxs7("div", { children: [
2119
- /* @__PURE__ */ jsx11(
2980
+ return /* @__PURE__ */ jsxs13(Fragment3, { children: [
2981
+ /* @__PURE__ */ jsxs13("div", { children: [
2982
+ /* @__PURE__ */ jsx19(
2120
2983
  Welcome,
2121
2984
  {
2122
2985
  style: { padding: 8 },
2123
2986
  variant: "borderless",
2124
2987
  description,
2125
- icon: /* @__PURE__ */ jsx11(Avatar, { src: avatar || "/images/avatar.jpeg", size: 48 }),
2988
+ icon: /* @__PURE__ */ jsx19(Avatar, { src: avatar || "/images/avatar.jpeg", size: 48 }),
2126
2989
  title: name || "Fina",
2127
- extra: /* @__PURE__ */ jsxs7(Space6, { children: [
2990
+ extra: /* @__PURE__ */ jsxs13(Space10, { children: [
2128
2991
  extra,
2129
- todos && todos.length > 0 && /* @__PURE__ */ jsx11(
2992
+ todos && todos.length > 0 && /* @__PURE__ */ jsx19(
2130
2993
  Popover,
2131
2994
  {
2132
- content: /* @__PURE__ */ jsx11("div", { style: { width: 400 }, children: /* @__PURE__ */ jsx11(
2995
+ content: /* @__PURE__ */ jsx19("div", { style: { width: 400 }, children: /* @__PURE__ */ jsx19(
2133
2996
  Todo,
2134
2997
  {
2135
2998
  data: todos,
@@ -2140,37 +3003,72 @@ ${JSON.stringify(tool_call)}
2140
3003
  title: "Todos",
2141
3004
  trigger: "click",
2142
3005
  placement: "bottomRight",
2143
- children: /* @__PURE__ */ jsx11(Tooltip, { title: "Todos", children: /* @__PURE__ */ jsx11(
2144
- Badge,
3006
+ children: /* @__PURE__ */ jsx19(
3007
+ Tooltip2,
2145
3008
  {
2146
- count: todos.filter((item) => item.status !== "completed").length,
2147
- size: "small",
2148
- children: /* @__PURE__ */ jsx11(Button3, { icon: /* @__PURE__ */ jsx11(CheckSquareOutlined, {}), type: "text" })
3009
+ title: `${todos.filter((item) => item.status === "completed").length} / ${todos.length} tasks completed`,
3010
+ children: /* @__PURE__ */ jsx19("div", { style: { cursor: "pointer", display: "inline-flex" }, children: /* @__PURE__ */ jsx19(
3011
+ Progress,
3012
+ {
3013
+ type: "circle",
3014
+ strokeColor: {
3015
+ "0%": "#91caff",
3016
+ "100%": "#003eb3"
3017
+ },
3018
+ percent: Math.round(
3019
+ todos.filter((item) => item.status === "completed").length / todos.length * 100
3020
+ ),
3021
+ status: todos.some((item) => item.status === "in_progress") ? "active" : "normal",
3022
+ width: 30,
3023
+ format: () => /* @__PURE__ */ jsx19(
3024
+ "div",
3025
+ {
3026
+ style: {
3027
+ display: "flex",
3028
+ flexDirection: "column",
3029
+ alignItems: "center",
3030
+ lineHeight: 1
3031
+ },
3032
+ children: /* @__PURE__ */ jsxs13("span", { style: { fontSize: 8 }, children: [
3033
+ todos.filter(
3034
+ (item) => item.status === "completed"
3035
+ ).length,
3036
+ "/",
3037
+ todos.length
3038
+ ] })
3039
+ }
3040
+ )
3041
+ }
3042
+ ) })
2149
3043
  }
2150
- ) })
3044
+ )
2151
3045
  }
2152
3046
  ),
2153
- files && Object.keys(files).length > 0 && /* @__PURE__ */ jsx11(Tooltip, { title: "File Explorer", children: /* @__PURE__ */ jsx11(
3047
+ files && Object.keys(files).length > 0 && /* @__PURE__ */ jsx19(Tooltip2, { title: "File Explorer", children: /* @__PURE__ */ jsx19(
2154
3048
  Badge,
2155
3049
  {
2156
3050
  count: Object.keys(files).length,
2157
3051
  size: "small",
2158
3052
  color: "blue",
2159
- children: /* @__PURE__ */ jsx11(
2160
- Button3,
3053
+ children: /* @__PURE__ */ jsx19(
3054
+ Button8,
2161
3055
  {
2162
3056
  type: "text",
2163
- icon: /* @__PURE__ */ jsx11(FileTextOutlined2, {}),
2164
- onClick: () => setFileExplorerVisible(true)
3057
+ icon: /* @__PURE__ */ jsx19(FileTextOutlined3, {}),
3058
+ onClick: () => onOpenSidePanel({
3059
+ component_key: "file_explorer",
3060
+ message: "File Explorer",
3061
+ data: { files }
3062
+ })
2165
3063
  }
2166
3064
  )
2167
3065
  }
2168
3066
  ) }),
2169
- extraMetaComponents && /* @__PURE__ */ jsx11(Space6, { align: "center", style: { marginRight: 16 }, children: extraMetaComponents })
3067
+ extraMetaComponents && /* @__PURE__ */ jsx19(Space10, { align: "center", style: { marginRight: 16 }, children: extraMetaComponents })
2170
3068
  ] })
2171
3069
  }
2172
3070
  ),
2173
- /* @__PURE__ */ jsx11(
3071
+ /* @__PURE__ */ jsx19(
2174
3072
  "div",
2175
3073
  {
2176
3074
  style: {
@@ -2179,35 +3077,16 @@ ${JSON.stringify(tool_call)}
2179
3077
  }
2180
3078
  )
2181
3079
  ] }),
2182
- /* @__PURE__ */ jsx11(
2183
- Modal,
2184
- {
2185
- title: "File Explorer",
2186
- open: fileExplorerVisible,
2187
- onCancel: () => setFileExplorerVisible(false),
2188
- footer: null,
2189
- width: 1e3,
2190
- destroyOnClose: true,
2191
- styles: { body: { height: "70vh", padding: 0 } },
2192
- children: /* @__PURE__ */ jsx11(
2193
- FileExplorer,
2194
- {
2195
- files,
2196
- style: { height: "100%", border: "none" }
2197
- }
2198
- )
2199
- }
2200
- ),
2201
- items.length > 0 ? /* @__PURE__ */ jsx11(
3080
+ items.length > 0 ? /* @__PURE__ */ jsx19(
2202
3081
  MemoizedBubbleList,
2203
3082
  {
2204
3083
  items,
2205
3084
  roles,
2206
3085
  className: styles.messages
2207
3086
  }
2208
- ) : /* @__PURE__ */ jsx11("div", { style: { flex: 1 } }),
2209
- isLoading ? /* @__PURE__ */ jsx11("div", { children: /* @__PURE__ */ jsx11(Bubble, { loading: isLoading, variant: "borderless" }) }) : /* @__PURE__ */ jsx11(Prompts, { items: senderPromptsItems, onItemClick: onPromptsItemClick }),
2210
- error && /* @__PURE__ */ jsx11("div", { style: { padding: "0 16px 8px" }, children: /* @__PURE__ */ jsx11(
3087
+ ) : /* @__PURE__ */ jsx19("div", { style: { flex: 1 } }),
3088
+ isLoading ? /* @__PURE__ */ jsx19("div", { children: /* @__PURE__ */ jsx19(Bubble, { loading: isLoading, variant: "borderless" }) }) : /* @__PURE__ */ jsx19(Prompts, { items: senderPromptsItems, onItemClick: onPromptsItemClick }),
3089
+ error && /* @__PURE__ */ jsx19("div", { style: { padding: "0 16px 8px" }, children: /* @__PURE__ */ jsx19(
2211
3090
  Alert2,
2212
3091
  {
2213
3092
  type: "error",
@@ -2217,7 +3096,7 @@ ${JSON.stringify(tool_call)}
2217
3096
  message: `${error.message}`
2218
3097
  }
2219
3098
  ) }),
2220
- /* @__PURE__ */ jsx11(
3099
+ /* @__PURE__ */ jsx19(
2221
3100
  Sender,
2222
3101
  {
2223
3102
  allowSpeech: true,
@@ -2232,7 +3111,7 @@ ${JSON.stringify(tool_call)}
2232
3111
  className: styles.sender,
2233
3112
  actions: (ori, { components }) => {
2234
3113
  const { SendButton, LoadingButton } = components;
2235
- return /* @__PURE__ */ jsx11(Flex3, { justify: "space-between", align: "center", children: isLoading ? /* @__PURE__ */ jsx11(LoadingButton, { type: "default" }) : /* @__PURE__ */ jsx11(
3114
+ return /* @__PURE__ */ jsx19(Flex5, { justify: "space-between", align: "center", children: isLoading ? /* @__PURE__ */ jsx19(LoadingButton, { type: "default" }) : /* @__PURE__ */ jsx19(
2236
3115
  SendButton,
2237
3116
  {
2238
3117
  type: "primary",
@@ -2261,49 +3140,49 @@ import {
2261
3140
  import {
2262
3141
  ThoughtChain
2263
3142
  } from "@ant-design/x";
2264
- import { jsx as jsx12 } from "react/jsx-runtime";
3143
+ import { jsx as jsx20 } from "react/jsx-runtime";
2265
3144
  function getStatusIcon2(status) {
2266
3145
  switch (status) {
2267
3146
  case "success":
2268
- return /* @__PURE__ */ jsx12(CheckCircleOutlined3, {});
3147
+ return /* @__PURE__ */ jsx20(CheckCircleOutlined3, {});
2269
3148
  case "error":
2270
- return /* @__PURE__ */ jsx12(InfoCircleOutlined2, {});
3149
+ return /* @__PURE__ */ jsx20(InfoCircleOutlined2, {});
2271
3150
  case "pending":
2272
- return /* @__PURE__ */ jsx12(LoadingOutlined3, {});
3151
+ return /* @__PURE__ */ jsx20(LoadingOutlined3, {});
2273
3152
  default:
2274
- return /* @__PURE__ */ jsx12(CheckCircleOutlined3, {});
3153
+ return /* @__PURE__ */ jsx20(CheckCircleOutlined3, {});
2275
3154
  }
2276
3155
  }
2277
- var ThinkingChain = ({ message: message2 }) => {
2278
- const title = message2.name || message2.content.split("\n")[0];
3156
+ var ThinkingChain = ({ message: message3 }) => {
3157
+ const title = message3.name || message3.content.split("\n")[0];
2279
3158
  const items = [
2280
3159
  {
2281
- key: message2.id,
3160
+ key: message3.id,
2282
3161
  title,
2283
- content: /* @__PURE__ */ jsx12(MDResponse, { content: message2.content }),
2284
- status: message2.status,
2285
- icon: getStatusIcon2(message2.status)
3162
+ content: /* @__PURE__ */ jsx20(MDResponse, { content: message3.content }),
3163
+ status: message3.status,
3164
+ icon: getStatusIcon2(message3.status)
2286
3165
  }
2287
3166
  ];
2288
- return /* @__PURE__ */ jsx12(
3167
+ return /* @__PURE__ */ jsx20(
2289
3168
  ThoughtChain,
2290
3169
  {
2291
3170
  items,
2292
- collapsible: message2.status === "success" ? true : false,
3171
+ collapsible: message3.status === "success" ? true : false,
2293
3172
  size: "small"
2294
3173
  }
2295
3174
  );
2296
3175
  };
2297
- var ThinkingChainGroup = ({ message: message2 }) => {
3176
+ var ThinkingChainGroup = ({ message: message3 }) => {
2298
3177
  const title = "\u601D\u8003\u8FC7\u7A0B";
2299
- const children = message2.items?.map((item) => ({
3178
+ const children = message3.items?.map((item) => ({
2300
3179
  key: item.id,
2301
3180
  title: item.name || item.content.split("\n")[0],
2302
- content: /* @__PURE__ */ jsx12(MDResponse, { content: item.content }),
3181
+ content: /* @__PURE__ */ jsx20(MDResponse, { content: item.content }),
2303
3182
  status: item.status,
2304
3183
  icon: getStatusIcon2(item.status)
2305
3184
  }));
2306
- return /* @__PURE__ */ jsx12(ThoughtChain, { items: children, collapsible: true, size: "small" });
3185
+ return /* @__PURE__ */ jsx20(ThoughtChain, { items: children, collapsible: true, size: "small" });
2307
3186
  };
2308
3187
 
2309
3188
  // src/components/Chat/SideAppViewBrowser.tsx
@@ -2313,11 +3192,11 @@ import {
2313
3192
  ExpandOutlined,
2314
3193
  FullscreenOutlined
2315
3194
  } from "@ant-design/icons";
2316
- import { Button as Button4, Tabs as Tabs2 } from "antd";
2317
- import { createStyles as createStyles6 } from "antd-style";
2318
- import { useEffect as useEffect7, useState as useState10 } from "react";
2319
- import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
2320
- var useStyle4 = createStyles6(({ token, css }) => {
3195
+ import { Button as Button9, Tabs } from "antd";
3196
+ import { createStyles as createStyles7 } from "antd-style";
3197
+ import { useEffect as useEffect9, useState as useState13 } from "react";
3198
+ import { jsx as jsx21, jsxs as jsxs14 } from "react/jsx-runtime";
3199
+ var useStyle5 = createStyles7(({ token, css }) => {
2321
3200
  return {
2322
3201
  tabContainer: css`
2323
3202
  .ant-tabs-content-holder {
@@ -2336,9 +3215,9 @@ var useStyle4 = createStyles6(({ token, css }) => {
2336
3215
  };
2337
3216
  });
2338
3217
  var EmptySideAppView = ({ component_key, data }) => {
2339
- return /* @__PURE__ */ jsxs8("div", { children: [
2340
- /* @__PURE__ */ jsx13("p", { children: "\u672A\u627E\u5230\u5BF9\u5E94\u7684\u7EC4\u4EF6\u89C6\u56FE" }),
2341
- /* @__PURE__ */ jsx13("pre", { children: JSON.stringify({ component_key, data }, null, 2) })
3218
+ return /* @__PURE__ */ jsxs14("div", { children: [
3219
+ /* @__PURE__ */ jsx21("p", { children: "\u672A\u627E\u5230\u5BF9\u5E94\u7684\u7EC4\u4EF6\u89C6\u56FE" }),
3220
+ /* @__PURE__ */ jsx21("pre", { children: JSON.stringify({ component_key, data }, null, 2) })
2342
3221
  ] });
2343
3222
  };
2344
3223
  var SideAppViewBrowser = ({
@@ -2347,10 +3226,10 @@ var SideAppViewBrowser = ({
2347
3226
  onClose,
2348
3227
  onChangeSize
2349
3228
  }) => {
2350
- const { styles } = useStyle4();
2351
- const [activeKey, setActiveKey] = useState10(JSON.stringify(open_uri));
2352
- const [currentSize, setCurrentSize] = useState10(open_uri.size || "large");
2353
- const [items, setItems] = useState10([]);
3229
+ const { styles } = useStyle5();
3230
+ const [activeKey, setActiveKey] = useState13(JSON.stringify(open_uri));
3231
+ const [currentSize, setCurrentSize] = useState13(open_uri.size || "large");
3232
+ const [items, setItems] = useState13([]);
2354
3233
  const add = (key, label, children) => {
2355
3234
  const newActiveKey = key;
2356
3235
  const newPanes = [...items];
@@ -2386,7 +3265,7 @@ var SideAppViewBrowser = ({
2386
3265
  remove(targetKey);
2387
3266
  }
2388
3267
  };
2389
- useEffect7(() => {
3268
+ useEffect9(() => {
2390
3269
  const SideAppView = getElement(open_uri.component_key).side_app_view || EmptySideAppView;
2391
3270
  const key = JSON.stringify(open_uri);
2392
3271
  if (items.find((item) => item.key === key)) {
@@ -2396,7 +3275,7 @@ var SideAppViewBrowser = ({
2396
3275
  add(
2397
3276
  key,
2398
3277
  open_uri.message || open_uri.data.message || "\u672A\u547D\u540D",
2399
- /* @__PURE__ */ jsx13(
3278
+ /* @__PURE__ */ jsx21(
2400
3279
  SideAppView,
2401
3280
  {
2402
3281
  component_key: open_uri.component_key,
@@ -2406,7 +3285,7 @@ var SideAppViewBrowser = ({
2406
3285
  )
2407
3286
  );
2408
3287
  }, [open_uri]);
2409
- useEffect7(() => {
3288
+ useEffect9(() => {
2410
3289
  if (open_uri.size && open_uri.size !== currentSize) {
2411
3290
  setCurrentSize(open_uri.size);
2412
3291
  }
@@ -2444,26 +3323,26 @@ var SideAppViewBrowser = ({
2444
3323
  const getSizeIcon = (size) => {
2445
3324
  switch (size) {
2446
3325
  case "middle":
2447
- return /* @__PURE__ */ jsx13(CompressOutlined, {});
3326
+ return /* @__PURE__ */ jsx21(CompressOutlined, {});
2448
3327
  case "large":
2449
- return /* @__PURE__ */ jsx13(ExpandOutlined, {});
3328
+ return /* @__PURE__ */ jsx21(ExpandOutlined, {});
2450
3329
  case "full":
2451
- return /* @__PURE__ */ jsx13(FullscreenOutlined, {});
3330
+ return /* @__PURE__ */ jsx21(FullscreenOutlined, {});
2452
3331
  default:
2453
- return /* @__PURE__ */ jsx13(ExpandOutlined, {});
3332
+ return /* @__PURE__ */ jsx21(ExpandOutlined, {});
2454
3333
  }
2455
3334
  };
2456
- return /* @__PURE__ */ jsx13(
2457
- Tabs2,
3335
+ return /* @__PURE__ */ jsx21(
3336
+ Tabs,
2458
3337
  {
2459
3338
  className: styles.tabContainer,
2460
3339
  type: "editable-card",
2461
3340
  style: { height: "100%" },
2462
3341
  hideAdd: true,
2463
3342
  tabBarExtraContent: {
2464
- right: /* @__PURE__ */ jsxs8("div", { style: { display: "flex", gap: "4px" }, children: [
2465
- /* @__PURE__ */ jsx13(
2466
- Button4,
3343
+ right: /* @__PURE__ */ jsxs14("div", { style: { display: "flex", gap: "4px" }, children: [
3344
+ /* @__PURE__ */ jsx21(
3345
+ Button9,
2467
3346
  {
2468
3347
  style: { margin: "8px 0" },
2469
3348
  size: "large",
@@ -2473,13 +3352,13 @@ var SideAppViewBrowser = ({
2473
3352
  title: `\u5F53\u524D\u5C3A\u5BF8: ${getSizeLabel(currentSize)}, \u70B9\u51FB\u5207\u6362`
2474
3353
  }
2475
3354
  ),
2476
- /* @__PURE__ */ jsx13(
2477
- Button4,
3355
+ /* @__PURE__ */ jsx21(
3356
+ Button9,
2478
3357
  {
2479
3358
  style: { margin: "8px 0" },
2480
3359
  size: "large",
2481
3360
  type: "text",
2482
- icon: /* @__PURE__ */ jsx13(CloseOutlined, {}),
3361
+ icon: /* @__PURE__ */ jsx21(CloseOutlined, {}),
2483
3362
  onClick: () => {
2484
3363
  onClose();
2485
3364
  }
@@ -2498,7 +3377,7 @@ var SideAppViewBrowser = ({
2498
3377
  // src/components/Chat/context.tsx
2499
3378
  import { createContext as createContext2 } from "react";
2500
3379
  var chatContext = createContext2({
2501
- eventHandler: (component_key, data, message2) => {
3380
+ eventHandler: (component_key, data, message3) => {
2502
3381
  }
2503
3382
  });
2504
3383
  export {
@@ -2512,7 +3391,6 @@ export {
2512
3391
  ThinkingChain,
2513
3392
  ThinkingChainGroup,
2514
3393
  chatContext,
2515
- elements,
2516
3394
  getElement,
2517
3395
  regsiterElement,
2518
3396
  useAgentGraph,