@rodrigocoliveira/agno-react 1.1.5 → 1.2.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/ui.mjs CHANGED
@@ -2719,7 +2719,8 @@ function AgnoMessageItem({
2719
2719
  showToolCalls = true,
2720
2720
  showFilePreview = true,
2721
2721
  showImageLightbox = true,
2722
- formatTimestamp
2722
+ formatTimestamp,
2723
+ toolResultRenderers
2723
2724
  }) {
2724
2725
  const isUser = message.role === "user";
2725
2726
  const hasError = message.streamingError;
@@ -2919,6 +2920,15 @@ function AgnoMessageItem({
2919
2920
  }, tool.tool_call_id, false, undefined, this);
2920
2921
  })
2921
2922
  }, undefined, false, undefined, this),
2923
+ toolResultRenderers && message.tool_calls?.map((tool) => {
2924
+ const renderer = toolResultRenderers[tool.tool_name];
2925
+ const content = tool.result ?? tool.content;
2926
+ if (!renderer || !content)
2927
+ return null;
2928
+ return /* @__PURE__ */ jsxDEV35("div", {
2929
+ children: renderer(tool.tool_args, content)
2930
+ }, `result-${tool.tool_call_id}`, false, undefined, this);
2931
+ }),
2922
2932
  renderMedia ? renderMedia(message) : (() => {
2923
2933
  const mediaClassName = classNames?.assistant?.media;
2924
2934
  return /* @__PURE__ */ jsxDEV35(Fragment5, {
@@ -3459,11 +3469,14 @@ function AgnoChatRoot({
3459
3469
  children,
3460
3470
  toolHandlers = {},
3461
3471
  autoExecuteTools = true,
3472
+ toolResultRenderers,
3462
3473
  className,
3463
3474
  ...divProps
3464
3475
  }) {
3465
3476
  const chat = useAgnoChat();
3466
- const toolExec = useAgnoToolExecution(toolHandlers, autoExecuteTools);
3477
+ const toolExec = useAgnoToolExecution(toolHandlers, autoExecuteTools, {
3478
+ skipHydration: toolResultRenderers ? Object.keys(toolResultRenderers) : undefined
3479
+ });
3467
3480
  const containerRef = useRef6(null);
3468
3481
  const sendRef = useRef6(chat.sendMessage);
3469
3482
  sendRef.current = chat.sendMessage;
@@ -3513,7 +3526,8 @@ function AgnoChatRoot({
3513
3526
  executionError,
3514
3527
  handleSend,
3515
3528
  inputDisabled: isStreaming || isPaused,
3516
- dropZoneContainerRef: containerRef
3529
+ dropZoneContainerRef: containerRef,
3530
+ toolResultRenderers
3517
3531
  }), [
3518
3532
  messages,
3519
3533
  sendMessage,
@@ -3532,7 +3546,8 @@ function AgnoChatRoot({
3532
3546
  executeTools,
3533
3547
  continueWithResults,
3534
3548
  executionError,
3535
- handleSend
3549
+ handleSend,
3550
+ toolResultRenderers
3536
3551
  ]);
3537
3552
  return /* @__PURE__ */ jsxDEV37(AgnoChatContext.Provider, {
3538
3553
  value: contextValue,
@@ -3612,9 +3627,11 @@ function AgnoChatMessages({
3612
3627
  suggestedPrompts = DEFAULT_PROMPTS,
3613
3628
  children,
3614
3629
  showThinkingIndicator = true,
3615
- renderThinkingIndicator
3630
+ renderThinkingIndicator,
3631
+ toolResultRenderers: propToolResultRenderers
3616
3632
  }) {
3617
- const { messages, isStreaming } = useAgnoChatContext();
3633
+ const { messages, isStreaming, toolResultRenderers: contextToolResultRenderers } = useAgnoChatContext();
3634
+ const toolResultRenderers = propToolResultRenderers ?? contextToolResultRenderers;
3618
3635
  const lastMessage = messages[messages.length - 1];
3619
3636
  const isThinking = showThinkingIndicator && isStreaming && (!lastMessage || lastMessage.role !== "user") && !lastMessage?.content;
3620
3637
  let lastAssistantIndex = -1;
@@ -3636,7 +3653,8 @@ function AgnoChatMessages({
3636
3653
  ...renderContent !== undefined && { renderContent },
3637
3654
  ...renderMedia !== undefined && { renderMedia },
3638
3655
  ...formatTimestamp !== undefined && { formatTimestamp },
3639
- ...messageClassNames !== undefined && { classNames: messageClassNames }
3656
+ ...messageClassNames !== undefined && { classNames: messageClassNames },
3657
+ ...toolResultRenderers !== undefined && { toolResultRenderers }
3640
3658
  };
3641
3659
  const resolvedEmptyState = children ?? emptyState ?? /* @__PURE__ */ jsxDEV39("div", {
3642
3660
  className: "flex flex-col items-center gap-6",
@@ -3721,71 +3739,9 @@ function AgnoChatEmptyState({ children, className, ...props }) {
3721
3739
  }, undefined, false, undefined, this);
3722
3740
  }
3723
3741
 
3724
- // src/ui/composed/agno-chat/tool-status.tsx
3725
- import { Loader2 as Loader22, Wrench } from "lucide-react";
3726
- import { jsxDEV as jsxDEV41, Fragment as Fragment6 } from "react/jsx-dev-runtime";
3727
- function AgnoChatToolStatus({ className }) {
3728
- const { isPaused, isExecuting, pendingTools } = useAgnoChatContext();
3729
- if (!isPaused && !isExecuting)
3730
- return null;
3731
- return /* @__PURE__ */ jsxDEV41("div", {
3732
- className: cn("px-4 py-2.5 border-t border-border bg-primary/5", className),
3733
- children: /* @__PURE__ */ jsxDEV41("div", {
3734
- className: "flex items-center gap-2.5 text-sm max-w-3xl mx-auto",
3735
- children: isExecuting ? /* @__PURE__ */ jsxDEV41(Fragment6, {
3736
- children: [
3737
- /* @__PURE__ */ jsxDEV41("div", {
3738
- className: "h-5 w-5 rounded-full bg-primary/10 flex items-center justify-center",
3739
- children: /* @__PURE__ */ jsxDEV41(Loader22, {
3740
- className: "h-3 w-3 animate-spin text-primary"
3741
- }, undefined, false, undefined, this)
3742
- }, undefined, false, undefined, this),
3743
- /* @__PURE__ */ jsxDEV41("span", {
3744
- className: "text-muted-foreground",
3745
- children: [
3746
- "Executing",
3747
- " ",
3748
- /* @__PURE__ */ jsxDEV41("span", {
3749
- className: "font-medium text-foreground",
3750
- children: pendingTools.length
3751
- }, undefined, false, undefined, this),
3752
- " tool",
3753
- pendingTools.length !== 1 ? "s" : "",
3754
- "..."
3755
- ]
3756
- }, undefined, true, undefined, this)
3757
- ]
3758
- }, undefined, true, undefined, this) : /* @__PURE__ */ jsxDEV41(Fragment6, {
3759
- children: [
3760
- /* @__PURE__ */ jsxDEV41("div", {
3761
- className: "h-5 w-5 rounded-full bg-amber-500/10 flex items-center justify-center",
3762
- children: /* @__PURE__ */ jsxDEV41(Wrench, {
3763
- className: "h-3 w-3 text-amber-600 dark:text-amber-400"
3764
- }, undefined, false, undefined, this)
3765
- }, undefined, false, undefined, this),
3766
- /* @__PURE__ */ jsxDEV41("span", {
3767
- className: "text-muted-foreground",
3768
- children: [
3769
- "Preparing",
3770
- " ",
3771
- /* @__PURE__ */ jsxDEV41("span", {
3772
- className: "font-medium text-foreground",
3773
- children: pendingTools.length
3774
- }, undefined, false, undefined, this),
3775
- " tool",
3776
- pendingTools.length !== 1 ? "s" : "",
3777
- "..."
3778
- ]
3779
- }, undefined, true, undefined, this)
3780
- ]
3781
- }, undefined, true, undefined, this)
3782
- }, undefined, false, undefined, this)
3783
- }, undefined, false, undefined, this);
3784
- }
3785
-
3786
3742
  // src/ui/composed/agno-chat/error-bar.tsx
3787
3743
  import { useState as useState9, useEffect as useEffect7, useRef as useRef8 } from "react";
3788
- import { jsxDEV as jsxDEV42 } from "react/jsx-dev-runtime";
3744
+ import { jsxDEV as jsxDEV41 } from "react/jsx-dev-runtime";
3789
3745
  function AgnoChatErrorBar({
3790
3746
  className,
3791
3747
  text,
@@ -3825,23 +3781,23 @@ function AgnoChatErrorBar({
3825
3781
  if (children) {
3826
3782
  return typeof children === "function" ? children(rawMessage) : children;
3827
3783
  }
3828
- return /* @__PURE__ */ jsxDEV42("div", {
3784
+ return /* @__PURE__ */ jsxDEV41("div", {
3829
3785
  className: "flex items-center gap-2 max-w-3xl mx-auto",
3830
3786
  children: [
3831
- icon && /* @__PURE__ */ jsxDEV42("span", {
3787
+ icon && /* @__PURE__ */ jsxDEV41("span", {
3832
3788
  className: "shrink-0",
3833
3789
  children: icon
3834
3790
  }, undefined, false, undefined, this),
3835
- /* @__PURE__ */ jsxDEV42("p", {
3791
+ /* @__PURE__ */ jsxDEV41("p", {
3836
3792
  className: "text-sm text-destructive flex-1",
3837
3793
  children: displayMessage
3838
3794
  }, undefined, false, undefined, this),
3839
- dismissible && /* @__PURE__ */ jsxDEV42("button", {
3795
+ dismissible && /* @__PURE__ */ jsxDEV41("button", {
3840
3796
  type: "button",
3841
3797
  onClick: () => setHidden(true),
3842
3798
  className: "shrink-0 text-destructive/60 hover:text-destructive transition-colors",
3843
3799
  "aria-label": "Dismiss error",
3844
- children: /* @__PURE__ */ jsxDEV42("svg", {
3800
+ children: /* @__PURE__ */ jsxDEV41("svg", {
3845
3801
  xmlns: "http://www.w3.org/2000/svg",
3846
3802
  width: "16",
3847
3803
  height: "16",
@@ -3852,10 +3808,10 @@ function AgnoChatErrorBar({
3852
3808
  strokeLinecap: "round",
3853
3809
  strokeLinejoin: "round",
3854
3810
  children: [
3855
- /* @__PURE__ */ jsxDEV42("path", {
3811
+ /* @__PURE__ */ jsxDEV41("path", {
3856
3812
  d: "M18 6 6 18"
3857
3813
  }, undefined, false, undefined, this),
3858
- /* @__PURE__ */ jsxDEV42("path", {
3814
+ /* @__PURE__ */ jsxDEV41("path", {
3859
3815
  d: "m6 6 12 12"
3860
3816
  }, undefined, false, undefined, this)
3861
3817
  ]
@@ -3864,14 +3820,14 @@ function AgnoChatErrorBar({
3864
3820
  ]
3865
3821
  }, undefined, true, undefined, this);
3866
3822
  };
3867
- return /* @__PURE__ */ jsxDEV42("div", {
3823
+ return /* @__PURE__ */ jsxDEV41("div", {
3868
3824
  className: cn("px-4 py-2.5 bg-destructive/5 border-t border-destructive/20", className),
3869
3825
  children: renderContent()
3870
3826
  }, undefined, false, undefined, this);
3871
3827
  }
3872
3828
 
3873
3829
  // src/ui/composed/agno-chat/input.tsx
3874
- import { jsxDEV as jsxDEV43 } from "react/jsx-dev-runtime";
3830
+ import { jsxDEV as jsxDEV42 } from "react/jsx-dev-runtime";
3875
3831
  function AgnoChatInputArea({
3876
3832
  className,
3877
3833
  children,
@@ -3884,11 +3840,11 @@ function AgnoChatInputArea({
3884
3840
  dropZoneProps
3885
3841
  }) {
3886
3842
  const { handleSend, inputDisabled, isStreaming, isPaused, cancelRun, dropZoneContainerRef } = useAgnoChatContext();
3887
- return /* @__PURE__ */ jsxDEV43("div", {
3843
+ return /* @__PURE__ */ jsxDEV42("div", {
3888
3844
  className: cn("border-t border-border bg-background/80 backdrop-blur-sm", className),
3889
- children: /* @__PURE__ */ jsxDEV43("div", {
3845
+ children: /* @__PURE__ */ jsxDEV42("div", {
3890
3846
  className: "mx-auto px-4 py-2",
3891
- children: children ? children({ onSend: handleSend, disabled: inputDisabled, isStreaming, isPaused }) : /* @__PURE__ */ jsxDEV43(AgnoChatInput, {
3847
+ children: children ? children({ onSend: handleSend, disabled: inputDisabled, isStreaming, isPaused }) : /* @__PURE__ */ jsxDEV42(AgnoChatInput, {
3892
3848
  onSend: handleSend,
3893
3849
  disabled: inputDisabled,
3894
3850
  isStreaming,
@@ -3911,7 +3867,6 @@ var AgnoChat = Object.assign(AgnoChatRoot, {
3911
3867
  Messages: AgnoChatMessages,
3912
3868
  EmptyState: AgnoChatEmptyState,
3913
3869
  SuggestedPrompts: AgnoChatSuggestedPrompts,
3914
- ToolStatus: AgnoChatToolStatus,
3915
3870
  ErrorBar: AgnoChatErrorBar,
3916
3871
  Input: AgnoChatInputArea
3917
3872
  });
@@ -4059,7 +4014,6 @@ export {
4059
4014
  ArtifactAction,
4060
4015
  Artifact,
4061
4016
  AgnoMessageItem,
4062
- AgnoChatToolStatus,
4063
4017
  AgnoChatSuggestedPrompts,
4064
4018
  AgnoChatRoot,
4065
4019
  AgnoChatMessages,
@@ -4074,4 +4028,4 @@ export {
4074
4028
  Accordion
4075
4029
  };
4076
4030
 
4077
- //# debugId=6E9B25001B68B11264756E2164756E21
4031
+ //# debugId=F991C700ECBE5AE664756E2164756E21