@copilotkitnext/react 0.0.21-alpha.0 → 0.0.22-alpha.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.mjs CHANGED
@@ -1328,7 +1328,7 @@ CopilotChatInput.AddMenuButton.displayName = "CopilotChatInput.AddMenuButton";
1328
1328
  var CopilotChatInput_default = CopilotChatInput;
1329
1329
 
1330
1330
  // src/components/chat/CopilotChatAssistantMessage.tsx
1331
- import { useState as useState7 } from "react";
1331
+ import { useState as useState6 } from "react";
1332
1332
  import {
1333
1333
  Copy,
1334
1334
  Check as Check2,
@@ -1864,34 +1864,26 @@ function useFrontendTool(tool) {
1864
1864
  }
1865
1865
 
1866
1866
  // src/hooks/use-human-in-the-loop.tsx
1867
- import { useState as useState5, useCallback as useCallback4, useRef as useRef5, useEffect as useEffect7 } from "react";
1867
+ import { useCallback as useCallback4, useRef as useRef5, useEffect as useEffect7 } from "react";
1868
1868
  import React7 from "react";
1869
1869
  function useHumanInTheLoop(tool) {
1870
1870
  const { copilotkit } = useCopilotKit();
1871
- const [status, setStatus] = useState5(
1872
- "inProgress"
1873
- );
1874
- const statusRef = useRef5(status);
1875
1871
  const resolvePromiseRef = useRef5(null);
1876
- statusRef.current = status;
1877
1872
  const respond = useCallback4(async (result) => {
1878
1873
  if (resolvePromiseRef.current) {
1879
1874
  resolvePromiseRef.current(result);
1880
- setStatus("complete");
1881
1875
  resolvePromiseRef.current = null;
1882
1876
  }
1883
1877
  }, []);
1884
1878
  const handler = useCallback4(async () => {
1885
1879
  return new Promise((resolve) => {
1886
- setStatus("executing");
1887
1880
  resolvePromiseRef.current = resolve;
1888
1881
  });
1889
1882
  }, []);
1890
1883
  const RenderComponent = useCallback4(
1891
1884
  (props) => {
1892
1885
  const ToolComponent = tool.render;
1893
- const currentStatus = statusRef.current;
1894
- if (currentStatus === "inProgress" && props.status === "inProgress") {
1886
+ if (props.status === "inProgress") {
1895
1887
  const enhancedProps = {
1896
1888
  ...props,
1897
1889
  name: tool.name,
@@ -1899,7 +1891,7 @@ function useHumanInTheLoop(tool) {
1899
1891
  respond: void 0
1900
1892
  };
1901
1893
  return React7.createElement(ToolComponent, enhancedProps);
1902
- } else if (currentStatus === "executing" && props.status === "executing") {
1894
+ } else if (props.status === "executing") {
1903
1895
  const enhancedProps = {
1904
1896
  ...props,
1905
1897
  name: tool.name,
@@ -1907,7 +1899,7 @@ function useHumanInTheLoop(tool) {
1907
1899
  respond
1908
1900
  };
1909
1901
  return React7.createElement(ToolComponent, enhancedProps);
1910
- } else if (currentStatus === "complete" && props.status === "complete") {
1902
+ } else if (props.status === "complete") {
1911
1903
  const enhancedProps = {
1912
1904
  ...props,
1913
1905
  name: tool.name,
@@ -2014,17 +2006,17 @@ function useAgentContext(context) {
2014
2006
  }
2015
2007
 
2016
2008
  // src/hooks/use-suggestions.tsx
2017
- import { useCallback as useCallback5, useEffect as useEffect10, useMemo as useMemo5, useState as useState6 } from "react";
2009
+ import { useCallback as useCallback5, useEffect as useEffect10, useMemo as useMemo5, useState as useState5 } from "react";
2018
2010
  import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID5 } from "@copilotkitnext/shared";
2019
2011
  function useSuggestions({ agentId } = {}) {
2020
2012
  const { copilotkit } = useCopilotKit();
2021
2013
  const config = useCopilotChatConfiguration();
2022
2014
  const resolvedAgentId = useMemo5(() => agentId ?? config?.agentId ?? DEFAULT_AGENT_ID5, [agentId, config?.agentId]);
2023
- const [suggestions, setSuggestions] = useState6(() => {
2015
+ const [suggestions, setSuggestions] = useState5(() => {
2024
2016
  const result = copilotkit.getSuggestions(resolvedAgentId);
2025
2017
  return result.suggestions;
2026
2018
  });
2027
- const [isLoading, setIsLoading] = useState6(() => {
2019
+ const [isLoading, setIsLoading] = useState5(() => {
2028
2020
  const result = copilotkit.getSuggestions(resolvedAgentId);
2029
2021
  return result.isLoading;
2030
2022
  });
@@ -2390,7 +2382,7 @@ function CopilotChatAssistantMessage({
2390
2382
  CopilotChatAssistantMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
2391
2383
  const config = useCopilotChatConfiguration();
2392
2384
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2393
- const [copied, setCopied] = useState7(false);
2385
+ const [copied, setCopied] = useState6(false);
2394
2386
  const handleClick = (event) => {
2395
2387
  setCopied(true);
2396
2388
  setTimeout(() => setCopied(false), 2e3);
@@ -2468,7 +2460,7 @@ CopilotChatAssistantMessage.RegenerateButton.displayName = "CopilotChatAssistant
2468
2460
  var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
2469
2461
 
2470
2462
  // src/components/chat/CopilotChatUserMessage.tsx
2471
- import { useMemo as useMemo7, useState as useState8 } from "react";
2463
+ import { useMemo as useMemo7, useState as useState7 } from "react";
2472
2464
  import { Copy as Copy2, Check as Check3, Edit, ChevronLeft, ChevronRight } from "lucide-react";
2473
2465
  import { twMerge as twMerge5 } from "tailwind-merge";
2474
2466
  import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
@@ -2631,7 +2623,7 @@ function CopilotChatUserMessage({
2631
2623
  CopilotChatUserMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
2632
2624
  const config = useCopilotChatConfiguration();
2633
2625
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2634
- const [copied, setCopied] = useState8(false);
2626
+ const [copied, setCopied] = useState7(false);
2635
2627
  const handleClick = (event) => {
2636
2628
  setCopied(true);
2637
2629
  setTimeout(() => setCopied(false), 2e3);
@@ -2910,15 +2902,15 @@ CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
2910
2902
  var CopilotChatMessageView_default = CopilotChatMessageView;
2911
2903
 
2912
2904
  // src/components/chat/CopilotChatView.tsx
2913
- import React11, { useRef as useRef7, useState as useState10, useEffect as useEffect13 } from "react";
2905
+ import React11, { useRef as useRef7, useState as useState9, useEffect as useEffect13 } from "react";
2914
2906
  import { twMerge as twMerge7 } from "tailwind-merge";
2915
2907
  import { StickToBottom, useStickToBottom, useStickToBottomContext } from "use-stick-to-bottom";
2916
2908
  import { ChevronDown } from "lucide-react";
2917
2909
 
2918
2910
  // src/hooks/use-keyboard-height.tsx
2919
- import { useState as useState9, useEffect as useEffect12 } from "react";
2911
+ import { useState as useState8, useEffect as useEffect12 } from "react";
2920
2912
  function useKeyboardHeight() {
2921
- const [keyboardState, setKeyboardState] = useState9({
2913
+ const [keyboardState, setKeyboardState] = useState8({
2922
2914
  isKeyboardOpen: false,
2923
2915
  keyboardHeight: 0,
2924
2916
  availableHeight: typeof window !== "undefined" ? window.innerHeight : 0,
@@ -2978,8 +2970,8 @@ function CopilotChatView({
2978
2970
  ...props
2979
2971
  }) {
2980
2972
  const inputContainerRef = useRef7(null);
2981
- const [inputContainerHeight, setInputContainerHeight] = useState10(0);
2982
- const [isResizing, setIsResizing] = useState10(false);
2973
+ const [inputContainerHeight, setInputContainerHeight] = useState9(0);
2974
+ const [isResizing, setIsResizing] = useState9(false);
2983
2975
  const resizeTimeoutRef = useRef7(null);
2984
2976
  const { isKeyboardOpen, keyboardHeight, availableHeight } = useKeyboardHeight();
2985
2977
  useEffect13(() => {
@@ -3095,9 +3087,9 @@ function CopilotChatView({
3095
3087
  className,
3096
3088
  ...props
3097
3089
  }) => {
3098
- const [hasMounted, setHasMounted] = useState10(false);
3090
+ const [hasMounted, setHasMounted] = useState9(false);
3099
3091
  const { scrollRef, contentRef, scrollToBottom } = useStickToBottom();
3100
- const [showScrollButton, setShowScrollButton] = useState10(false);
3092
+ const [showScrollButton, setShowScrollButton] = useState9(false);
3101
3093
  useEffect13(() => {
3102
3094
  setHasMounted(true);
3103
3095
  }, []);
@@ -3365,7 +3357,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
3365
3357
  })(CopilotChat || (CopilotChat = {}));
3366
3358
 
3367
3359
  // src/components/chat/CopilotChatToggleButton.tsx
3368
- import React12, { useState as useState11 } from "react";
3360
+ import React12, { useState as useState10 } from "react";
3369
3361
  import { MessageCircle, X as X2 } from "lucide-react";
3370
3362
  import { jsx as jsx20, jsxs as jsxs11 } from "react/jsx-runtime";
3371
3363
  var DefaultOpenIcon = ({
@@ -3396,7 +3388,7 @@ var CopilotChatToggleButton = React12.forwardRef(function CopilotChatToggleButto
3396
3388
  const { onClick, type, disabled, ...restProps } = buttonProps;
3397
3389
  const configuration = useCopilotChatConfiguration();
3398
3390
  const labels = configuration?.labels ?? CopilotChatDefaultLabels;
3399
- const [fallbackOpen, setFallbackOpen] = useState11(false);
3391
+ const [fallbackOpen, setFallbackOpen] = useState10(false);
3400
3392
  const isOpen = configuration?.isModalOpen ?? fallbackOpen;
3401
3393
  const setModalOpen = configuration?.setModalOpen ?? setFallbackOpen;
3402
3394
  const handleClick = (event) => {
@@ -3482,7 +3474,7 @@ CopilotChatToggleButton.displayName = "CopilotChatToggleButton";
3482
3474
  var CopilotChatToggleButton_default = CopilotChatToggleButton;
3483
3475
 
3484
3476
  // src/components/chat/CopilotSidebarView.tsx
3485
- import { useEffect as useEffect15, useRef as useRef8, useState as useState12 } from "react";
3477
+ import { useEffect as useEffect15, useRef as useRef8, useState as useState11 } from "react";
3486
3478
 
3487
3479
  // src/components/chat/CopilotModalHeader.tsx
3488
3480
  import { useCallback as useCallback8 } from "react";
@@ -3576,7 +3568,7 @@ function CopilotSidebarView({ header, width, ...props }) {
3576
3568
  const configuration = useCopilotChatConfiguration();
3577
3569
  const isSidebarOpen = configuration?.isModalOpen ?? false;
3578
3570
  const sidebarRef = useRef8(null);
3579
- const [sidebarWidth, setSidebarWidth] = useState12(width ?? DEFAULT_SIDEBAR_WIDTH);
3571
+ const [sidebarWidth, setSidebarWidth] = useState11(width ?? DEFAULT_SIDEBAR_WIDTH);
3580
3572
  const widthToCss = (w) => {
3581
3573
  return typeof w === "number" ? `${w}px` : w;
3582
3574
  };
@@ -3665,7 +3657,7 @@ function CopilotSidebarView({ header, width, ...props }) {
3665
3657
  CopilotSidebarView.displayName = "CopilotSidebarView";
3666
3658
 
3667
3659
  // src/components/chat/CopilotPopupView.tsx
3668
- import { useEffect as useEffect16, useMemo as useMemo9, useRef as useRef9, useState as useState13 } from "react";
3660
+ import { useEffect as useEffect16, useMemo as useMemo9, useRef as useRef9, useState as useState12 } from "react";
3669
3661
  import { Fragment as Fragment8, jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
3670
3662
  var DEFAULT_POPUP_WIDTH = 420;
3671
3663
  var DEFAULT_POPUP_HEIGHT = 560;
@@ -3691,8 +3683,8 @@ function CopilotPopupView({
3691
3683
  const setModalOpen = configuration?.setModalOpen;
3692
3684
  const labels = configuration?.labels ?? CopilotChatDefaultLabels;
3693
3685
  const containerRef = useRef9(null);
3694
- const [isRendered, setIsRendered] = useState13(isPopupOpen);
3695
- const [isAnimatingOut, setIsAnimatingOut] = useState13(false);
3686
+ const [isRendered, setIsRendered] = useState12(isPopupOpen);
3687
+ const [isAnimatingOut, setIsAnimatingOut] = useState12(false);
3696
3688
  useEffect16(() => {
3697
3689
  if (isPopupOpen) {
3698
3690
  setIsRendered(true);
@@ -3909,12 +3901,12 @@ function defineToolCallRenderer(def) {
3909
3901
  }
3910
3902
 
3911
3903
  // src/components/WildcardToolCallRender.tsx
3912
- import { useState as useState14 } from "react";
3904
+ import { useState as useState13 } from "react";
3913
3905
  import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
3914
3906
  var WildcardToolCallRender = defineToolCallRenderer({
3915
3907
  name: "*",
3916
3908
  render: ({ args, result, name, status }) => {
3917
- const [isExpanded, setIsExpanded] = useState14(false);
3909
+ const [isExpanded, setIsExpanded] = useState13(false);
3918
3910
  const statusString = String(status);
3919
3911
  const isActive = statusString === "inProgress" || statusString === "executing";
3920
3912
  const isComplete = statusString === "complete";