@axiom-lattice/react-sdk 2.0.4 → 2.1.0

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
@@ -41,7 +41,6 @@ __export(index_exports, {
41
41
  ThinkingChain: () => ThinkingChain,
42
42
  ThinkingChainGroup: () => ThinkingChainGroup,
43
43
  chatContext: () => chatContext,
44
- elements: () => elements,
45
44
  getElement: () => getElement,
46
45
  regsiterElement: () => regsiterElement,
47
46
  useAgentGraph: () => useAgentGraph,
@@ -156,7 +155,7 @@ function useChat(threadId, options = {}) {
156
155
  stopStreamingRef.current = null;
157
156
  }
158
157
  const { input, command, streaming = true } = data;
159
- const { message: message2, files, ...rest } = input || {};
158
+ const { message: message3, files, ...rest } = input || {};
160
159
  setState((prev) => ({
161
160
  ...prev,
162
161
  isLoading: true,
@@ -165,7 +164,7 @@ function useChat(threadId, options = {}) {
165
164
  }));
166
165
  const userMessage = {
167
166
  id: Date.now().toString(),
168
- content: message2 || command?.resume?.message || "",
167
+ content: message3 || command?.resume?.message || "",
169
168
  files,
170
169
  role: "human"
171
170
  };
@@ -607,8 +606,8 @@ var import_react_markdown = __toESM(require("react-markdown"));
607
606
  var import_react_syntax_highlighter = require("react-syntax-highlighter");
608
607
  var import_prism = require("react-syntax-highlighter/dist/cjs/styles/prism");
609
608
  var import_remark_gfm = __toESM(require("remark-gfm"));
610
- var import_react9 = require("react");
611
- var import_antd_style4 = require("antd-style");
609
+ var import_react13 = require("react");
610
+ var import_antd_style6 = require("antd-style");
612
611
  var import_rehype_raw = __toESM(require("rehype-raw"));
613
612
 
614
613
  // src/components/GenUI/elements/confirm_feedback.tsx
@@ -632,7 +631,7 @@ var ConfirmFeedback = ({
632
631
  eventHandler,
633
632
  interactive = true
634
633
  }) => {
635
- const { message: message2, type, config, feedback, options } = data ?? {};
634
+ const { message: message3, type, config, feedback, options } = data ?? {};
636
635
  const [clicked, setClicked] = (0, import_react6.useState)(false);
637
636
  const { styles } = useStyle();
638
637
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_antd.Card, { size: "small", className: `shadow-sm ${styles.card}`, bordered: false, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_antd.Space, { direction: "vertical", style: { width: "100%" }, children: [
@@ -651,7 +650,7 @@ var ConfirmFeedback = ({
651
650
  children: "\u8BF7\u6C42\u786E\u8BA4"
652
651
  }
653
652
  ),
654
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MDResponse, { content: message2 }),
653
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MDResponse, { content: message3 }),
655
654
  options ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_antd.Space, { style: { justifyContent: "flex-end", width: "100%" }, children: options?.map((option) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
656
655
  import_antd.Button,
657
656
  {
@@ -732,7 +731,7 @@ var GenericDataTable = ({
732
731
  interactive = true,
733
732
  default_open_in_side_app = true
734
733
  }) => {
735
- const { dataSource, message: message2 } = data ?? {};
734
+ const { dataSource, message: message3 } = data ?? {};
736
735
  const [expandedRowKeys, setExpandedRowKeys] = (0, import_react7.useState)([]);
737
736
  const processedData = dataSource?.map((item, index) => ({
738
737
  ...item,
@@ -814,7 +813,7 @@ var GenericDataTable = ({
814
813
  {
815
814
  size: "small",
816
815
  title: () => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_antd2.Flex, { justify: "space-between", align: "center", children: [
817
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd2.Space, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text2, { strong: true, style: { fontSize: 16 }, children: message2 || "" }) }),
816
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_antd2.Space, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text2, { strong: true, style: { fontSize: 16 }, children: message3 || "" }) }),
818
817
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_antd2.Space, { children: [
819
818
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
820
819
  import_antd2.Button,
@@ -837,8 +836,8 @@ var GenericDataTable = ({
837
836
  "__open_side_app",
838
837
  {
839
838
  component_key: "generic_data_table",
840
- message: message2 || "",
841
- data: { dataSource, message: message2 },
839
+ message: message3 || "",
840
+ data: { dataSource, message: message3 },
842
841
  size: "large"
843
842
  },
844
843
  ""
@@ -1069,9 +1068,12 @@ function getStatusIcon(status) {
1069
1068
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons3.LoadingOutlined, { style: { color: "#1890ff" } });
1070
1069
  }
1071
1070
  }
1072
- var ToolCall = ({ data }) => {
1071
+ var ToolCall = ({ data, eventHandler }) => {
1073
1072
  const toolCallData = data;
1074
1073
  const formatToolName = (name) => {
1074
+ if (!name) {
1075
+ return "";
1076
+ }
1075
1077
  return name.replace(/([a-z])([A-Z])/g, "$1 $2").split(/[_-]/).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
1076
1078
  };
1077
1079
  const formatArgsPreview = (args) => {
@@ -1128,6 +1130,14 @@ var ToolCall = ({ data }) => {
1128
1130
  const expandIcon = ({ isActive }) => {
1129
1131
  return getStatusIcon(toolCallData.status);
1130
1132
  };
1133
+ const toolCallElement = getElement(toolCallData.name.toLowerCase());
1134
+ if (toolCallElement) {
1135
+ return toolCallElement.card_view({
1136
+ data: toolCallData,
1137
+ component_key: toolCallData.id,
1138
+ eventHandler
1139
+ });
1140
+ }
1131
1141
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1132
1142
  import_antd4.Collapse,
1133
1143
  {
@@ -1159,8 +1169,8 @@ var useStyle3 = (0, import_antd_style3.createStyles)(({ token, css }) => ({
1159
1169
  max-width: 1200px;
1160
1170
  background: linear-gradient(
1161
1171
  919deg,
1162
- rgb(67 232 157 / 8%),
1163
- rgb(206 250 235 / 28%) 43%
1172
+ rgb(67 81 232 / 8%),
1173
+ rgb(249 249 249 / 28%) 43%
1164
1174
  );
1165
1175
  `,
1166
1176
  todoItem: css`
@@ -1186,100 +1196,1099 @@ var Todo = ({
1186
1196
  eventHandler,
1187
1197
  interactive = true
1188
1198
  }) => {
1189
- const { styles } = useStyle3();
1190
- const getStatusIcon3 = (status) => {
1191
- switch (status) {
1192
- case "completed":
1193
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons4.CheckCircleOutlined, { style: { color: "#52c41a" } });
1194
- case "in_progress":
1195
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons4.LoadingOutlined, { style: { color: "#1890ff" } });
1196
- case "pending":
1197
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons4.ClockCircleOutlined, { style: { color: "gray" } });
1198
- default:
1199
- return null;
1200
- }
1201
- };
1202
- const getStatusColor = (status) => {
1203
- switch (status) {
1204
- case "completed":
1205
- return "success";
1206
- case "in_progress":
1207
- return "processing";
1208
- case "pending":
1209
- return "warning";
1210
- default:
1211
- return "default";
1212
- }
1213
- };
1214
- const getStatusText = (status) => {
1215
- switch (status) {
1216
- case "completed":
1217
- return "Completed";
1218
- case "in_progress":
1219
- return "In Progress";
1220
- case "pending":
1221
- return "Pending";
1222
- default:
1223
- return status;
1224
- }
1225
- };
1226
- const getItemClassName = (status) => {
1227
- switch (status) {
1228
- case "completed":
1229
- return styles.completed;
1230
- case "in_progress":
1231
- return styles.inProgress;
1232
- case "pending":
1233
- return styles.pending;
1234
- default:
1235
- return "";
1236
- }
1237
- };
1238
- if (!data || !Array.isArray(data)) {
1239
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1240
- import_antd5.Card,
1241
- {
1242
- size: "small",
1243
- className: `shadow-sm ${styles.card}`,
1244
- bordered: false,
1245
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text4, { type: "secondary", children: "No todo items available" })
1246
- }
1247
- );
1199
+ const { styles } = useStyle3();
1200
+ const getStatusIcon3 = (status) => {
1201
+ switch (status) {
1202
+ case "completed":
1203
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons4.CheckCircleOutlined, { style: { color: "#52c41a" } });
1204
+ case "in_progress":
1205
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons4.LoadingOutlined, { style: { color: "#1890ff" } });
1206
+ case "pending":
1207
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons4.ClockCircleOutlined, { style: { color: "gray" } });
1208
+ default:
1209
+ return null;
1210
+ }
1211
+ };
1212
+ const getStatusColor = (status) => {
1213
+ switch (status) {
1214
+ case "completed":
1215
+ return "success";
1216
+ case "in_progress":
1217
+ return "processing";
1218
+ case "pending":
1219
+ return "warning";
1220
+ default:
1221
+ return "default";
1222
+ }
1223
+ };
1224
+ const getStatusText = (status) => {
1225
+ switch (status) {
1226
+ case "completed":
1227
+ return "Completed";
1228
+ case "in_progress":
1229
+ return "In Progress";
1230
+ case "pending":
1231
+ return "Pending";
1232
+ default:
1233
+ return status;
1234
+ }
1235
+ };
1236
+ const getItemClassName = (status) => {
1237
+ switch (status) {
1238
+ case "completed":
1239
+ return styles.completed;
1240
+ case "in_progress":
1241
+ return styles.inProgress;
1242
+ case "pending":
1243
+ return styles.pending;
1244
+ default:
1245
+ return "";
1246
+ }
1247
+ };
1248
+ if (!data || !Array.isArray(data)) {
1249
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1250
+ import_antd5.Card,
1251
+ {
1252
+ size: "small",
1253
+ className: `shadow-sm ${styles.card}`,
1254
+ bordered: false,
1255
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text4, { type: "secondary", children: "No todo items available" })
1256
+ }
1257
+ );
1258
+ }
1259
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_antd5.Card, { size: "small", className: `shadow-sm ${styles.card}`, bordered: false, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_antd5.Space, { direction: "vertical", style: { width: "100%" }, children: [
1260
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1261
+ import_antd5.List,
1262
+ {
1263
+ size: "small",
1264
+ dataSource: data,
1265
+ renderItem: (item, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1266
+ import_antd5.List.Item,
1267
+ {
1268
+ className: `${styles.todoItem} ${getItemClassName(item.status)}`,
1269
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_antd5.Space, { align: "center", style: { width: "100%" }, children: [
1270
+ getStatusIcon3(item.status),
1271
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text4, { style: { flex: 1 }, children: item.content })
1272
+ ] })
1273
+ }
1274
+ )
1275
+ }
1276
+ ),
1277
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text4, { type: "secondary", style: { fontSize: 12 }, children: [
1278
+ "Total items: ",
1279
+ data.length,
1280
+ " | Completed:",
1281
+ " ",
1282
+ data.filter((item) => item.status === "completed").length,
1283
+ " | In Progress:",
1284
+ " ",
1285
+ data.filter((item) => item.status === "in_progress").length,
1286
+ " | Pending: ",
1287
+ data.filter((item) => item.status === "pending").length
1288
+ ] })
1289
+ ] }) });
1290
+ };
1291
+
1292
+ // src/components/GenUI/elements/WriteTodos.tsx
1293
+ var import_antd6 = require("antd");
1294
+ var import_icons5 = require("@ant-design/icons");
1295
+ var import_CollapsePanel2 = __toESM(require("antd/es/collapse/CollapsePanel"));
1296
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1297
+ var { Text: Text5 } = import_antd6.Typography;
1298
+ var WriteTodos = ({
1299
+ data,
1300
+ component_key,
1301
+ eventHandler,
1302
+ interactive = true
1303
+ }) => {
1304
+ const toolCallData = data;
1305
+ const todos = toolCallData?.args?.todos || [];
1306
+ const totalCount = todos.length;
1307
+ const completedCount = todos.filter(
1308
+ (item) => item.status === "completed"
1309
+ ).length;
1310
+ const expandIcon = () => {
1311
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons5.UnorderedListOutlined, {});
1312
+ };
1313
+ const header = /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_antd6.Space, { children: [
1314
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text5, { strong: true, children: "Todos" }),
1315
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Text5, { style: { fontSize: 12 }, type: "secondary", children: [
1316
+ completedCount,
1317
+ "/",
1318
+ totalCount,
1319
+ " Done"
1320
+ ] })
1321
+ ] });
1322
+ if (!toolCallData) {
1323
+ return null;
1324
+ }
1325
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1326
+ import_antd6.Collapse,
1327
+ {
1328
+ size: "small",
1329
+ bordered: false,
1330
+ defaultActiveKey: [],
1331
+ expandIcon,
1332
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1333
+ import_CollapsePanel2.default,
1334
+ {
1335
+ header,
1336
+ style: { minWidth: 400 },
1337
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1338
+ Todo,
1339
+ {
1340
+ data: data.args.todos,
1341
+ component_key,
1342
+ eventHandler,
1343
+ interactive
1344
+ }
1345
+ )
1346
+ },
1347
+ toolCallData.id
1348
+ )
1349
+ }
1350
+ );
1351
+ };
1352
+
1353
+ // src/components/GenUI/FileExplorer.tsx
1354
+ var import_react8 = require("react");
1355
+ var import_antd7 = require("antd");
1356
+ var import_icons7 = require("@ant-design/icons");
1357
+ var import_antd_style4 = require("antd-style");
1358
+
1359
+ // src/components/GenUI/elements/getFileIcon.tsx
1360
+ var import_icons6 = require("@ant-design/icons");
1361
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1362
+ var getFileIcon = (filename) => {
1363
+ const ext = filename?.split(".")?.pop()?.toLowerCase();
1364
+ const iconStyle = { fontSize: 14, marginRight: 4, verticalAlign: "middle" };
1365
+ switch (ext) {
1366
+ case "ts":
1367
+ case "tsx":
1368
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons6.CodeOutlined, { style: { ...iconStyle, color: "#3178c6" } });
1369
+ case "js":
1370
+ case "jsx":
1371
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons6.CodeOutlined, { style: { ...iconStyle, color: "#f7df1e" } });
1372
+ case "html":
1373
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons6.Html5Outlined, { style: { ...iconStyle, color: "#e34c26" } });
1374
+ case "css":
1375
+ case "less":
1376
+ case "scss":
1377
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons6.FileUnknownOutlined, { style: { ...iconStyle, color: "#563d7c" } });
1378
+ case "md":
1379
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons6.FileMarkdownOutlined, { style: { ...iconStyle, color: "#083fa1" } });
1380
+ case "json":
1381
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons6.FileTextOutlined, { style: { ...iconStyle, color: "#fbc02d" } });
1382
+ case "png":
1383
+ case "jpg":
1384
+ case "jpeg":
1385
+ case "gif":
1386
+ case "svg":
1387
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons6.FileImageOutlined, { style: { ...iconStyle, color: "#4caf50" } });
1388
+ default:
1389
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons6.FileOutlined, { style: { ...iconStyle, color: "#9e9e9e" } });
1390
+ }
1391
+ };
1392
+
1393
+ // src/components/GenUI/FileExplorer.tsx
1394
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1395
+ var useStyles = (0, import_antd_style4.createStyles)(({ token, css }) => ({
1396
+ container: css`
1397
+ height: 100%;
1398
+ background: ${token.colorBgContainer};
1399
+ border: 1px solid ${token.colorBorder};
1400
+ border-radius: ${token.borderRadiusLG}px;
1401
+ overflow: hidden;
1402
+ display: flex;
1403
+ flex-direction: column;
1404
+ `,
1405
+ splitter: css`
1406
+ height: 100%;
1407
+ .ant-splitter-bar-dragger {
1408
+ background: transparent !important;
1409
+ &:hover {
1410
+ background: ${token.colorPrimary} !important;
1411
+ }
1412
+ }
1413
+ `,
1414
+ leftPanel: css`
1415
+ height: 100%;
1416
+ overflow: auto;
1417
+ padding: 0;
1418
+ background: ${token.colorBgContainer};
1419
+ border-right: 1px solid ${token.colorBorderSecondary};
1420
+
1421
+ /* Custom scrollbar for tree */
1422
+ &::-webkit-scrollbar {
1423
+ width: 6px;
1424
+ height: 6px;
1425
+ }
1426
+ &::-webkit-scrollbar-thumb {
1427
+ background: ${token.colorBorder};
1428
+ border-radius: 3px;
1429
+ }
1430
+ `,
1431
+ rightPanel: css`
1432
+ height: 100%;
1433
+ overflow: auto;
1434
+ padding: 0;
1435
+ background: ${token.colorBgLayout};
1436
+ position: relative;
1437
+ `,
1438
+ header: css`
1439
+ display: flex;
1440
+ justify-content: flex-end;
1441
+ padding: 8px 16px;
1442
+ background: ${token.colorBgContainer + "30"};
1443
+ backdrop-filter: blur(4px);
1444
+ -webkit-backdrop-filter: blur(4px);
1445
+ gap: 8px;
1446
+ position: sticky;
1447
+ top: 0;
1448
+ z-index: 10;
1449
+ `,
1450
+ contentBody: css`
1451
+ padding: 24px;
1452
+ min-height: 100%;
1453
+
1454
+ pre {
1455
+ margin: 0 !important;
1456
+ border-radius: ${token.borderRadius}px !important;
1457
+ }
1458
+ `,
1459
+ emptyState: css`
1460
+ display: flex;
1461
+ flex-direction: column;
1462
+ align-items: center;
1463
+ justify-content: center;
1464
+ height: 100%;
1465
+ color: ${token.colorTextQuaternary};
1466
+ `,
1467
+ fileTree: css`
1468
+ background: transparent;
1469
+ font-size: 13px;
1470
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
1471
+ "Helvetica Neue", Arial, sans-serif;
1472
+
1473
+ .ant-tree-treenode {
1474
+ padding-bottom: 0 !important;
1475
+ width: 100%;
1476
+ &:hover {
1477
+ background-color: ${token.colorFillQuaternary};
1478
+ }
1479
+ }
1480
+
1481
+ .ant-tree-node-content-wrapper {
1482
+ padding: 0 4px;
1483
+ border-radius: 0;
1484
+ transition: none;
1485
+ line-height: 24px;
1486
+ min-height: 24px;
1487
+
1488
+ &:hover {
1489
+ background-color: transparent;
1490
+ }
1491
+
1492
+ &.ant-tree-node-selected {
1493
+ background-color: ${token.controlItemBgActive} !important;
1494
+ color: ${token.colorText};
1495
+ font-weight: 500;
1496
+ }
1497
+ }
1498
+
1499
+ .ant-tree-indent-unit {
1500
+ width: 16px;
1501
+ }
1502
+
1503
+ .ant-tree-switcher {
1504
+ width: 20px;
1505
+ line-height: 24px;
1506
+
1507
+ .anticon {
1508
+ font-size: 10px;
1509
+ color: ${token.colorTextSecondary};
1510
+ }
1511
+ }
1512
+
1513
+ .ant-tree-title {
1514
+ display: inline-block;
1515
+ margin-left: 4px;
1516
+ }
1517
+ `
1518
+ }));
1519
+ var getFolderIcon = (expanded) => {
1520
+ const iconStyle = {
1521
+ fontSize: 14,
1522
+ marginRight: 4,
1523
+ color: "#dcb67a",
1524
+ verticalAlign: "middle"
1525
+ };
1526
+ return expanded ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons7.FolderOpenOutlined, { style: iconStyle }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons7.FolderOutlined, { style: iconStyle });
1527
+ };
1528
+ var sortTreeNodes = (nodes) => {
1529
+ return nodes.sort((a, b) => {
1530
+ if (!!a.isLeaf === !!b.isLeaf) {
1531
+ return a.title.localeCompare(b.title);
1532
+ }
1533
+ return a.isLeaf ? 1 : -1;
1534
+ }).map((node) => {
1535
+ if (node.children) {
1536
+ return { ...node, children: sortTreeNodes(node.children) };
1537
+ }
1538
+ return node;
1539
+ });
1540
+ };
1541
+ var buildTreeData = (files, expandedKeys) => {
1542
+ const root = [];
1543
+ files.forEach((file) => {
1544
+ const parts = file.name.split("/");
1545
+ let currentLevel = root;
1546
+ parts.forEach((part, index) => {
1547
+ const isFile = index === parts.length - 1;
1548
+ const key = parts.slice(0, index + 1).join("/");
1549
+ let existingNode = currentLevel.find((node) => node.key === key);
1550
+ if (!existingNode) {
1551
+ const title = part === "" && index === 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1552
+ "span",
1553
+ {
1554
+ style: {
1555
+ color: "rgba(0, 0, 0, 0.45)",
1556
+ fontStyle: "italic",
1557
+ fontSize: 12
1558
+ },
1559
+ children: "<root>"
1560
+ }
1561
+ ) : part;
1562
+ const newNode = {
1563
+ title,
1564
+ key,
1565
+ isLeaf: isFile,
1566
+ icon: isFile ? getFileIcon(part) : getFolderIcon(expandedKeys.includes(key)),
1567
+ children: isFile ? void 0 : []
1568
+ };
1569
+ currentLevel.push(newNode);
1570
+ existingNode = newNode;
1571
+ }
1572
+ if (!isFile && existingNode.children) {
1573
+ currentLevel = existingNode.children;
1574
+ }
1575
+ });
1576
+ });
1577
+ return sortTreeNodes(root);
1578
+ };
1579
+ var FileExplorer = ({
1580
+ data,
1581
+ eventHandler,
1582
+ interactive = true,
1583
+ default_open_in_side_app = true
1584
+ }) => {
1585
+ const { files } = data ?? {};
1586
+ const { styles, cx } = useStyles();
1587
+ const [fileList, setFileList] = (0, import_react8.useState)([]);
1588
+ const [selectedKey, setSelectedKey] = (0, import_react8.useState)("");
1589
+ const [expandedKeys, setExpandedKeys] = (0, import_react8.useState)([]);
1590
+ const [copied, setCopied] = (0, import_react8.useState)(false);
1591
+ (0, import_react8.useEffect)(() => {
1592
+ if (copied) {
1593
+ const timer = setTimeout(() => setCopied(false), 2e3);
1594
+ return () => clearTimeout(timer);
1595
+ }
1596
+ }, [copied]);
1597
+ (0, import_react8.useEffect)(() => {
1598
+ let list = [];
1599
+ if (Array.isArray(files)) {
1600
+ list = files;
1601
+ } else {
1602
+ list = Object.keys(files).map((key) => ({
1603
+ ...files[key],
1604
+ name: key
1605
+ }));
1606
+ }
1607
+ setFileList(list);
1608
+ if (list.length > 0 && !selectedKey) {
1609
+ const firstFile = list[0];
1610
+ setSelectedKey(list[0].name);
1611
+ }
1612
+ }, [files]);
1613
+ const treeData = (0, import_react8.useMemo)(
1614
+ () => buildTreeData(fileList, expandedKeys),
1615
+ [fileList, expandedKeys]
1616
+ );
1617
+ (0, import_react8.useEffect)(() => {
1618
+ if (treeData.length > 0 && expandedKeys.length === 0) {
1619
+ const getAllKeys = (nodes) => {
1620
+ let keys = [];
1621
+ nodes.forEach((node) => {
1622
+ if (!node.isLeaf) {
1623
+ keys.push(node.key);
1624
+ if (node.children) {
1625
+ keys = keys.concat(getAllKeys(node.children));
1626
+ }
1627
+ }
1628
+ });
1629
+ return keys;
1630
+ };
1631
+ setExpandedKeys(getAllKeys(treeData));
1632
+ }
1633
+ }, [treeData.length]);
1634
+ const selectedFile = (0, import_react8.useMemo)(() => {
1635
+ return fileList.find((f) => f.name === selectedKey);
1636
+ }, [fileList, selectedKey]);
1637
+ const handleCopy = () => {
1638
+ if (!selectedFile) return;
1639
+ const content = Array.isArray(selectedFile.content) ? selectedFile.content.join("\n") : selectedFile.content;
1640
+ navigator.clipboard.writeText(content).then(() => {
1641
+ setCopied(true);
1642
+ import_antd7.message.success("Copied to clipboard");
1643
+ });
1644
+ };
1645
+ const handleDownload = () => {
1646
+ if (!selectedFile) return;
1647
+ const content = Array.isArray(selectedFile.content) ? selectedFile.content.join("\n") : selectedFile.content;
1648
+ const blob = new Blob([content], { type: "text/plain" });
1649
+ const url = URL.createObjectURL(blob);
1650
+ const a = document.createElement("a");
1651
+ a.href = url;
1652
+ const fileName = selectedFile.name.split("/").pop() || selectedFile.name;
1653
+ a.download = fileName;
1654
+ document.body.appendChild(a);
1655
+ a.click();
1656
+ document.body.removeChild(a);
1657
+ URL.revokeObjectURL(url);
1658
+ };
1659
+ const renderContent = () => {
1660
+ if (!selectedFile) {
1661
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: styles.emptyState, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1662
+ import_antd7.Empty,
1663
+ {
1664
+ description: "Select a file to preview",
1665
+ image: import_antd7.Empty.PRESENTED_IMAGE_SIMPLE
1666
+ }
1667
+ ) });
1668
+ }
1669
+ const content = Array.isArray(selectedFile.content) ? selectedFile.content.join("\n") : selectedFile.content;
1670
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1671
+ "div",
1672
+ {
1673
+ style: { minHeight: "100%", display: "flex", flexDirection: "column" },
1674
+ children: [
1675
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: styles.header, children: [
1676
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_antd7.Tooltip, { title: "Copy Content", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1677
+ import_antd7.Button,
1678
+ {
1679
+ type: "text",
1680
+ icon: copied ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons7.CheckOutlined, {}) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons7.CopyOutlined, {}),
1681
+ onClick: handleCopy,
1682
+ size: "small"
1683
+ }
1684
+ ) }),
1685
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_antd7.Tooltip, { title: "Download File", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1686
+ import_antd7.Button,
1687
+ {
1688
+ type: "text",
1689
+ icon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons7.DownloadOutlined, {}),
1690
+ onClick: handleDownload,
1691
+ size: "small"
1692
+ }
1693
+ ) })
1694
+ ] }),
1695
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: styles.contentBody, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(MDResponse, { content }) })
1696
+ ]
1697
+ }
1698
+ );
1699
+ };
1700
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: styles.container, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_antd7.Splitter, { className: styles.splitter, children: [
1701
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_antd7.Splitter.Panel, { defaultSize: "25%", min: "15%", max: "40%", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: styles.leftPanel, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1702
+ import_antd7.Tree,
1703
+ {
1704
+ showIcon: true,
1705
+ blockNode: true,
1706
+ showLine: true,
1707
+ className: styles.fileTree,
1708
+ treeData,
1709
+ selectedKeys: selectedKey ? [selectedKey] : [],
1710
+ expandedKeys,
1711
+ onExpand: setExpandedKeys,
1712
+ onSelect: (keys, info) => {
1713
+ if (keys.length > 0) {
1714
+ const key = keys[0];
1715
+ const file = fileList.find((f) => f.name === key);
1716
+ if (file) {
1717
+ setSelectedKey(key);
1718
+ } else {
1719
+ if (expandedKeys.includes(key)) {
1720
+ setExpandedKeys(expandedKeys.filter((k) => k !== key));
1721
+ } else {
1722
+ setExpandedKeys([...expandedKeys, key]);
1723
+ }
1724
+ }
1725
+ } else if (info.node.key) {
1726
+ const key = info.node.key;
1727
+ const file = fileList.find((f) => f.name === key);
1728
+ if (!file) {
1729
+ if (expandedKeys.includes(key)) {
1730
+ setExpandedKeys(expandedKeys.filter((k) => k !== key));
1731
+ } else {
1732
+ setExpandedKeys([...expandedKeys, key]);
1733
+ }
1734
+ }
1735
+ }
1736
+ }
1737
+ }
1738
+ ) }) }),
1739
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_antd7.Splitter.Panel, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: styles.rightPanel, children: renderContent() }) })
1740
+ ] }) });
1741
+ };
1742
+
1743
+ // src/components/GenUI/elements/attachments_card.tsx
1744
+ var import_x = require("@ant-design/x");
1745
+ var import_antd8 = require("antd");
1746
+ var import_dayjs = __toESM(require("dayjs"));
1747
+ var import_react9 = require("react");
1748
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1749
+ var AttachmentsCard = ({
1750
+ data,
1751
+ eventHandler,
1752
+ component_key,
1753
+ size = "medium",
1754
+ columns = 1,
1755
+ showDownloadButton = false
1756
+ }) => {
1757
+ const { Text: Text8 } = import_antd8.Typography;
1758
+ const [showAll, setShowAll] = (0, import_react9.useState)(false);
1759
+ const getStyles = () => {
1760
+ switch (size) {
1761
+ case "small":
1762
+ return {
1763
+ padding: "0px",
1764
+ fontSize: "10px",
1765
+ cardSize: "small"
1766
+ };
1767
+ case "large":
1768
+ return {
1769
+ padding: "16px",
1770
+ fontSize: "16px",
1771
+ cardSize: "default"
1772
+ };
1773
+ default:
1774
+ return {
1775
+ padding: "8px",
1776
+ fontSize: "14px",
1777
+ cardSize: "small"
1778
+ };
1779
+ }
1780
+ };
1781
+ const styles = getStyles();
1782
+ const handleItemClick = (item) => {
1783
+ eventHandler?.(
1784
+ "__open_side_app",
1785
+ {
1786
+ component_key: "attachments",
1787
+ data: { file_id: item.id, message: "\u9884\u89C8\uFF1A" + item.name }
1788
+ },
1789
+ ""
1790
+ );
1791
+ };
1792
+ const getCardStyle = (item) => {
1793
+ if (item.is_failure && columns > 1) {
1794
+ return {
1795
+ padding: 0
1796
+ };
1797
+ }
1798
+ return { padding: 0, cursor: "pointer" };
1799
+ };
1800
+ const getFileCardStyle = (item) => {
1801
+ const baseStyle = {
1802
+ width: "100%",
1803
+ backgroundColor: "transparent",
1804
+ fontSize: styles.fontSize,
1805
+ padding: styles.padding,
1806
+ position: "relative"
1807
+ // 添加相对定位,用于绝对定位下载按钮
1808
+ };
1809
+ if (item.is_failure && columns > 1) {
1810
+ return {
1811
+ ...baseStyle,
1812
+ color: "gray"
1813
+ };
1814
+ }
1815
+ return baseStyle;
1816
+ };
1817
+ const DownloadButton = ({ item }) => {
1818
+ if (!showDownloadButton) return null;
1819
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1820
+ "div",
1821
+ {
1822
+ style: {
1823
+ position: "absolute",
1824
+ top: "50%",
1825
+ right: 8,
1826
+ transform: "translateY(-50%)",
1827
+ zIndex: 10
1828
+ },
1829
+ onClick: (e) => e.stopPropagation()
1830
+ }
1831
+ );
1832
+ };
1833
+ const renderFileDescription = (item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd8.Space, { direction: "vertical", size: size === "small" ? 2 : 4, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd8.Space, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1834
+ Text8,
1835
+ {
1836
+ type: "secondary",
1837
+ style: {
1838
+ fontSize: size === "small" ? "10px" : void 0
1839
+ },
1840
+ children: item.created_at && (0, import_dayjs.default)(item.created_at).format("YYYY-MM-DD HH:mm:ss")
1841
+ }
1842
+ ) }) });
1843
+ if (columns > 1) {
1844
+ const displayData2 = data || [];
1845
+ const shouldShowViewMore2 = displayData2.length > 4;
1846
+ const visibleData2 = showAll ? displayData2 : displayData2.slice(0, 4);
1847
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_antd8.Flex, { vertical: true, gap: "small", children: [
1848
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd8.Row, { gutter: [8, 8], children: visibleData2.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd8.Col, { span: 24 / columns, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1849
+ "div",
1850
+ {
1851
+ onClick: (evt) => {
1852
+ evt.stopPropagation();
1853
+ handleItemClick(item);
1854
+ },
1855
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_antd8.Card, { size: styles.cardSize, style: getCardStyle(item), children: [
1856
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DownloadButton, { item }),
1857
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1858
+ import_x.Attachments.FileCard,
1859
+ {
1860
+ style: getFileCardStyle(item),
1861
+ item: {
1862
+ name: item.name,
1863
+ size: item.size,
1864
+ uid: item.id,
1865
+ description: renderFileDescription(item)
1866
+ }
1867
+ }
1868
+ ),
1869
+ item.files && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1870
+ AttachmentsCard,
1871
+ {
1872
+ data: item.files,
1873
+ component_key: `${component_key}_${item.id}`,
1874
+ eventHandler,
1875
+ size: "small",
1876
+ columns: 2,
1877
+ showDownloadButton
1878
+ }
1879
+ )
1880
+ ] })
1881
+ }
1882
+ ) }, item.id)) }),
1883
+ shouldShowViewMore2 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1884
+ import_antd8.Button,
1885
+ {
1886
+ type: "link",
1887
+ onClick: () => setShowAll(!showAll),
1888
+ style: { alignSelf: "center" },
1889
+ children: showAll ? "\u663E\u793A\u66F4\u5C11" : `\u663E\u793A\u66F4\u591A (${displayData2.length - 4})`
1890
+ }
1891
+ )
1892
+ ] });
1893
+ }
1894
+ const displayData = data || [];
1895
+ const shouldShowViewMore = displayData.length > 4;
1896
+ const visibleData = showAll ? displayData : displayData.slice(0, 4);
1897
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_antd8.Flex, { vertical: true, gap: size === "small" ? "small" : "middle", children: [
1898
+ visibleData.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { onClick: () => handleItemClick(item), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_antd8.Card, { size: styles.cardSize, style: getCardStyle(item), children: [
1899
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DownloadButton, { item }),
1900
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1901
+ import_x.Attachments.FileCard,
1902
+ {
1903
+ style: getFileCardStyle(item),
1904
+ item: {
1905
+ name: item.name,
1906
+ size: item.size,
1907
+ uid: item.id,
1908
+ description: renderFileDescription(item)
1909
+ }
1910
+ }
1911
+ ),
1912
+ item.files && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { style: { paddingLeft: "12px" }, children: [
1913
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Text8, { type: "secondary", style: { fontSize: "12px" }, children: [
1914
+ "\u5305\u542B\u6587\u4EF6(",
1915
+ item.files.length,
1916
+ ")"
1917
+ ] }),
1918
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1919
+ AttachmentsCard,
1920
+ {
1921
+ data: item.files,
1922
+ component_key: `${component_key}_${item.id}`,
1923
+ eventHandler,
1924
+ size: "small",
1925
+ columns: 2,
1926
+ showDownloadButton
1927
+ }
1928
+ )
1929
+ ] })
1930
+ ] }) }, item.id)),
1931
+ shouldShowViewMore && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1932
+ import_antd8.Button,
1933
+ {
1934
+ type: "link",
1935
+ size: "small",
1936
+ onClick: (evt) => {
1937
+ evt.stopPropagation();
1938
+ setShowAll(!showAll);
1939
+ },
1940
+ style: { alignSelf: "center" },
1941
+ children: showAll ? "\u663E\u793A\u66F4\u5C11" : `\u663E\u793A\u66F4\u591A (${displayData.length - 4})`
1942
+ }
1943
+ )
1944
+ ] });
1945
+ };
1946
+
1947
+ // src/components/GenUI/elements/attachments_viewer_side_app.tsx
1948
+ var import_antd9 = require("antd");
1949
+ var import_react10 = require("react");
1950
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1951
+ function AttachmentsViewerSideApp({
1952
+ data,
1953
+ eventHandler,
1954
+ component_key
1955
+ }) {
1956
+ const [fileUri, setFileUri] = (0, import_react10.useState)();
1957
+ const [loading, setLoading] = (0, import_react10.useState)(true);
1958
+ const { file_id } = data ?? {};
1959
+ if (loading) {
1960
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_antd9.Skeleton, { active: true });
1961
+ }
1962
+ const canPreviewInIframe = (fileName) => {
1963
+ if (!fileName) return false;
1964
+ const extension = fileName?.split(".").pop()?.toLowerCase() || "";
1965
+ const previewableExtensions = [
1966
+ // PDF文档
1967
+ "pdf",
1968
+ // 图片类型
1969
+ "jpg",
1970
+ "jpeg",
1971
+ "png",
1972
+ "gif",
1973
+ "svg",
1974
+ "bmp",
1975
+ "webp",
1976
+ // 文本类型
1977
+ "txt",
1978
+ "csv",
1979
+ "json",
1980
+ "xml",
1981
+ // 网页类型
1982
+ "html",
1983
+ "htm",
1984
+ // 音频类型
1985
+ "mp3",
1986
+ "wav",
1987
+ "ogg",
1988
+ // 视频类型
1989
+ "mp4",
1990
+ "webm"
1991
+ ];
1992
+ return previewableExtensions.includes(extension);
1993
+ };
1994
+ const isPreviewable = fileUri?.fileName ? canPreviewInIframe(fileUri.fileName) : false;
1995
+ return isPreviewable ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1996
+ "iframe",
1997
+ {
1998
+ style: { width: "100%", height: "100%", border: 0 },
1999
+ src: fileUri?.url
2000
+ }
2001
+ ) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2002
+ import_antd9.Empty,
2003
+ {
2004
+ description: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
2005
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { children: "\u6682\u65F6\u4E0D\u652F\u6301\u9884\u89C8\uFF0C\u8BF7\u4E0B\u8F7D\u540E\u67E5\u770B\u3002" }),
2006
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_antd9.Button, { type: "link", href: fileUri?.url, download: fileUri?.fileName, children: [
2007
+ "\u4E0B\u8F7D",
2008
+ fileUri?.fileName
2009
+ ] })
2010
+ ] }),
2011
+ image: import_antd9.Empty.PRESENTED_IMAGE_DEFAULT
2012
+ }
2013
+ );
2014
+ }
2015
+
2016
+ // src/components/GenUI/elements/WriteFile.tsx
2017
+ var import_antd11 = require("antd");
2018
+
2019
+ // src/components/GenUI/elements/ContentPreviewCollapse.tsx
2020
+ var import_react11 = require("react");
2021
+ var import_antd10 = require("antd");
2022
+ var import_antd_style5 = require("antd-style");
2023
+ var import_icons8 = require("@ant-design/icons");
2024
+ var import_CollapsePanel3 = __toESM(require("antd/es/collapse/CollapsePanel"));
2025
+ var import_jsx_runtime13 = require("react/jsx-runtime");
2026
+ var DEFAULT_COLLAPSED_MAX_HEIGHT = 180;
2027
+ var DEFAULT_EXPANDED_MAX_HEIGHT = 500;
2028
+ var useStyle4 = (0, import_antd_style5.createStyles)(
2029
+ ({ css }, { showShadow }) => ({
2030
+ collapse: css`
2031
+ .ant-collapse-header {
2032
+ position: relative;
2033
+ z-index: 1;
2034
+ transition: box-shadow 0.2s ease;
2035
+ box-shadow: ${showShadow ? "0 4px 8px -2px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)" : "none"};
2036
+ }
2037
+
2038
+ .ant-collapse-content-box {
2039
+ padding-top: 0 !important;
2040
+ }
2041
+ `,
2042
+ contentContainer: css`
2043
+ position: relative;
2044
+ overflow: hidden;
2045
+ display: flex;
2046
+ flex-direction: column;
2047
+ justify-content: flex-end;
2048
+
2049
+ &.expanded {
2050
+ overflow: auto;
2051
+ display: block;
2052
+ }
2053
+ `,
2054
+ content: css`
2055
+ flex-shrink: 0;
2056
+ `,
2057
+ toggleButton: css`
2058
+ display: flex;
2059
+ align-items: center;
2060
+ justify-content: center;
2061
+ gap: 4px;
2062
+ padding: 8px 0;
2063
+ margin-top: 8px;
2064
+ border-top: 1px solid rgba(0, 0, 0, 0.06);
2065
+ cursor: pointer;
2066
+ color: #1890ff;
2067
+ font-size: 12px;
2068
+ user-select: none;
2069
+ transition: color 0.2s;
2070
+
2071
+ &:hover {
2072
+ color: #40a9ff;
2073
+ }
2074
+ `
2075
+ })
2076
+ );
2077
+ var ContentPreviewCollapse = ({
2078
+ panelKey,
2079
+ header,
2080
+ extra,
2081
+ expandIcon,
2082
+ children,
2083
+ collapsedMaxHeight = DEFAULT_COLLAPSED_MAX_HEIGHT,
2084
+ expandedMaxHeight = DEFAULT_EXPANDED_MAX_HEIGHT,
2085
+ defaultExpanded = true,
2086
+ minWidth = 400,
2087
+ showAllText = "Show all content",
2088
+ showLessText = "Show less"
2089
+ }) => {
2090
+ const [showFullContent, setShowFullContent] = (0, import_react11.useState)(false);
2091
+ const [isOverflowing, setIsOverflowing] = (0, import_react11.useState)(false);
2092
+ const contentRef = (0, import_react11.useRef)(null);
2093
+ const showShadow = isOverflowing && !showFullContent;
2094
+ const { styles, cx } = useStyle4({ showShadow });
2095
+ const checkOverflow = (0, import_react11.useCallback)(() => {
2096
+ if (contentRef.current) {
2097
+ const scrollHeight = contentRef.current.scrollHeight;
2098
+ setIsOverflowing(scrollHeight > collapsedMaxHeight);
2099
+ }
2100
+ }, [collapsedMaxHeight]);
2101
+ (0, import_react11.useEffect)(() => {
2102
+ const element = contentRef.current;
2103
+ if (!element) return;
2104
+ checkOverflow();
2105
+ const resizeObserver = new ResizeObserver(() => {
2106
+ checkOverflow();
2107
+ });
2108
+ resizeObserver.observe(element);
2109
+ return () => {
2110
+ resizeObserver.disconnect();
2111
+ };
2112
+ }, [children, checkOverflow]);
2113
+ const handleToggleContent = (e) => {
2114
+ e.stopPropagation();
2115
+ setShowFullContent(!showFullContent);
2116
+ };
2117
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2118
+ import_antd10.Collapse,
2119
+ {
2120
+ className: styles.collapse,
2121
+ size: "small",
2122
+ bordered: false,
2123
+ defaultActiveKey: defaultExpanded ? [panelKey] : [],
2124
+ expandIcon,
2125
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2126
+ import_CollapsePanel3.default,
2127
+ {
2128
+ header,
2129
+ extra,
2130
+ style: { minWidth },
2131
+ children: [
2132
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2133
+ "div",
2134
+ {
2135
+ className: cx(styles.contentContainer, showFullContent && "expanded"),
2136
+ style: {
2137
+ maxHeight: showFullContent ? expandedMaxHeight : collapsedMaxHeight
2138
+ },
2139
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { ref: contentRef, className: styles.content, children })
2140
+ }
2141
+ ),
2142
+ isOverflowing && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: styles.toggleButton, onClick: handleToggleContent, children: showFullContent ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
2143
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons8.UpOutlined, { style: { fontSize: 10 } }),
2144
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: showLessText })
2145
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
2146
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons8.DownOutlined, { style: { fontSize: 10 } }),
2147
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: showAllText })
2148
+ ] }) })
2149
+ ]
2150
+ },
2151
+ panelKey
2152
+ )
2153
+ }
2154
+ );
2155
+ };
2156
+
2157
+ // src/components/GenUI/elements/WriteFile.tsx
2158
+ var import_jsx_runtime14 = require("react/jsx-runtime");
2159
+ var { Text: Text6 } = import_antd11.Typography;
2160
+ var WriteFile = ({
2161
+ data,
2162
+ component_key,
2163
+ eventHandler,
2164
+ interactive = true
2165
+ }) => {
2166
+ const toolCallData = data;
2167
+ const { file_path, content } = toolCallData?.args || {};
2168
+ if (!toolCallData) {
2169
+ return null;
2170
+ }
2171
+ const expandIcon = () => getFileIcon(file_path);
2172
+ const header = /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_antd11.Space, { children: [
2173
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text6, { strong: true, children: "New" }),
2174
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text6, { title: file_path, children: file_path?.split("/")?.pop() || "" })
2175
+ ] });
2176
+ const handleItemClick = (toolCallData2) => {
2177
+ eventHandler?.(
2178
+ "__open_side_app",
2179
+ {
2180
+ component_key: "file_content_diff_view",
2181
+ message: file_path,
2182
+ data: {
2183
+ old_code: "",
2184
+ new_code: content
2185
+ }
2186
+ },
2187
+ ""
2188
+ );
2189
+ };
2190
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2191
+ ContentPreviewCollapse,
2192
+ {
2193
+ panelKey: toolCallData.id,
2194
+ header,
2195
+ expandIcon,
2196
+ extra: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2197
+ import_antd11.Button,
2198
+ {
2199
+ type: "link",
2200
+ size: "small",
2201
+ onClick: (evt) => {
2202
+ evt.stopPropagation();
2203
+ handleItemClick(toolCallData);
2204
+ },
2205
+ children: "Diff View"
2206
+ }
2207
+ ),
2208
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MDResponse, { content })
2209
+ }
2210
+ );
2211
+ };
2212
+
2213
+ // src/components/GenUI/elements/file_content_diff_view.tsx
2214
+ var import_react_diff_viewer = __toESM(require("@alexbruf/react-diff-viewer"));
2215
+ var import_react_diff_viewer2 = require("@alexbruf/react-diff-viewer/index.css");
2216
+ var import_jsx_runtime15 = require("react/jsx-runtime");
2217
+ var FileContentDiffView = ({
2218
+ data,
2219
+ eventHandler,
2220
+ interactive = true,
2221
+ default_open_in_side_app = true
2222
+ }) => {
2223
+ const { old_code, new_code } = data;
2224
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2225
+ import_react_diff_viewer.default,
2226
+ {
2227
+ oldValue: old_code,
2228
+ newValue: new_code,
2229
+ splitView: false
2230
+ }
2231
+ );
2232
+ };
2233
+
2234
+ // src/components/GenUI/elements/EditFile.tsx
2235
+ var import_antd12 = require("antd");
2236
+ var import_jsx_runtime16 = require("react/jsx-runtime");
2237
+ var { Text: Text7 } = import_antd12.Typography;
2238
+ var EditFile = ({
2239
+ data,
2240
+ component_key,
2241
+ eventHandler,
2242
+ interactive = true
2243
+ }) => {
2244
+ const toolCallData = data;
2245
+ const { file_path, new_string, old_string } = toolCallData?.args || {};
2246
+ if (!toolCallData) {
2247
+ return null;
1248
2248
  }
1249
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_antd5.Card, { size: "small", className: `shadow-sm ${styles.card}`, bordered: false, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_antd5.Space, { direction: "vertical", style: { width: "100%" }, children: [
1250
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1251
- import_antd5.List,
2249
+ const expandIcon = () => getFileIcon(file_path);
2250
+ const header = /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_antd12.Space, { children: [
2251
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Text7, { strong: true, children: "Edit" }),
2252
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Text7, { title: file_path, children: file_path?.split("/")?.pop() || "" })
2253
+ ] });
2254
+ const handleItemClick = (toolCallData2) => {
2255
+ eventHandler?.(
2256
+ "__open_side_app",
1252
2257
  {
1253
- size: "small",
1254
- dataSource: data,
1255
- renderItem: (item, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1256
- import_antd5.List.Item,
1257
- {
1258
- className: `${styles.todoItem} ${getItemClassName(item.status)}`,
1259
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_antd5.Space, { align: "center", style: { width: "100%" }, children: [
1260
- getStatusIcon3(item.status),
1261
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text4, { style: { flex: 1 }, children: item.content })
1262
- ] })
1263
- }
1264
- )
1265
- }
1266
- ),
1267
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text4, { type: "secondary", style: { fontSize: 12 }, children: [
1268
- "Total items: ",
1269
- data.length,
1270
- " | Completed:",
1271
- " ",
1272
- data.filter((item) => item.status === "completed").length,
1273
- " | In Progress:",
1274
- " ",
1275
- data.filter((item) => item.status === "in_progress").length,
1276
- " | Pending: ",
1277
- data.filter((item) => item.status === "pending").length
1278
- ] })
1279
- ] }) });
2258
+ component_key: "file_content_diff_view",
2259
+ message: file_path,
2260
+ data: {
2261
+ old_code: old_string,
2262
+ new_code: new_string
2263
+ }
2264
+ },
2265
+ ""
2266
+ );
2267
+ };
2268
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2269
+ ContentPreviewCollapse,
2270
+ {
2271
+ panelKey: toolCallData.id,
2272
+ header,
2273
+ expandIcon,
2274
+ extra: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2275
+ import_antd12.Button,
2276
+ {
2277
+ type: "link",
2278
+ size: "small",
2279
+ onClick: (evt) => {
2280
+ evt.stopPropagation();
2281
+ handleItemClick(toolCallData);
2282
+ },
2283
+ children: "Diff View"
2284
+ }
2285
+ ),
2286
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(MDResponse, { content: new_string })
2287
+ }
2288
+ );
1280
2289
  };
1281
2290
 
1282
- // src/components/GenUI/elements/index.tsx
2291
+ // src/components/GenUI/elements/builtIns.tsx
1283
2292
  var elements = {
1284
2293
  action_show_attachments_uploader: {
1285
2294
  card_view: () => null,
@@ -1302,8 +2311,31 @@ var elements = {
1302
2311
  },
1303
2312
  todo_list: {
1304
2313
  card_view: Todo
2314
+ },
2315
+ write_todos: {
2316
+ card_view: WriteTodos
2317
+ },
2318
+ write_file: {
2319
+ card_view: WriteFile
2320
+ },
2321
+ edit_file: {
2322
+ card_view: EditFile
2323
+ },
2324
+ file_explorer: {
2325
+ card_view: () => null,
2326
+ side_app_view: FileExplorer
2327
+ },
2328
+ attachments: {
2329
+ card_view: AttachmentsCard,
2330
+ side_app_view: AttachmentsViewerSideApp
2331
+ },
2332
+ file_content_diff_view: {
2333
+ card_view: FileContentDiffView,
2334
+ side_app_view: FileContentDiffView
1305
2335
  }
1306
2336
  };
2337
+
2338
+ // src/components/GenUI/elements/index.tsx
1307
2339
  var getElement = (language) => {
1308
2340
  if (language && elements[language]) {
1309
2341
  return elements[language];
@@ -1318,15 +2350,15 @@ var regsiterElement = (language, ElementMeta) => {
1318
2350
 
1319
2351
  // src/components/GenUI/MDMermaid.tsx
1320
2352
  var import_mermaid = __toESM(require("mermaid"));
1321
- var import_react8 = require("react");
2353
+ var import_react12 = require("react");
1322
2354
  var import_uuid = require("uuid");
1323
- var import_jsx_runtime8 = require("react/jsx-runtime");
2355
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1324
2356
  var MDMermaid = ({ children = [] }) => {
1325
- const domId = (0, import_react8.useRef)(`dom${(0, import_uuid.v4)()}`);
2357
+ const domId = (0, import_react12.useRef)(`dom${(0, import_uuid.v4)()}`);
1326
2358
  const code = String(children);
1327
- const target = (0, import_react8.useRef)(null);
1328
- const targetInternal = (0, import_react8.useRef)(null);
1329
- (0, import_react8.useEffect)(() => {
2359
+ const target = (0, import_react12.useRef)(null);
2360
+ const targetInternal = (0, import_react12.useRef)(null);
2361
+ (0, import_react12.useEffect)(() => {
1330
2362
  if (target.current && code) {
1331
2363
  import_mermaid.default.initialize({
1332
2364
  startOnLoad: true,
@@ -1388,13 +2420,13 @@ var MDMermaid = ({ children = [] }) => {
1388
2420
  });
1389
2421
  }
1390
2422
  }, [code]);
1391
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { minWidth: 750 }, ref: target, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("code", { id: domId.current, style: { display: "none" } }) });
2423
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: { minWidth: 750 }, ref: target, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("code", { id: domId.current, style: { display: "none" } }) });
1392
2424
  };
1393
2425
 
1394
2426
  // src/components/GenUI/MDResponse.tsx
1395
- var import_jsx_runtime9 = require("react/jsx-runtime");
2427
+ var import_jsx_runtime18 = require("react/jsx-runtime");
1396
2428
  var SyntaxHighlighter = import_react_syntax_highlighter.Prism;
1397
- var useStyles = (0, import_antd_style4.createStyles)(({ token, css }) => ({
2429
+ var useStyles2 = (0, import_antd_style6.createStyles)(({ token, css }) => ({
1398
2430
  markdownTableContainer: css`
1399
2431
  overflow-x: auto;
1400
2432
  width: 100%;
@@ -1483,26 +2515,26 @@ var MDResponse = ({
1483
2515
  noGenUI,
1484
2516
  eventHandler
1485
2517
  }) => {
1486
- const { styles } = useStyles();
1487
- const config = (0, import_react9.useMemo)(
2518
+ const { styles } = useStyles2();
2519
+ const config = (0, import_react13.useMemo)(
1488
2520
  () => ({
1489
2521
  components: {
1490
2522
  a({ node, ...props }) {
1491
2523
  if (embeddedLink) {
1492
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(IFrameCard, { src: props.href });
1493
- } else return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("a", { ...props });
2524
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(IFrameCard, { src: props.href });
2525
+ } else return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("a", { ...props });
1494
2526
  },
1495
2527
  table({ node, ...props }) {
1496
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: styles.markdownTableContainer, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("table", { className: styles.markdownTable, ...props }) });
2528
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: styles.markdownTableContainer, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("table", { className: styles.markdownTable, ...props }) });
1497
2529
  },
1498
2530
  th({ node, ...props }) {
1499
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("th", { className: styles.markdownTh, ...props });
2531
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("th", { className: styles.markdownTh, ...props });
1500
2532
  },
1501
2533
  td({ node, ...props }) {
1502
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("td", { className: styles.markdownTd, ...props });
2534
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("td", { className: styles.markdownTd, ...props });
1503
2535
  },
1504
2536
  tr({ node, ...props }) {
1505
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("tr", { className: styles.markdownTr, ...props });
2537
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("tr", { className: styles.markdownTr, ...props });
1506
2538
  },
1507
2539
  code({ children, className, node, ...rest }) {
1508
2540
  const match = /language-(\w+)/.exec(className || "");
@@ -1515,23 +2547,23 @@ var MDResponse = ({
1515
2547
  childrenData = JSON.parse(children);
1516
2548
  } catch (error) {
1517
2549
  }
1518
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2550
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1519
2551
  Element,
1520
2552
  {
1521
2553
  interactive,
1522
2554
  component_key: language,
1523
2555
  data: childrenData,
1524
- eventHandler: (e, data, message2, agent) => {
1525
- eventHandler?.(e, data, message2, agent);
2556
+ eventHandler: (e, data, message3, agent) => {
2557
+ eventHandler?.(e, data, message3, agent);
1526
2558
  }
1527
2559
  }
1528
2560
  );
1529
2561
  }
1530
2562
  switch (language) {
1531
2563
  case "mermaid":
1532
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MDMermaid, { children });
2564
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(MDMermaid, { children });
1533
2565
  default:
1534
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2566
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1535
2567
  SyntaxHighlighter,
1536
2568
  {
1537
2569
  ...rest,
@@ -1543,7 +2575,7 @@ var MDResponse = ({
1543
2575
  );
1544
2576
  }
1545
2577
  } else {
1546
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("code", { ...rest, className, children });
2578
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("code", { ...rest, className, children });
1547
2579
  }
1548
2580
  }
1549
2581
  },
@@ -1552,15 +2584,15 @@ var MDResponse = ({
1552
2584
  }),
1553
2585
  [userData, interactive, embeddedLink, styles]
1554
2586
  );
1555
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: styles.markdownContainer, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_markdown.default, { ...config, children: content }) });
2587
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: styles.markdownContainer, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_markdown.default, { ...config, children: content }) });
1556
2588
  };
1557
2589
  var MDViewFormItem = ({ value }) => {
1558
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MDResponse, { content: value || "" });
2590
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(MDResponse, { content: value || "" });
1559
2591
  };
1560
2592
  var IFrameCard = ({ src }) => {
1561
- const containerRef = (0, import_react9.useRef)(null);
1562
- const [width, setWidth] = (0, import_react9.useState)("640px");
1563
- const [height, setHeight] = (0, import_react9.useState)("320px");
2593
+ const containerRef = (0, import_react13.useRef)(null);
2594
+ const [width, setWidth] = (0, import_react13.useState)("640px");
2595
+ const [height, setHeight] = (0, import_react13.useState)("320px");
1564
2596
  const valid_images = [
1565
2597
  "jpg",
1566
2598
  "jpeg",
@@ -1577,211 +2609,29 @@ var IFrameCard = ({ src }) => {
1577
2609
  }
1578
2610
  const spitedSrc = src.split(".");
1579
2611
  if (valid_images.includes(spitedSrc[spitedSrc.length - 1].toLowerCase())) {
1580
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("img", { src, style: { width: "100%" } }) });
2612
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("img", { src, style: { width: "100%" } }) });
1581
2613
  } else {
1582
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("a", { href: src, target: "_black", children: src }) });
2614
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("a", { href: src, target: "_black", children: src }) });
1583
2615
  }
1584
2616
  };
1585
2617
 
1586
2618
  // src/components/Chat/Chating.tsx
1587
- var import_icons6 = require("@ant-design/icons");
1588
- var import_x = require("@ant-design/x");
1589
- var import_antd7 = require("antd");
2619
+ var import_icons9 = require("@ant-design/icons");
2620
+ var import_x2 = require("@ant-design/x");
2621
+ var import_antd13 = require("antd");
1590
2622
  var import_ErrorBoundary = __toESM(require("antd/es/alert/ErrorBoundary"));
1591
- var import_react11 = __toESM(require("react"));
2623
+ var import_react14 = __toESM(require("react"));
1592
2624
  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");
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");
2625
+ var import_jsx_runtime19 = require("react/jsx-runtime");
1776
2626
  var LazyBubble = ({
1777
- message: message2,
2627
+ message: message3,
1778
2628
  renderContent,
1779
2629
  autoLoadRightPanel
1780
2630
  }) => {
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)(() => {
2631
+ const ref = (0, import_react14.useRef)(null);
2632
+ const [isVisible, setIsVisible] = (0, import_react14.useState)(false);
2633
+ const [wasEverVisible, setWasEverVisible] = (0, import_react14.useState)(false);
2634
+ (0, import_react14.useEffect)(() => {
1785
2635
  const observer = new IntersectionObserver(
1786
2636
  ([entry]) => {
1787
2637
  const visible = entry.isIntersecting;
@@ -1801,22 +2651,22 @@ var LazyBubble = ({
1801
2651
  }
1802
2652
  };
1803
2653
  }, [wasEverVisible]);
1804
- (0, import_react11.useEffect)(() => {
2654
+ (0, import_react14.useEffect)(() => {
1805
2655
  autoLoadRightPanel?.();
1806
2656
  }, []);
1807
2657
  const getPlaceholder = () => {
1808
- const estimatedHeight = message2.content ? Math.min(100, message2.content.length / 5) : 100;
1809
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { height: `${estimatedHeight}px`, minHeight: "50px" } });
2658
+ const estimatedHeight = message3.content ? Math.min(100, message3.content.length / 5) : 100;
2659
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { style: { height: `${estimatedHeight}px`, minHeight: "50px" } });
1810
2660
  };
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() }) });
2661
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ErrorBoundary.default, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { ref, style: { width: "100%" }, children: isVisible || wasEverVisible ? renderContent(message3) : getPlaceholder() }) });
1812
2662
  };
1813
- var MemoizedBubbleList = (0, import_react11.memo)(
2663
+ var MemoizedBubbleList = (0, import_react14.memo)(
1814
2664
  ({
1815
2665
  items,
1816
2666
  roles,
1817
2667
  className
1818
- }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1819
- import_x.Bubble.List,
2668
+ }) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2669
+ import_x2.Bubble.List,
1820
2670
  {
1821
2671
  autoScroll: true,
1822
2672
  items,
@@ -1853,13 +2703,12 @@ var Chating = ({
1853
2703
  todos
1854
2704
  }) => {
1855
2705
  const { t } = (0, import_react_i18next.useTranslation)();
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)(() => {
2706
+ const [content, setContent] = (0, import_react14.useState)("");
2707
+ const [attachedFiles, setAttachedFiles] = (0, import_react14.useState)([]);
2708
+ const [headerOpen, setHeaderOpen] = (0, import_react14.useState)(false);
2709
+ const attachmentsRef = (0, import_react14.useRef)(null);
2710
+ const senderRef = import_react14.default.useRef(null);
2711
+ (0, import_react14.useEffect)(() => {
1863
2712
  regsiterElement("action_show_attachments_uploader", {
1864
2713
  card_view: () => null,
1865
2714
  action: (data) => {
@@ -1868,19 +2717,19 @@ var Chating = ({
1868
2717
  }
1869
2718
  });
1870
2719
  }, []);
1871
- const messageLengthRef = (0, import_react11.useRef)(messages?.length ?? 0);
1872
- (0, import_react11.useEffect)(() => {
2720
+ const messageLengthRef = (0, import_react14.useRef)(messages?.length ?? 0);
2721
+ (0, import_react14.useEffect)(() => {
1873
2722
  if (messages?.length) {
1874
2723
  messageLengthRef.current = messages?.length;
1875
2724
  }
1876
2725
  }, [messages?.length]);
1877
- const renderContent = (0, import_react11.useCallback)(
1878
- (message2) => {
1879
- const { content: content2, files: files2, id } = message2;
2726
+ const renderContent = (0, import_react14.useCallback)(
2727
+ (message3) => {
2728
+ const { content: content2, files: files2, id } = message3;
1880
2729
  try {
1881
2730
  const json = JSON.parse(content2);
1882
2731
  if (json.action && json.message) {
1883
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2732
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1884
2733
  MDResponse,
1885
2734
  {
1886
2735
  content: json.message,
@@ -1890,13 +2739,13 @@ var Chating = ({
1890
2739
  }
1891
2740
  } catch (error2) {
1892
2741
  }
1893
- const tool_calls_md = message2.tool_calls?.map((tool_call) => {
2742
+ const tool_calls_md = message3.tool_calls?.map((tool_call) => {
1894
2743
  return `\`\`\`tool_call
1895
2744
  ${JSON.stringify(tool_call)}
1896
2745
  \`\`\``;
1897
2746
  }) || [];
1898
2747
  const content_md = [content2, ...tool_calls_md].join("\n");
1899
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd7.Space, { direction: "vertical", style: { width: "100%" }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2748
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_antd13.Space, { direction: "vertical", style: { width: "100%" }, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1900
2749
  MDResponse,
1901
2750
  {
1902
2751
  content: content_md,
@@ -1906,18 +2755,18 @@ ${JSON.stringify(tool_call)}
1906
2755
  },
1907
2756
  [handleMDResponseEvent]
1908
2757
  );
1909
- const items = (0, import_react11.useMemo)(
1910
- () => messages.map((message2, index) => ({
1911
- key: message2.id,
1912
- role: message2.role,
2758
+ const items = (0, import_react14.useMemo)(
2759
+ () => messages.map((message3, index) => ({
2760
+ key: message3.id,
2761
+ role: message3.role,
1913
2762
  typing: false,
1914
- content: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2763
+ content: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1915
2764
  LazyBubble,
1916
2765
  {
1917
- message: message2,
2766
+ message: message3,
1918
2767
  renderContent,
1919
2768
  autoLoadRightPanel: () => {
1920
- const { content: content2, role } = message2;
2769
+ const { content: content2, role } = message3;
1921
2770
  const isNewAddedMessage = messageLengthRef.current > 1 && messageLengthRef.current + 1 === messages.length;
1922
2771
  if (index === messages.length - 1 && isNewAddedMessage && role === "ai") {
1923
2772
  try {
@@ -1961,7 +2810,7 @@ ${JSON.stringify(tool_call)}
1961
2810
  const onSubmit = (nextContent) => {
1962
2811
  if (!nextContent && attachedFiles.length === 0) return;
1963
2812
  if (attachedFiles.filter((f) => f.status !== "done").length > 0) {
1964
- import_antd7.message.warning("\u6587\u4EF6\u8FD8\u5728\u4E0A\u4F20\u4E2D...");
2813
+ import_antd13.message.warning("\u6587\u4EF6\u8FD8\u5728\u4E0A\u4F20\u4E2D...");
1965
2814
  return;
1966
2815
  }
1967
2816
  if (!nextContent && attachedFiles.length > 0) {
@@ -2005,7 +2854,7 @@ ${JSON.stringify(tool_call)}
2005
2854
  setHeaderOpen(true);
2006
2855
  }
2007
2856
  if (info.file?.response?.error || info.file.status === "error") {
2008
- import_antd7.message.error(
2857
+ import_antd13.message.error(
2009
2858
  `${info.file.name} file upload failed.${info.file?.response?.message}`
2010
2859
  );
2011
2860
  }
@@ -2017,23 +2866,23 @@ ${JSON.stringify(tool_call)}
2017
2866
  const beforeUpload = (file) => {
2018
2867
  const isLessThan20MB = file.size / 1024 / 1024 < 20;
2019
2868
  if (!isLessThan20MB) {
2020
- import_antd7.message.error(
2869
+ import_antd13.message.error(
2021
2870
  `File must be smaller than 20MB! ${file.name} is too large.`
2022
2871
  );
2023
2872
  return false;
2024
2873
  }
2025
2874
  return true;
2026
2875
  };
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,
2876
+ const attachmentsNode = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_antd13.Badge, { dot: attachedFiles.length > 0 && !headerOpen, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2877
+ import_antd13.Button,
2029
2878
  {
2030
2879
  type: "text",
2031
- icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons6.PaperClipOutlined, {}),
2880
+ icon: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_icons9.PaperClipOutlined, {}),
2032
2881
  onClick: () => setHeaderOpen(!headerOpen)
2033
2882
  }
2034
2883
  ) });
2035
- const senderHeader = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2036
- import_x.Sender.Header,
2884
+ const senderHeader = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2885
+ import_x2.Sender.Header,
2037
2886
  {
2038
2887
  title: "Attachments",
2039
2888
  open: headerOpen,
@@ -2044,8 +2893,8 @@ ${JSON.stringify(tool_call)}
2044
2893
  }
2045
2894
  },
2046
2895
  forceRender: true,
2047
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2048
- import_x.Attachments,
2896
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2897
+ import_x2.Attachments,
2049
2898
  {
2050
2899
  ref: attachmentsRef,
2051
2900
  items: attachedFiles,
@@ -2066,7 +2915,7 @@ ${JSON.stringify(tool_call)}
2066
2915
  multiple: true,
2067
2916
  maxCount: 10,
2068
2917
  placeholder: (type) => ({
2069
- icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons6.CloudUploadOutlined, {}),
2918
+ icon: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_icons9.CloudUploadOutlined, {}),
2070
2919
  title: "\u4E0A\u4F20\u6587\u4EF6",
2071
2920
  description: attachment_placeholder
2072
2921
  })
@@ -2098,7 +2947,7 @@ ${JSON.stringify(tool_call)}
2098
2947
  }
2099
2948
  }
2100
2949
  };
2101
- const extraMetaComponents = (0, import_react11.useMemo)(() => {
2950
+ const extraMetaComponents = (0, import_react14.useMemo)(() => {
2102
2951
  if (extraMeta?.length > 0) {
2103
2952
  return extraMeta.map((meta) => {
2104
2953
  const Element = getElement(meta.id)?.card_view;
@@ -2107,13 +2956,13 @@ ${JSON.stringify(tool_call)}
2107
2956
  try {
2108
2957
  } catch (error2) {
2109
2958
  }
2110
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2959
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2111
2960
  Element,
2112
2961
  {
2113
2962
  component_key: meta.id,
2114
2963
  data: childrenData,
2115
- eventHandler: (e, data, message2, agent) => {
2116
- handleMDResponseEvent?.(e, data, message2, agent);
2964
+ eventHandler: (e, data, message3, agent) => {
2965
+ handleMDResponseEvent?.(e, data, message3, agent);
2117
2966
  }
2118
2967
  },
2119
2968
  meta.id
@@ -2123,22 +2972,22 @@ ${JSON.stringify(tool_call)}
2123
2972
  }
2124
2973
  return void 0;
2125
2974
  }, [extraMeta]);
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)(
2129
- import_x.Welcome,
2975
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
2976
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { children: [
2977
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2978
+ import_x2.Welcome,
2130
2979
  {
2131
2980
  style: { padding: 8 },
2132
2981
  variant: "borderless",
2133
2982
  description,
2134
- icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd7.Avatar, { src: avatar || "/images/avatar.jpeg", size: 48 }),
2983
+ icon: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_antd13.Avatar, { src: avatar || "/images/avatar.jpeg", size: 48 }),
2135
2984
  title: name || "Fina",
2136
- extra: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_antd7.Space, { children: [
2985
+ extra: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_antd13.Space, { children: [
2137
2986
  extra,
2138
- todos && todos.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2139
- import_antd7.Popover,
2987
+ todos && todos.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2988
+ import_antd13.Popover,
2140
2989
  {
2141
- content: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { width: 400 }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2990
+ content: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { style: { width: 400 }, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2142
2991
  Todo,
2143
2992
  {
2144
2993
  data: todos,
@@ -2149,37 +2998,72 @@ ${JSON.stringify(tool_call)}
2149
2998
  title: "Todos",
2150
2999
  trigger: "click",
2151
3000
  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,
3001
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3002
+ import_antd13.Tooltip,
2154
3003
  {
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" })
3004
+ title: `${todos.filter((item) => item.status === "completed").length} / ${todos.length} tasks completed`,
3005
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { style: { cursor: "pointer", display: "inline-flex" }, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3006
+ import_antd13.Progress,
3007
+ {
3008
+ type: "circle",
3009
+ strokeColor: {
3010
+ "0%": "#91caff",
3011
+ "100%": "#003eb3"
3012
+ },
3013
+ percent: Math.round(
3014
+ todos.filter((item) => item.status === "completed").length / todos.length * 100
3015
+ ),
3016
+ status: todos.some((item) => item.status === "in_progress") ? "active" : "normal",
3017
+ width: 30,
3018
+ format: () => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3019
+ "div",
3020
+ {
3021
+ style: {
3022
+ display: "flex",
3023
+ flexDirection: "column",
3024
+ alignItems: "center",
3025
+ lineHeight: 1
3026
+ },
3027
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { style: { fontSize: 8 }, children: [
3028
+ todos.filter(
3029
+ (item) => item.status === "completed"
3030
+ ).length,
3031
+ "/",
3032
+ todos.length
3033
+ ] })
3034
+ }
3035
+ )
3036
+ }
3037
+ ) })
2158
3038
  }
2159
- ) })
3039
+ )
2160
3040
  }
2161
3041
  ),
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,
3042
+ files && Object.keys(files).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_antd13.Tooltip, { title: "File Explorer", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3043
+ import_antd13.Badge,
2164
3044
  {
2165
3045
  count: Object.keys(files).length,
2166
3046
  size: "small",
2167
3047
  color: "blue",
2168
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2169
- import_antd7.Button,
3048
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3049
+ import_antd13.Button,
2170
3050
  {
2171
3051
  type: "text",
2172
- icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons6.FileTextOutlined, {}),
2173
- onClick: () => setFileExplorerVisible(true)
3052
+ icon: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_icons9.FileTextOutlined, {}),
3053
+ onClick: () => onOpenSidePanel({
3054
+ component_key: "file_explorer",
3055
+ message: "File Explorer",
3056
+ data: { files }
3057
+ })
2174
3058
  }
2175
3059
  )
2176
3060
  }
2177
3061
  ) }),
2178
- extraMetaComponents && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_antd7.Space, { align: "center", style: { marginRight: 16 }, children: extraMetaComponents })
3062
+ extraMetaComponents && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_antd13.Space, { align: "center", style: { marginRight: 16 }, children: extraMetaComponents })
2179
3063
  ] })
2180
3064
  }
2181
3065
  ),
2182
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3066
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2183
3067
  "div",
2184
3068
  {
2185
3069
  style: {
@@ -2188,36 +3072,17 @@ ${JSON.stringify(tool_call)}
2188
3072
  }
2189
3073
  )
2190
3074
  ] }),
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)(
3075
+ items.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2211
3076
  MemoizedBubbleList,
2212
3077
  {
2213
3078
  items,
2214
3079
  roles,
2215
3080
  className: styles.messages
2216
3081
  }
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,
3082
+ ) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { style: { flex: 1 } }),
3083
+ isLoading ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_x2.Bubble, { loading: isLoading, variant: "borderless" }) }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_x2.Prompts, { items: senderPromptsItems, onItemClick: onPromptsItemClick }),
3084
+ error && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { style: { padding: "0 16px 8px" }, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3085
+ import_antd13.Alert,
2221
3086
  {
2222
3087
  type: "error",
2223
3088
  banner: true,
@@ -2226,8 +3091,8 @@ ${JSON.stringify(tool_call)}
2226
3091
  message: `${error.message}`
2227
3092
  }
2228
3093
  ) }),
2229
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2230
- import_x.Sender,
3094
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3095
+ import_x2.Sender,
2231
3096
  {
2232
3097
  allowSpeech: true,
2233
3098
  ref: senderRef,
@@ -2241,7 +3106,7 @@ ${JSON.stringify(tool_call)}
2241
3106
  className: styles.sender,
2242
3107
  actions: (ori, { components }) => {
2243
3108
  const { SendButton, LoadingButton } = components;
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)(
3109
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_antd13.Flex, { justify: "space-between", align: "center", children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(LoadingButton, { type: "default" }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2245
3110
  SendButton,
2246
3111
  {
2247
3112
  type: "primary",
@@ -2262,60 +3127,60 @@ ${JSON.stringify(tool_call)}
2262
3127
  };
2263
3128
 
2264
3129
  // src/components/Chat/ThinkingChain.tsx
2265
- var import_icons7 = require("@ant-design/icons");
2266
- var import_x2 = require("@ant-design/x");
2267
- var import_jsx_runtime12 = require("react/jsx-runtime");
3130
+ var import_icons10 = require("@ant-design/icons");
3131
+ var import_x3 = require("@ant-design/x");
3132
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2268
3133
  function getStatusIcon2(status) {
2269
3134
  switch (status) {
2270
3135
  case "success":
2271
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.CheckCircleOutlined, {});
3136
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_icons10.CheckCircleOutlined, {});
2272
3137
  case "error":
2273
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.InfoCircleOutlined, {});
3138
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_icons10.InfoCircleOutlined, {});
2274
3139
  case "pending":
2275
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.LoadingOutlined, {});
3140
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_icons10.LoadingOutlined, {});
2276
3141
  default:
2277
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons7.CheckCircleOutlined, {});
3142
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_icons10.CheckCircleOutlined, {});
2278
3143
  }
2279
3144
  }
2280
- var ThinkingChain = ({ message: message2 }) => {
2281
- const title = message2.name || message2.content.split("\n")[0];
3145
+ var ThinkingChain = ({ message: message3 }) => {
3146
+ const title = message3.name || message3.content.split("\n")[0];
2282
3147
  const items = [
2283
3148
  {
2284
- key: message2.id,
3149
+ key: message3.id,
2285
3150
  title,
2286
- content: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MDResponse, { content: message2.content }),
2287
- status: message2.status,
2288
- icon: getStatusIcon2(message2.status)
3151
+ content: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(MDResponse, { content: message3.content }),
3152
+ status: message3.status,
3153
+ icon: getStatusIcon2(message3.status)
2289
3154
  }
2290
3155
  ];
2291
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2292
- import_x2.ThoughtChain,
3156
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3157
+ import_x3.ThoughtChain,
2293
3158
  {
2294
3159
  items,
2295
- collapsible: message2.status === "success" ? true : false,
3160
+ collapsible: message3.status === "success" ? true : false,
2296
3161
  size: "small"
2297
3162
  }
2298
3163
  );
2299
3164
  };
2300
- var ThinkingChainGroup = ({ message: message2 }) => {
3165
+ var ThinkingChainGroup = ({ message: message3 }) => {
2301
3166
  const title = "\u601D\u8003\u8FC7\u7A0B";
2302
- const children = message2.items?.map((item) => ({
3167
+ const children = message3.items?.map((item) => ({
2303
3168
  key: item.id,
2304
3169
  title: item.name || item.content.split("\n")[0],
2305
- content: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MDResponse, { content: item.content }),
3170
+ content: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(MDResponse, { content: item.content }),
2306
3171
  status: item.status,
2307
3172
  icon: getStatusIcon2(item.status)
2308
3173
  }));
2309
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_x2.ThoughtChain, { items: children, collapsible: true, size: "small" });
3174
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_x3.ThoughtChain, { items: children, collapsible: true, size: "small" });
2310
3175
  };
2311
3176
 
2312
3177
  // src/components/Chat/SideAppViewBrowser.tsx
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 }) => {
3178
+ var import_icons11 = require("@ant-design/icons");
3179
+ var import_antd14 = require("antd");
3180
+ var import_antd_style7 = require("antd-style");
3181
+ var import_react15 = require("react");
3182
+ var import_jsx_runtime21 = require("react/jsx-runtime");
3183
+ var useStyle5 = (0, import_antd_style7.createStyles)(({ token, css }) => {
2319
3184
  return {
2320
3185
  tabContainer: css`
2321
3186
  .ant-tabs-content-holder {
@@ -2334,9 +3199,9 @@ var useStyle4 = (0, import_antd_style6.createStyles)(({ token, css }) => {
2334
3199
  };
2335
3200
  });
2336
3201
  var EmptySideAppView = ({ component_key, data }) => {
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) })
3202
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { children: [
3203
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { children: "\u672A\u627E\u5230\u5BF9\u5E94\u7684\u7EC4\u4EF6\u89C6\u56FE" }),
3204
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("pre", { children: JSON.stringify({ component_key, data }, null, 2) })
2340
3205
  ] });
2341
3206
  };
2342
3207
  var SideAppViewBrowser = ({
@@ -2345,10 +3210,10 @@ var SideAppViewBrowser = ({
2345
3210
  onClose,
2346
3211
  onChangeSize
2347
3212
  }) => {
2348
- const { styles } = useStyle4();
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)([]);
3213
+ const { styles } = useStyle5();
3214
+ const [activeKey, setActiveKey] = (0, import_react15.useState)(JSON.stringify(open_uri));
3215
+ const [currentSize, setCurrentSize] = (0, import_react15.useState)(open_uri.size || "large");
3216
+ const [items, setItems] = (0, import_react15.useState)([]);
2352
3217
  const add = (key, label, children) => {
2353
3218
  const newActiveKey = key;
2354
3219
  const newPanes = [...items];
@@ -2384,7 +3249,7 @@ var SideAppViewBrowser = ({
2384
3249
  remove(targetKey);
2385
3250
  }
2386
3251
  };
2387
- (0, import_react12.useEffect)(() => {
3252
+ (0, import_react15.useEffect)(() => {
2388
3253
  const SideAppView = getElement(open_uri.component_key).side_app_view || EmptySideAppView;
2389
3254
  const key = JSON.stringify(open_uri);
2390
3255
  if (items.find((item) => item.key === key)) {
@@ -2394,7 +3259,7 @@ var SideAppViewBrowser = ({
2394
3259
  add(
2395
3260
  key,
2396
3261
  open_uri.message || open_uri.data.message || "\u672A\u547D\u540D",
2397
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
3262
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2398
3263
  SideAppView,
2399
3264
  {
2400
3265
  component_key: open_uri.component_key,
@@ -2404,7 +3269,7 @@ var SideAppViewBrowser = ({
2404
3269
  )
2405
3270
  );
2406
3271
  }, [open_uri]);
2407
- (0, import_react12.useEffect)(() => {
3272
+ (0, import_react15.useEffect)(() => {
2408
3273
  if (open_uri.size && open_uri.size !== currentSize) {
2409
3274
  setCurrentSize(open_uri.size);
2410
3275
  }
@@ -2442,26 +3307,26 @@ var SideAppViewBrowser = ({
2442
3307
  const getSizeIcon = (size) => {
2443
3308
  switch (size) {
2444
3309
  case "middle":
2445
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons8.CompressOutlined, {});
3310
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_icons11.CompressOutlined, {});
2446
3311
  case "large":
2447
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons8.ExpandOutlined, {});
3312
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_icons11.ExpandOutlined, {});
2448
3313
  case "full":
2449
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons8.FullscreenOutlined, {});
3314
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_icons11.FullscreenOutlined, {});
2450
3315
  default:
2451
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons8.ExpandOutlined, {});
3316
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_icons11.ExpandOutlined, {});
2452
3317
  }
2453
3318
  };
2454
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2455
- import_antd8.Tabs,
3319
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3320
+ import_antd14.Tabs,
2456
3321
  {
2457
3322
  className: styles.tabContainer,
2458
3323
  type: "editable-card",
2459
3324
  style: { height: "100%" },
2460
3325
  hideAdd: true,
2461
3326
  tabBarExtraContent: {
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,
3327
+ right: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { display: "flex", gap: "4px" }, children: [
3328
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3329
+ import_antd14.Button,
2465
3330
  {
2466
3331
  style: { margin: "8px 0" },
2467
3332
  size: "large",
@@ -2471,13 +3336,13 @@ var SideAppViewBrowser = ({
2471
3336
  title: `\u5F53\u524D\u5C3A\u5BF8: ${getSizeLabel(currentSize)}, \u70B9\u51FB\u5207\u6362`
2472
3337
  }
2473
3338
  ),
2474
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2475
- import_antd8.Button,
3339
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3340
+ import_antd14.Button,
2476
3341
  {
2477
3342
  style: { margin: "8px 0" },
2478
3343
  size: "large",
2479
3344
  type: "text",
2480
- icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons8.CloseOutlined, {}),
3345
+ icon: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_icons11.CloseOutlined, {}),
2481
3346
  onClick: () => {
2482
3347
  onClose();
2483
3348
  }
@@ -2494,9 +3359,9 @@ var SideAppViewBrowser = ({
2494
3359
  };
2495
3360
 
2496
3361
  // src/components/Chat/context.tsx
2497
- var import_react13 = require("react");
2498
- var chatContext = (0, import_react13.createContext)({
2499
- eventHandler: (component_key, data, message2) => {
3362
+ var import_react16 = require("react");
3363
+ var chatContext = (0, import_react16.createContext)({
3364
+ eventHandler: (component_key, data, message3) => {
2500
3365
  }
2501
3366
  });
2502
3367
  // Annotate the CommonJS export names for ESM import in node:
@@ -2511,7 +3376,6 @@ var chatContext = (0, import_react13.createContext)({
2511
3376
  ThinkingChain,
2512
3377
  ThinkingChainGroup,
2513
3378
  chatContext,
2514
- elements,
2515
3379
  getElement,
2516
3380
  regsiterElement,
2517
3381
  useAgentGraph,