@vegintech/langchain-react-agent 0.0.10 → 0.0.12

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.
Files changed (2) hide show
  1. package/dist/index.mjs +63 -34
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -396,8 +396,8 @@ function DebugPanel({ messages, streamState, visible = true }) {
396
396
  const [isDraggingButton, setIsDraggingButton] = useState(false);
397
397
  const buttonDragRef = useRef(null);
398
398
  const [dialogPos, setDialogPos] = useState({
399
- x: -400,
400
- y: -300
399
+ x: 0,
400
+ y: 0
401
401
  });
402
402
  const [isDraggingDialog, setIsDraggingDialog] = useState(false);
403
403
  const dialogDragRef = useRef(null);
@@ -508,9 +508,60 @@ function DebugPanel({ messages, streamState, visible = true }) {
508
508
  };
509
509
  };
510
510
  const formatContent = (content) => {
511
- if (!content) return "-";
511
+ if (!content) return "";
512
512
  return content;
513
513
  };
514
+ const renderMessageContent = (message) => {
515
+ const hasToolCalls = message.tool_calls && Array.isArray(message.tool_calls) && message.tool_calls.length > 0;
516
+ return /* @__PURE__ */ jsxs("div", {
517
+ style: {
518
+ display: "flex",
519
+ flexDirection: "column",
520
+ gap: "8px"
521
+ },
522
+ children: [message.content && /* @__PURE__ */ jsx("div", {
523
+ style: {
524
+ color: "#333",
525
+ lineHeight: 1.5,
526
+ wordBreak: "break-all"
527
+ },
528
+ children: formatContent(message.content)
529
+ }), hasToolCalls && /* @__PURE__ */ jsxs("div", {
530
+ style: {
531
+ marginTop: "4px",
532
+ padding: "8px",
533
+ background: "#f6ffed",
534
+ border: "1px solid #b7eb8f",
535
+ borderRadius: "6px"
536
+ },
537
+ children: [/* @__PURE__ */ jsxs("div", {
538
+ style: {
539
+ fontSize: "11px",
540
+ fontWeight: 600,
541
+ color: "#389e0d",
542
+ marginBottom: "6px",
543
+ display: "flex",
544
+ alignItems: "center",
545
+ gap: "4px"
546
+ },
547
+ children: [/* @__PURE__ */ jsx("span", { children: "🔧" }), /* @__PURE__ */ jsxs("span", { children: [
548
+ "Tool Calls (",
549
+ message.tool_calls.length,
550
+ ")"
551
+ ] })]
552
+ }), /* @__PURE__ */ jsx("pre", {
553
+ style: {
554
+ ...preStyle,
555
+ background: "#fff",
556
+ border: "1px solid #d9f7be",
557
+ maxHeight: "200px",
558
+ fontSize: "11px"
559
+ },
560
+ children: formatJson(message.tool_calls)
561
+ })]
562
+ })]
563
+ });
564
+ };
514
565
  const buttonStyle = {
515
566
  position: "fixed",
516
567
  right: `${20 - buttonPos.x}px`,
@@ -533,11 +584,12 @@ function DebugPanel({ messages, streamState, visible = true }) {
533
584
  };
534
585
  const dialogStyle = {
535
586
  position: "fixed",
536
- right: `${20 - dialogPos.x}px`,
537
- bottom: `${80 - dialogPos.y}px`,
538
- width: "800px",
587
+ left: "50%",
588
+ top: "50%",
589
+ transform: `translate(calc(-50% + ${dialogPos.x}px), calc(-50% + ${dialogPos.y}px))`,
590
+ width: "1000px",
539
591
  maxWidth: "90vw",
540
- height: "600px",
592
+ height: "650px",
541
593
  maxHeight: "85vh",
542
594
  background: "#fff",
543
595
  borderRadius: "12px",
@@ -546,8 +598,7 @@ function DebugPanel({ messages, streamState, visible = true }) {
546
598
  display: "flex",
547
599
  flexDirection: "column",
548
600
  overflow: "hidden",
549
- cursor: isDraggingDialog ? "grabbing" : "default",
550
- userSelect: "none"
601
+ cursor: isDraggingDialog ? "grabbing" : "default"
551
602
  };
552
603
  const headerStyle = {
553
604
  padding: "12px 16px",
@@ -718,13 +769,6 @@ function DebugPanel({ messages, streamState, visible = true }) {
718
769
  /* @__PURE__ */ jsx("th", {
719
770
  style: tableHeaderStyle,
720
771
  children: "内容"
721
- }),
722
- /* @__PURE__ */ jsx("th", {
723
- style: {
724
- ...tableHeaderStyle,
725
- width: "100px"
726
- },
727
- children: "ID"
728
772
  })
729
773
  ] }) }), /* @__PURE__ */ jsx("tbody", { children: messages.map((msg, index) => {
730
774
  const message = msg;
@@ -762,28 +806,13 @@ function DebugPanel({ messages, streamState, visible = true }) {
762
806
  }),
763
807
  /* @__PURE__ */ jsx("td", {
764
808
  style: tableCellStyle,
765
- children: /* @__PURE__ */ jsx("div", {
766
- style: {
767
- color: "#333",
768
- lineHeight: 1.5,
769
- wordBreak: "break-all"
770
- },
771
- children: formatContent(message.content)
772
- })
773
- }),
774
- /* @__PURE__ */ jsx("td", {
775
- style: {
776
- ...tableCellStyle,
777
- color: "#999",
778
- fontSize: "12px"
779
- },
780
- children: message.id?.slice(-8) || "-"
809
+ children: renderMessageContent(message)
781
810
  })
782
811
  ]
783
812
  }, index), isExpanded && /* @__PURE__ */ jsx("tr", {
784
813
  style: expandedRowStyle,
785
814
  children: /* @__PURE__ */ jsx("td", {
786
- colSpan: 4,
815
+ colSpan: 3,
787
816
  style: {
788
817
  padding: 0,
789
818
  borderBottom: "1px solid #e8e8e8"
@@ -1314,7 +1343,7 @@ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId: external
1314
1343
  }, [submitToStream]);
1315
1344
  const handleSend = useCallback(async (params) => {
1316
1345
  let messages = [];
1317
- if (onPreSend && params.message.trim()) messages = (await onPreSend(params)).messages.filter((m) => m != null);
1346
+ if (onPreSend && params.message.trim()) messages = (await onPreSend(params)).messages.filter((m) => m != null).map((m) => ({ ...m }));
1318
1347
  else {
1319
1348
  if (!params.message.trim()) return;
1320
1349
  messages = [{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vegintech/langchain-react-agent",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "LangChain Agent UI component library for React",
5
5
  "license": "MIT",
6
6
  "files": [