@copilotkit/react-core 1.76.0 → 1.77.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 (38) hide show
  1. package/dist/{copilotkit-dHdNF7H5.cjs → copilotkit-CFPkj9B9.cjs} +89 -24
  2. package/dist/copilotkit-CFPkj9B9.cjs.map +1 -0
  3. package/dist/{copilotkit-LD7Gp2aV.mjs → copilotkit-CP9qPAqV.mjs} +89 -24
  4. package/dist/copilotkit-CP9qPAqV.mjs.map +1 -0
  5. package/dist/{copilotkit-B90cY0Zg.d.mts → copilotkit-Cqa0TfEo.d.mts} +28 -3
  6. package/dist/copilotkit-Cqa0TfEo.d.mts.map +1 -0
  7. package/dist/{copilotkit-W-bV_OSs.d.cts → copilotkit-DGc2YiW9.d.cts} +33 -3
  8. package/dist/copilotkit-DGc2YiW9.d.cts.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.d.cts +1 -1
  11. package/dist/index.d.mts +1 -1
  12. package/dist/index.mjs +1 -1
  13. package/dist/index.umd.js +70 -16
  14. package/dist/index.umd.js.map +1 -1
  15. package/dist/v2/context.cjs.map +1 -1
  16. package/dist/v2/context.d.cts +5 -0
  17. package/dist/v2/context.d.cts.map +1 -1
  18. package/dist/v2/context.d.mts +5 -0
  19. package/dist/v2/context.d.mts.map +1 -1
  20. package/dist/v2/context.mjs.map +1 -1
  21. package/dist/v2/headless.cjs +19 -0
  22. package/dist/v2/headless.cjs.map +1 -1
  23. package/dist/v2/headless.d.cts +5 -0
  24. package/dist/v2/headless.d.cts.map +1 -1
  25. package/dist/v2/headless.d.mts.map +1 -1
  26. package/dist/v2/headless.mjs +20 -1
  27. package/dist/v2/headless.mjs.map +1 -1
  28. package/dist/v2/index.cjs +1 -1
  29. package/dist/v2/index.d.cts +2 -2
  30. package/dist/v2/index.d.mts +2 -2
  31. package/dist/v2/index.mjs +1 -1
  32. package/dist/v2/index.umd.js +88 -23
  33. package/dist/v2/index.umd.js.map +1 -1
  34. package/package.json +8 -8
  35. package/dist/copilotkit-B90cY0Zg.d.mts.map +0 -1
  36. package/dist/copilotkit-LD7Gp2aV.mjs.map +0 -1
  37. package/dist/copilotkit-W-bV_OSs.d.cts.map +0 -1
  38. package/dist/copilotkit-dHdNF7H5.cjs.map +0 -1
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { $d as CopilotContextParams, Cf as ActionRenderPropsWait, Df as FrontendAction, Ef as CatchAllFrontendAction, Of as FrontendActionAvailability, Qd as CopilotContext, Sf as ActionRenderPropsNoArgsWait, Tf as CatchAllActionRenderPropsWait, X as useAgent, Xd as CoagentInChatRenderFunction, Zd as CopilotApiConfig, _f as DocumentPointer, af as LangGraphInterruptRender, bf as ActionRenderProps, cf as QueuedInterruptEvent, df as CrewsResponseStatus, ef as useCopilotContext, ff as CrewsStateItem, gf as SystemMessageFunction, hf as CopilotChatSuggestionConfiguration, if as LangGraphInterruptActionSetterArgs, kf as RenderFunctionStatus, lf as CrewsAgentState, mf as CrewsToolStateItem, n as defaultCopilotContextCategories, nf as LangGraphInterruptAction, of as LangGraphInterruptRenderHandlerProps, pf as CrewsTaskStateItem, r as CopilotKitProps, rf as LangGraphInterruptActionSetter, sf as LangGraphInterruptRenderProps, t as CopilotKit, tf as CoAgentStateRender, uf as CrewsResponse, vf as Tree, wf as CatchAllActionRenderProps, xf as ActionRenderPropsNoArgs, xt as useRenderToolCall$1, yf as TreeNode } from "./copilotkit-B90cY0Zg.mjs";
1
+ import { Af as CatchAllActionRenderProps, Cf as DocumentPointer, Df as ActionRenderPropsNoArgs, Ef as ActionRenderProps, Ff as RenderFunctionStatus, Mf as CatchAllFrontendAction, Nf as FrontendAction, Of as ActionRenderPropsNoArgsWait, Pf as FrontendActionAvailability, Sf as SystemMessageFunction, Tf as TreeNode, X as useAgent, _f as CrewsResponseStatus, af as CopilotContextParams, bf as CrewsToolStateItem, cf as LangGraphInterruptAction, df as LangGraphInterruptRender, ff as LangGraphInterruptRenderHandlerProps, gf as CrewsResponse, hf as CrewsAgentState, if as CopilotContext, jf as CatchAllActionRenderPropsWait, kf as ActionRenderPropsWait, lf as LangGraphInterruptActionSetter, mf as QueuedInterruptEvent, n as defaultCopilotContextCategories, nf as CoagentInChatRenderFunction, of as useCopilotContext, pf as LangGraphInterruptRenderProps, r as CopilotKitProps, rf as CopilotApiConfig, sf as CoAgentStateRender, t as CopilotKit, uf as LangGraphInterruptActionSetterArgs, vf as CrewsStateItem, wf as Tree, xf as CopilotChatSuggestionConfiguration, xt as useRenderToolCall$1, yf as CrewsTaskStateItem } from "./copilotkit-Cqa0TfEo.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 { Pt as useCopilotChatConfiguration, Q as useSuggestions, X as INTERRUPT_EVENT_NAME, Y as useInterrupt, Z as useConfigureSuggestions, a as ThreadsProvider, c as CoAgentStateRendersProvider, ct as useFrontendTool$1, d as shouldShowDevConsole, f as useToast, ft as useCopilotKit, g as useCopilotContext, h as CopilotContext, ht as defineToolCallRenderer, i as ThreadsContext, kt as useRenderToolCall$1, l as useCoAgentStateRenders, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, nt as useAgent, o as useThreads, p as CopilotMessagesContext, r as CoAgentStateRenderBridge, rt as useHumanInTheLoop$1, s as CoAgentStateRendersContext, t as CopilotKit, u as useAsyncCallback, ut as useRenderCustomMessages } from "./copilotkit-LD7Gp2aV.mjs";
3
+ import { Pt as useCopilotChatConfiguration, Q as useSuggestions, X as INTERRUPT_EVENT_NAME, Y as useInterrupt, Z as useConfigureSuggestions, a as ThreadsProvider, c as CoAgentStateRendersProvider, ct as useFrontendTool$1, d as shouldShowDevConsole, f as useToast, ft as useCopilotKit, g as useCopilotContext, h as CopilotContext, ht as defineToolCallRenderer, i as ThreadsContext, kt as useRenderToolCall$1, l as useCoAgentStateRenders, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, nt as useAgent, o as useThreads, p as CopilotMessagesContext, r as CoAgentStateRenderBridge, rt as useHumanInTheLoop$1, s as CoAgentStateRendersContext, t as CopilotKit, u as useAsyncCallback, ut as useRenderCustomMessages } from "./copilotkit-CP9qPAqV.mjs";
4
4
  import React, { Fragment, createElement, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
5
5
  import { CopilotKitCoreRuntimeConnectionStatus, ToolCallStatus, ɵisHttpAgent } from "@copilotkit/core";
6
6
  import { AGUIConnectNotImplementedError } from "@ag-ui/client";
package/dist/index.umd.js CHANGED
@@ -280,6 +280,25 @@ react_markdown = __toESM(react_markdown);
280
280
  parentConfig?.threadId,
281
281
  activeThreadOverride
282
282
  ]);
283
+ const copilotkit = (0, react.useContext)(CopilotKitContext)?.copilotkit;
284
+ const openThreadRef = (0, react.useRef)(null);
285
+ const latestThreadIdRef = (0, react.useRef)(resolvedThreadId);
286
+ latestThreadIdRef.current = resolvedThreadId;
287
+ (0, react.useEffect)(() => {
288
+ if (copilotkit === void 0) return;
289
+ const registration = copilotkit.registerOpenThread({
290
+ agentId: resolvedAgentId,
291
+ threadId: latestThreadIdRef.current
292
+ });
293
+ openThreadRef.current = registration;
294
+ return () => {
295
+ registration.unregister();
296
+ openThreadRef.current = null;
297
+ };
298
+ }, [copilotkit, resolvedAgentId]);
299
+ (0, react.useEffect)(() => {
300
+ openThreadRef.current?.update(resolvedThreadId);
301
+ }, [resolvedThreadId]);
283
302
  const resolvedHasExplicitThreadId = (threadIdPropIsAuthoritative ? true : activeThreadOverride?.explicit ?? hasExplicitThreadId ?? false) || !!parentConfig?.hasExplicitThreadId;
284
303
  const [internalModalOpen, setInternalModalOpen] = (0, react.useState)(isModalDefaultOpen ?? true);
285
304
  const hasExplicitDefault = isModalDefaultOpen !== void 0;
@@ -583,7 +602,7 @@ react_markdown = __toESM(react_markdown);
583
602
 
584
603
  //#endregion
585
604
  //#region package.json
586
- var version = "1.76.0";
605
+ var version = "1.77.0";
587
606
 
588
607
  //#endregion
589
608
  //#region src/v2/components/CopilotKitInspector.tsx
@@ -787,12 +806,14 @@ react_markdown = __toESM(react_markdown);
787
806
  * Fetches resource content on-demand via proxied MCP requests. The React shell
788
807
  * owns the iframe; `bindMcpApp` owns the protocol.
789
808
  */
790
- const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agent }) {
809
+ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, message, agent }) {
791
810
  const { copilotkit } = useCopilotKit();
811
+ const messageId = message?.id;
792
812
  const containerRef = (0, react.useRef)(null);
793
813
  const iframeRef = (0, react.useRef)(null);
794
814
  const sessionRef = (0, react.useRef)(null);
795
815
  const [error, setError] = (0, react.useState)(null);
816
+ const [contentError, setContentError] = (0, react.useState)(null);
796
817
  const [isLoading, setIsLoading] = (0, react.useState)(true);
797
818
  const [iframeSize, setIframeSize] = (0, react.useState)({});
798
819
  const [fetchedResource, setFetchedResource] = (0, react.useState)(null);
@@ -811,6 +832,7 @@ react_markdown = __toESM(react_markdown);
811
832
  let mounted = true;
812
833
  setIsLoading(true);
813
834
  setError(null);
835
+ setContentError(null);
814
836
  const iframe = document.createElement("iframe");
815
837
  iframe.style.width = "100%";
816
838
  iframe.style.height = "100px";
@@ -833,6 +855,7 @@ react_markdown = __toESM(react_markdown);
833
855
  getContent: () => contentRef.current,
834
856
  getAgent: () => agentRef.current,
835
857
  host: copilotkit,
858
+ messageId,
836
859
  hooks: {
837
860
  onResource: (resource) => {
838
861
  if (!mounted) return;
@@ -842,6 +865,9 @@ react_markdown = __toESM(react_markdown);
842
865
  onSizeChanged: (size) => {
843
866
  if (mounted) setIframeSize(size);
844
867
  },
868
+ onContentError: (err) => {
869
+ if (mounted) setContentError(err);
870
+ },
845
871
  onError: (err) => {
846
872
  if (!mounted) return;
847
873
  setError(err);
@@ -850,9 +876,7 @@ react_markdown = __toESM(react_markdown);
850
876
  }
851
877
  });
852
878
  sessionRef.current = session;
853
- const current = contentRef.current;
854
- if (current.toolInput) session.sendToolInput(current.toolInput);
855
- if (current.result) session.sendToolResult(current.result);
879
+ session.syncContent(contentRef.current);
856
880
  } catch (err) {
857
881
  console.error("[MCPAppsRenderer] Setup error:", err);
858
882
  if (mounted) {
@@ -872,6 +896,7 @@ react_markdown = __toESM(react_markdown);
872
896
  }, [
873
897
  agent,
874
898
  copilotkit,
899
+ messageId,
875
900
  content.resourceUri,
876
901
  content.serverHash,
877
902
  content.serverId
@@ -886,11 +911,8 @@ react_markdown = __toESM(react_markdown);
886
911
  }
887
912
  }, [iframeSize]);
888
913
  (0, react.useEffect)(() => {
889
- if (content.toolInput) sessionRef.current?.sendToolInput(content.toolInput);
890
- }, [content.toolInput]);
891
- (0, react.useEffect)(() => {
892
- if (content.result) sessionRef.current?.sendToolResult(content.result);
893
- }, [content.result]);
914
+ sessionRef.current?.syncContent(contentRef.current);
915
+ }, [content.toolInput, content.result]);
894
916
  const borderStyle = fetchedResource?._meta?.ui?.prefersBorder === true ? {
895
917
  borderRadius: "8px",
896
918
  backgroundColor: "#f9f9f9",
@@ -912,12 +934,12 @@ react_markdown = __toESM(react_markdown);
912
934
  color: "#666"
913
935
  },
914
936
  children: "Loading..."
915
- }), error && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
937
+ }), (error ?? contentError) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
916
938
  style: {
917
939
  color: "red",
918
940
  padding: "1rem"
919
941
  },
920
- children: ["Error: ", error.message]
942
+ children: ["Error: ", (error ?? contentError).message]
921
943
  })]
922
944
  });
923
945
  };
@@ -2219,7 +2241,7 @@ react_markdown = __toESM(react_markdown);
2219
2241
  }, [value, warningMessage]);
2220
2242
  return value;
2221
2243
  }
2222
- const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, messageFilter, publicApiKey, publicLicenseKey, licenseToken, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, enableInspector, agentId, useSingleEndpoint, onError, a2ui, defaultThrottleMs, debug }) => {
2244
+ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, messageFilter, publicApiKey, publicLicenseKey, licenseToken, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, enableInspector, agentId, showIntelligenceIndicator = true, useSingleEndpoint, onError, a2ui, defaultThrottleMs, debug, learning }) => {
2223
2245
  const [shouldRenderInspector, setShouldRenderInspector] = (0, react.useState)(false);
2224
2246
  const [inspectorVisible, setInspectorVisible] = (0, react.useState)(false);
2225
2247
  (0, react.useEffect)(() => {
@@ -2454,7 +2476,8 @@ react_markdown = __toESM(react_markdown);
2454
2476
  renderToolCalls: allRenderToolCalls,
2455
2477
  renderActivityMessages: allActivityRenderers,
2456
2478
  renderCustomMessages: renderCustomMessagesList,
2457
- debug
2479
+ debug,
2480
+ learning
2458
2481
  });
2459
2482
  if (defaultThrottleMs !== void 0) copilotkitRef.current.setDefaultThrottleMs(defaultThrottleMs);
2460
2483
  }
@@ -2559,6 +2582,32 @@ react_markdown = __toESM(react_markdown);
2559
2582
  useSingleEndpoint,
2560
2583
  debug
2561
2584
  ]);
2585
+ const learningEnabled = learning !== void 0;
2586
+ const trajectoryId = learning?.trajectoryId;
2587
+ const learningContainerIdsRef = (0, react.useRef)(learning?.learningContainerIds);
2588
+ (0, react.useEffect)(() => {
2589
+ copilotkit.setLearningConfig(learning);
2590
+ learningContainerIdsRef.current = learning?.learningContainerIds;
2591
+ if (learning?.sink === void 0 && learning?.trajectoryId === void 0 && learning?.learningContainerIds !== void 0) console.warn("[CopilotKit] learningContainerIds is supported only with a custom sink. Authenticated Trajectory capture does not assign Learning Containers; remove learningContainerIds from the capture options.");
2592
+ }, [copilotkit, learning]);
2593
+ (0, react.useEffect)(() => {
2594
+ if (!learningEnabled) return;
2595
+ let disposed = false;
2596
+ if (trajectoryId !== void 0) copilotkit.startTrajectory({
2597
+ trajectoryId,
2598
+ learningContainerIds: learningContainerIdsRef.current
2599
+ }).catch(() => {
2600
+ if (!disposed) console.warn("[CopilotKit] Failed to start interaction capture.");
2601
+ });
2602
+ return () => {
2603
+ disposed = true;
2604
+ copilotkit.stopTrajectory();
2605
+ };
2606
+ }, [
2607
+ copilotkit,
2608
+ learningEnabled,
2609
+ trajectoryId
2610
+ ]);
2562
2611
  const didMountRef = (0, react.useRef)(false);
2563
2612
  (0, react.useEffect)(() => {
2564
2613
  if (!didMountRef.current) return;
@@ -2621,8 +2670,13 @@ react_markdown = __toESM(react_markdown);
2621
2670
  ]);
2622
2671
  const contextValue = (0, react.useMemo)(() => ({
2623
2672
  copilotkit,
2624
- executingToolCallIds
2625
- }), [copilotkit, executingToolCallIds]);
2673
+ executingToolCallIds,
2674
+ showIntelligenceIndicator
2675
+ }), [
2676
+ copilotkit,
2677
+ executingToolCallIds,
2678
+ showIntelligenceIndicator
2679
+ ]);
2626
2680
  const retryableRuntimeEntitlementFailure = runtimeEntitlements?.status !== "ready" && runtimeEntitlements?.error.retryable === true;
2627
2681
  const hasNonReadyRuntimeEntitlement = runtimeEntitlements !== void 0 && runtimeEntitlements.status !== "ready";
2628
2682
  const hasLegacyRuntimeEntitlementFallback = runtimeLicenseStatus === "valid" || runtimeLicenseStatus === "expiring";