@copilotkit/react-core 1.55.0-next.8 → 1.55.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +48 -5
  2. package/dist/{copilotkit-DNYSFuz5.mjs → copilotkit-BY5S1-0P.mjs} +2772 -858
  3. package/dist/copilotkit-BY5S1-0P.mjs.map +1 -0
  4. package/dist/{copilotkit-Dy5w3qEV.d.mts → copilotkit-BuhSUZHb.d.mts} +230 -17
  5. package/dist/copilotkit-BuhSUZHb.d.mts.map +1 -0
  6. package/dist/{copilotkit-B3Mb1yVE.cjs → copilotkit-Bz5-ImDl.cjs} +2776 -832
  7. package/dist/copilotkit-Bz5-ImDl.cjs.map +1 -0
  8. package/dist/{copilotkit-DBzgOMby.d.cts → copilotkit-dwDWYpya.d.cts} +230 -17
  9. package/dist/copilotkit-dwDWYpya.d.cts.map +1 -0
  10. package/dist/index.cjs +9 -4
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +1 -1
  13. package/dist/index.d.mts +1 -1
  14. package/dist/index.mjs +9 -4
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/index.umd.js +1624 -396
  17. package/dist/index.umd.js.map +1 -1
  18. package/dist/v2/index.cjs +13 -1
  19. package/dist/v2/index.css +1 -1
  20. package/dist/v2/index.d.cts +3 -3
  21. package/dist/v2/index.d.mts +3 -3
  22. package/dist/v2/index.mjs +3 -2
  23. package/dist/v2/index.umd.js +2746 -790
  24. package/dist/v2/index.umd.js.map +1 -1
  25. package/package.json +62 -54
  26. package/scripts/scope-preflight.mjs +1 -2
  27. package/src/components/CopilotListeners.tsx +41 -8
  28. package/src/components/copilot-provider/__tests__/copilot-messages-key.test.tsx +92 -0
  29. package/src/components/copilot-provider/copilotkit-props.tsx +4 -2
  30. package/src/components/copilot-provider/copilotkit.tsx +3 -3
  31. package/src/components/toast/toast-provider.tsx +269 -194
  32. package/src/hooks/__tests__/use-copilot-chat-internal-connect.test.tsx +27 -16
  33. package/src/hooks/use-copilot-chat_internal.ts +15 -4
  34. package/src/v2/__tests__/A2UIMessageRenderer.test.tsx +86 -22
  35. package/src/v2/__tests__/utils/test-helpers.tsx +107 -7
  36. package/src/v2/a2ui/A2UICatalogContext.tsx +79 -0
  37. package/src/v2/a2ui/A2UIMessageRenderer.tsx +125 -37
  38. package/src/v2/a2ui/A2UIToolCallRenderer.tsx +290 -0
  39. package/src/v2/components/CopilotKitInspector.tsx +2 -0
  40. package/src/v2/components/OpenGenerativeUIRenderer.tsx +598 -0
  41. package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.tsx +665 -0
  42. package/src/v2/components/chat/CopilotChat.tsx +197 -52
  43. package/src/v2/components/chat/CopilotChatAssistantMessage.tsx +17 -2
  44. package/src/v2/components/chat/CopilotChatAttachmentQueue.tsx +481 -0
  45. package/src/v2/components/chat/CopilotChatAttachmentRenderer.tsx +139 -0
  46. package/src/v2/components/chat/CopilotChatInput.tsx +146 -77
  47. package/src/v2/components/chat/CopilotChatMessageView.tsx +260 -151
  48. package/src/v2/components/chat/CopilotChatSuggestionView.tsx +1 -0
  49. package/src/v2/components/chat/CopilotChatUserMessage.tsx +54 -0
  50. package/src/v2/components/chat/CopilotChatView.tsx +179 -66
  51. package/src/v2/components/chat/__tests__/CopilotChat.attachments.test.tsx +168 -0
  52. package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.tsx +63 -2
  53. package/src/v2/components/chat/__tests__/CopilotChatInput.test.tsx +544 -1
  54. package/src/v2/components/chat/__tests__/CopilotChatPerf.e2e.test.tsx +268 -0
  55. package/src/v2/components/chat/__tests__/CopilotChatPropsRerender.e2e.test.tsx +249 -0
  56. package/src/v2/components/chat/__tests__/CopilotChatToolRendering.e2e.test.tsx +5 -2
  57. package/src/v2/components/chat/__tests__/CopilotChatToolRerenders.e2e.test.tsx +5 -2
  58. package/src/v2/components/chat/__tests__/MCPAppsActivityRenderer.e2e.test.tsx +60 -3
  59. package/src/v2/components/chat/__tests__/copilot-chat-throttle.test.tsx +138 -0
  60. package/src/v2/components/chat/index.ts +9 -0
  61. package/src/v2/components/chat/scroll-element-context.ts +13 -0
  62. package/src/v2/hooks/__tests__/use-agent-context-timing.e2e.test.tsx +8 -0
  63. package/src/v2/hooks/__tests__/use-agent-thread-isolation.test.tsx +327 -0
  64. package/src/v2/hooks/__tests__/use-agent-throttle.test.tsx +1003 -0
  65. package/src/v2/hooks/__tests__/use-agent.e2e.test.tsx +13 -2
  66. package/src/v2/hooks/__tests__/use-attachments.test.tsx +169 -0
  67. package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.tsx +23 -4
  68. package/src/v2/hooks/__tests__/use-threads.test.tsx +54 -0
  69. package/src/v2/hooks/index.ts +5 -0
  70. package/src/v2/hooks/use-agent.tsx +220 -15
  71. package/src/v2/hooks/use-attachments.tsx +269 -0
  72. package/src/v2/hooks/use-frontend-tool.tsx +5 -2
  73. package/src/v2/hooks/use-render-activity-message.tsx +9 -2
  74. package/src/v2/hooks/use-render-custom-messages.tsx +6 -1
  75. package/src/v2/hooks/use-threads.tsx +35 -15
  76. package/src/v2/index.ts +5 -1
  77. package/src/v2/lib/__tests__/processPartialHtml.test.ts +112 -0
  78. package/src/v2/lib/__tests__/slots.test.ts +56 -0
  79. package/src/v2/lib/processPartialHtml.ts +45 -0
  80. package/src/v2/lib/slots.tsx +42 -1
  81. package/src/v2/providers/CopilotChatConfigurationProvider.tsx +9 -3
  82. package/src/v2/providers/CopilotKitProvider.tsx +268 -32
  83. package/src/v2/providers/SandboxFunctionsContext.ts +10 -0
  84. package/src/v2/providers/__tests__/CopilotKitProvider.sandboxFunctions.test.tsx +198 -0
  85. package/src/v2/providers/__tests__/CopilotKitProvider.test.tsx +71 -0
  86. package/src/v2/providers/index.ts +7 -0
  87. package/src/v2/styles/globals.css +2 -1
  88. package/src/v2/types/index.ts +1 -0
  89. package/src/v2/types/sandbox-function.ts +11 -0
  90. package/dist/copilotkit-B3Mb1yVE.cjs.map +0 -1
  91. package/dist/copilotkit-DBzgOMby.d.cts.map +0 -1
  92. package/dist/copilotkit-DNYSFuz5.mjs.map +0 -1
  93. package/dist/copilotkit-Dy5w3qEV.d.mts.map +0 -1
  94. package/src/v2/components/__tests__/license-warning-banner.test.tsx +0 -46
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { $t as CrewsAgentState, Bt as CoagentInChatRenderFunction, Gt as CoAgentStateRender, Ht as CopilotContext, Jt as LangGraphInterruptActionSetterArgs, Kt as LangGraphInterruptAction, Qt as QueuedInterruptEvent, T as useAgent, U as useRenderToolCall$1, Ut as CopilotContextParams, Vt as CopilotApiConfig, Wt as useCopilotContext, Xt as LangGraphInterruptRenderHandlerProps, Yt as LangGraphInterruptRender, Zt as LangGraphInterruptRenderProps, _n as FrontendActionAvailability, an as CopilotChatSuggestionConfiguration, cn as Tree, dn as ActionRenderPropsNoArgs, en as CrewsResponse, fn as ActionRenderPropsNoArgsWait, gn as FrontendAction, hn as CatchAllFrontendAction, in as CrewsToolStateItem, ln as TreeNode, mn as CatchAllActionRenderProps, n as defaultCopilotContextCategories, nn as CrewsStateItem, on as SystemMessageFunction, pn as ActionRenderPropsWait, qt as LangGraphInterruptActionSetter, r as CopilotKitProps, rn as CrewsTaskStateItem, sn as DocumentPointer, t as CopilotKit, tn as CrewsResponseStatus, un as ActionRenderProps, vn as RenderFunctionStatus } from "./copilotkit-DBzgOMby.cjs";
1
+ import { $t as CoagentInChatRenderFunction, An as FrontendActionAvailability, Cn as ActionRenderProps, Dn as CatchAllActionRenderProps, En as ActionRenderPropsWait, M as useAgent, On as CatchAllFrontendAction, Sn as TreeNode, Tn as ActionRenderPropsNoArgsWait, Z as useRenderToolCall$1, _n as CrewsToolStateItem, an as LangGraphInterruptAction, bn as DocumentPointer, cn as LangGraphInterruptRender, dn as QueuedInterruptEvent, en as CopilotApiConfig, fn as CrewsAgentState, gn as CrewsTaskStateItem, hn as CrewsStateItem, in as CoAgentStateRender, jn as RenderFunctionStatus, kn as FrontendAction, ln as LangGraphInterruptRenderHandlerProps, mn as CrewsResponseStatus, n as defaultCopilotContextCategories, nn as CopilotContextParams, on as LangGraphInterruptActionSetter, pn as CrewsResponse, r as CopilotKitProps, rn as useCopilotContext, sn as LangGraphInterruptActionSetterArgs, t as CopilotKit, tn as CopilotContext, un as LangGraphInterruptRenderProps, vn as CopilotChatSuggestionConfiguration, wn as ActionRenderPropsNoArgs, xn as Tree, yn as SystemMessageFunction } from "./copilotkit-dwDWYpya.cjs";
2
2
  import "./v2/index.cjs";
3
3
  import * as react_jsx_runtime0 from "react/jsx-runtime";
4
4
  import { CopilotRuntimeClient, CopilotRuntimeClientOptions, ForwardedParametersInput, Message } from "@copilotkit/runtime-client-gql";
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { $t as CrewsAgentState, Bt as CoagentInChatRenderFunction, Gt as CoAgentStateRender, Ht as CopilotContext, Jt as LangGraphInterruptActionSetterArgs, Kt as LangGraphInterruptAction, Qt as QueuedInterruptEvent, T as useAgent, U as useRenderToolCall$1, Ut as CopilotContextParams, Vt as CopilotApiConfig, Wt as useCopilotContext, Xt as LangGraphInterruptRenderHandlerProps, Yt as LangGraphInterruptRender, Zt as LangGraphInterruptRenderProps, _n as FrontendActionAvailability, an as CopilotChatSuggestionConfiguration, cn as Tree, dn as ActionRenderPropsNoArgs, en as CrewsResponse, fn as ActionRenderPropsNoArgsWait, gn as FrontendAction, hn as CatchAllFrontendAction, in as CrewsToolStateItem, ln as TreeNode, mn as CatchAllActionRenderProps, n as defaultCopilotContextCategories, nn as CrewsStateItem, on as SystemMessageFunction, pn as ActionRenderPropsWait, qt as LangGraphInterruptActionSetter, r as CopilotKitProps, rn as CrewsTaskStateItem, sn as DocumentPointer, t as CopilotKit, tn as CrewsResponseStatus, un as ActionRenderProps, vn as RenderFunctionStatus } from "./copilotkit-Dy5w3qEV.mjs";
1
+ import { $t as CoagentInChatRenderFunction, An as FrontendActionAvailability, Cn as ActionRenderProps, Dn as CatchAllActionRenderProps, En as ActionRenderPropsWait, M as useAgent, On as CatchAllFrontendAction, Sn as TreeNode, Tn as ActionRenderPropsNoArgsWait, Z as useRenderToolCall$1, _n as CrewsToolStateItem, an as LangGraphInterruptAction, bn as DocumentPointer, cn as LangGraphInterruptRender, dn as QueuedInterruptEvent, en as CopilotApiConfig, fn as CrewsAgentState, gn as CrewsTaskStateItem, hn as CrewsStateItem, in as CoAgentStateRender, jn as RenderFunctionStatus, kn as FrontendAction, ln as LangGraphInterruptRenderHandlerProps, mn as CrewsResponseStatus, n as defaultCopilotContextCategories, nn as CopilotContextParams, on as LangGraphInterruptActionSetter, pn as CrewsResponse, r as CopilotKitProps, rn as useCopilotContext, sn as LangGraphInterruptActionSetterArgs, t as CopilotKit, tn as CopilotContext, un as LangGraphInterruptRenderProps, vn as CopilotChatSuggestionConfiguration, wn as ActionRenderPropsNoArgs, xn as Tree, yn as SystemMessageFunction } from "./copilotkit-BuhSUZHb.mjs";
2
2
  import "./v2/index.mjs";
3
3
  import React, { ReactNode, RefObject, SetStateAction } from "react";
4
4
  import { StaticSuggestionsConfig, Suggestion } from "@copilotkit/core";
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { G as defineToolCallRenderer, H as useHumanInTheLoop$1, I as useInterrupt, L as useConfigureSuggestions, Q as useCopilotKit, R as useSuggestions, V as useAgent, X as useRenderToolCall$1, Y as useRenderCustomMessages, a as ThreadsProvider, c as CoAgentStateRendersProvider, d as shouldShowDevConsole, f as useToast, g as useCopilotContext, h as CopilotContext, i as ThreadsContext, l as useCoAgentStateRenders, lt as useCopilotChatConfiguration, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, o as useThreads, p as CopilotMessagesContext, q as useFrontendTool$1, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, t as CopilotKit, u as useAsyncCallback } from "./copilotkit-DNYSFuz5.mjs";
3
+ import { $ as useCopilotKit, B as useConfigureSuggestions, H as useHumanInTheLoop$1, J as useRenderCustomMessages, K as useFrontendTool$1, V as useSuggestions, X as useAgent, Z as useRenderToolCall$1, a as ThreadsProvider, c as CoAgentStateRendersProvider, d as shouldShowDevConsole, f as useToast, g as useCopilotContext, h as CopilotContext, i as ThreadsContext, l as useCoAgentStateRenders, m as useCopilotMessagesContext, mt as useCopilotChatConfiguration, n as defaultCopilotContextCategories, nt as defineToolCallRenderer, o as useThreads, p as CopilotMessagesContext, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, t as CopilotKit, u as useAsyncCallback, z as useInterrupt } from "./copilotkit-BY5S1-0P.mjs";
4
4
  import React, { Fragment, createElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
5
5
  import { CopilotKitCoreRuntimeConnectionStatus, ToolCallStatus } from "@copilotkit/core";
6
6
  import { AGUIConnectNotImplementedError, HttpAgent } from "@ag-ui/client";
@@ -40,7 +40,11 @@ function useCopilotChatInternal({ suggestions, onInProgress, onSubmitMessage, on
40
40
  const existingConfig = useCopilotChatConfiguration();
41
41
  const [agentAvailable, setAgentAvailable] = useState(false);
42
42
  const resolvedAgentId = existingConfig?.agentId ?? "default";
43
- const { agent } = useAgent({ agentId: resolvedAgentId });
43
+ const { agent } = useAgent({
44
+ agentId: resolvedAgentId,
45
+ threadId: existingConfig?.threadId
46
+ });
47
+ const lastConnectedAgentRef = useRef(null);
44
48
  useEffect(() => {
45
49
  let detached = false;
46
50
  const connectAbortController = new AbortController();
@@ -55,11 +59,12 @@ function useCopilotChatInternal({ suggestions, onInProgress, onSubmitMessage, on
55
59
  if (error instanceof AGUIConnectNotImplementedError) {} else console.error("CopilotChat: connectAgent failed", error);
56
60
  }
57
61
  };
58
- if (agent && existingConfig?.threadId && agent.threadId !== existingConfig.threadId && copilotkit.runtimeConnectionStatus === CopilotKitCoreRuntimeConnectionStatus.Connected) {
59
- agent.threadId = existingConfig.threadId;
62
+ if (agent && agent !== lastConnectedAgentRef.current && copilotkit.runtimeConnectionStatus === CopilotKitCoreRuntimeConnectionStatus.Connected) {
63
+ lastConnectedAgentRef.current = agent;
60
64
  connect(agent);
61
65
  }
62
66
  return () => {
67
+ lastConnectedAgentRef.current = null;
63
68
  detached = true;
64
69
  connectAbortController.abort();
65
70
  agent?.detachActiveRun();