@copilotkit/react-core 1.60.2 → 1.61.1

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.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_copilotkit = require('./copilotkit-CP5uyB2h.cjs');
4
+ const require_copilotkit = require('./copilotkit-BCJDP8qd.cjs');
5
5
  let react = require("react");
6
6
  react = require_copilotkit.__toESM(react);
7
7
  let _copilotkit_core = require("@copilotkit/core");
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { An as LangGraphInterruptRenderHandlerProps, Bn as SystemMessageFunction, Cn as CopilotContextParams, Dn as LangGraphInterruptActionSetter, En as LangGraphInterruptAction, Fn as CrewsResponseStatus, G as useAgent, Gn as ActionRenderPropsNoArgs, Hn as Tree, In as CrewsStateItem, Jn as CatchAllActionRenderProps, Kn as ActionRenderPropsNoArgsWait, Ln as CrewsTaskStateItem, Mn as QueuedInterruptEvent, Nn as CrewsAgentState, On as LangGraphInterruptActionSetterArgs, Pn as CrewsResponse, Qn as RenderFunctionStatus, Rn as CrewsToolStateItem, Sn as CopilotContext, Tn as CoAgentStateRender, Un as TreeNode, Vn as DocumentPointer, Wn as ActionRenderProps, Xn as FrontendAction, Yn as CatchAllFrontendAction, Zn as FrontendActionAvailability, bn as CoagentInChatRenderFunction, jn as LangGraphInterruptRenderProps, kn as LangGraphInterruptRender, n as defaultCopilotContextCategories, qn as ActionRenderPropsWait, r as CopilotKitProps, t as CopilotKit, ut as useRenderToolCall$1, wn as useCopilotContext, xn as CopilotApiConfig, zn as CopilotChatSuggestionConfiguration } from "./copilotkit-CyL6ZsLP.cjs";
1
+ import { An as LangGraphInterruptRenderHandlerProps, Bn as SystemMessageFunction, Cn as CopilotContextParams, Dn as LangGraphInterruptActionSetter, En as LangGraphInterruptAction, Fn as CrewsResponseStatus, G as useAgent, Gn as ActionRenderPropsNoArgs, Hn as Tree, In as CrewsStateItem, Jn as CatchAllActionRenderProps, Kn as ActionRenderPropsNoArgsWait, Ln as CrewsTaskStateItem, Mn as QueuedInterruptEvent, Nn as CrewsAgentState, On as LangGraphInterruptActionSetterArgs, Pn as CrewsResponse, Qn as RenderFunctionStatus, Rn as CrewsToolStateItem, Sn as CopilotContext, Tn as CoAgentStateRender, Un as TreeNode, Vn as DocumentPointer, Wn as ActionRenderProps, Xn as FrontendAction, Yn as CatchAllFrontendAction, Zn as FrontendActionAvailability, bn as CoagentInChatRenderFunction, jn as LangGraphInterruptRenderProps, kn as LangGraphInterruptRender, n as defaultCopilotContextCategories, qn as ActionRenderPropsWait, r as CopilotKitProps, t as CopilotKit, ut as useRenderToolCall$1, wn as useCopilotContext, xn as CopilotApiConfig, zn as CopilotChatSuggestionConfiguration } from "./copilotkit-CEdu_aie.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 { An as LangGraphInterruptRenderHandlerProps, Bn as SystemMessageFunction, Cn as CopilotContextParams, Dn as LangGraphInterruptActionSetter, En as LangGraphInterruptAction, Fn as CrewsResponseStatus, G as useAgent, Gn as ActionRenderPropsNoArgs, Hn as Tree, In as CrewsStateItem, Jn as CatchAllActionRenderProps, Kn as ActionRenderPropsNoArgsWait, Ln as CrewsTaskStateItem, Mn as QueuedInterruptEvent, Nn as CrewsAgentState, On as LangGraphInterruptActionSetterArgs, Pn as CrewsResponse, Qn as RenderFunctionStatus, Rn as CrewsToolStateItem, Sn as CopilotContext, Tn as CoAgentStateRender, Un as TreeNode, Vn as DocumentPointer, Wn as ActionRenderProps, Xn as FrontendAction, Yn as CatchAllFrontendAction, Zn as FrontendActionAvailability, bn as CoagentInChatRenderFunction, jn as LangGraphInterruptRenderProps, kn as LangGraphInterruptRender, n as defaultCopilotContextCategories, qn as ActionRenderPropsWait, r as CopilotKitProps, t as CopilotKit, ut as useRenderToolCall$1, wn as useCopilotContext, xn as CopilotApiConfig, zn as CopilotChatSuggestionConfiguration } from "./copilotkit-UaQ7KSUq.mjs";
1
+ import { An as LangGraphInterruptRenderHandlerProps, Bn as SystemMessageFunction, Cn as CopilotContextParams, Dn as LangGraphInterruptActionSetter, En as LangGraphInterruptAction, Fn as CrewsResponseStatus, G as useAgent, Gn as ActionRenderPropsNoArgs, Hn as Tree, In as CrewsStateItem, Jn as CatchAllActionRenderProps, Kn as ActionRenderPropsNoArgsWait, Ln as CrewsTaskStateItem, Mn as QueuedInterruptEvent, Nn as CrewsAgentState, On as LangGraphInterruptActionSetterArgs, Pn as CrewsResponse, Qn as RenderFunctionStatus, Rn as CrewsToolStateItem, Sn as CopilotContext, Tn as CoAgentStateRender, Un as TreeNode, Vn as DocumentPointer, Wn as ActionRenderProps, Xn as FrontendAction, Yn as CatchAllFrontendAction, Zn as FrontendActionAvailability, bn as CoagentInChatRenderFunction, jn as LangGraphInterruptRenderProps, kn as LangGraphInterruptRender, n as defaultCopilotContextCategories, qn as ActionRenderPropsWait, r as CopilotKitProps, t as CopilotKit, ut as useRenderToolCall$1, wn as useCopilotContext, xn as CopilotApiConfig, zn as CopilotChatSuggestionConfiguration } from "./copilotkit-M1FiciGd.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 { $ as useAgent, Ct as useCopilotChatConfiguration, J as useConfigureSuggestions, Y as useSuggestions, _t as useCopilotKit, a as ThreadsProvider, c as CoAgentStateRendersProvider, d as shouldShowDevConsole, et as useHumanInTheLoop$1, f as useToast, g as useCopilotContext, gt as defineToolCallRenderer, h as CopilotContext, i as ThreadsContext, it as useRenderCustomMessages, l as useCoAgentStateRenders, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, nt as useFrontendTool$1, o as useThreads, p as CopilotMessagesContext, pt as useRenderToolCall$1, q as useInterrupt, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, t as CopilotKit, u as useAsyncCallback } from "./copilotkit-DheptEiV.mjs";
3
+ import { $ as useAgent, Ct as useCopilotChatConfiguration, J as useConfigureSuggestions, Y as useSuggestions, _t as useCopilotKit, a as ThreadsProvider, c as CoAgentStateRendersProvider, d as shouldShowDevConsole, et as useHumanInTheLoop$1, f as useToast, g as useCopilotContext, gt as defineToolCallRenderer, h as CopilotContext, i as ThreadsContext, it as useRenderCustomMessages, l as useCoAgentStateRenders, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, nt as useFrontendTool$1, o as useThreads, p as CopilotMessagesContext, pt as useRenderToolCall$1, q as useInterrupt, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, t as CopilotKit, u as useAsyncCallback } from "./copilotkit-UY-H6Kx7.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";
package/dist/index.umd.js CHANGED
@@ -2361,6 +2361,10 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
2361
2361
  ...selfManagedAgents
2362
2362
  }), [agents, selfManagedAgents]);
2363
2363
  const hasLocalAgents = mergedAgents && Object.keys(mergedAgents).length > 0;
2364
+ const hasSelfManagedAgents = Object.keys(selfManagedAgents).length > 0;
2365
+ (0, react.useEffect)(() => {
2366
+ if (hasSelfManagedAgents && !resolvedPublicKey) console.warn("[CopilotKit] `selfManagedAgents` is part of CopilotKit's Enterprise Intelligence offering. Provide a `publicLicenseKey` for production use — contact the CopilotKit team about licensing.");
2367
+ }, [hasSelfManagedAgents, resolvedPublicKey]);
2364
2368
  const headers = typeof headersProp === "function" ? headersProp() : headersProp;
2365
2369
  const mergedHeaders = (0, react.useMemo)(() => {
2366
2370
  if (!resolvedPublicKey) return headers;
@@ -2719,49 +2723,72 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
2719
2723
  function useHumanInTheLoop$1(tool, deps) {
2720
2724
  const { copilotkit } = useCopilotKit();
2721
2725
  const resolvePromiseRef = (0, react.useRef)(null);
2726
+ const cleanupAbortRef = (0, react.useRef)(null);
2722
2727
  const respond = (0, react.useCallback)(async (result) => {
2723
2728
  if (resolvePromiseRef.current) {
2729
+ cleanupAbortRef.current?.();
2730
+ cleanupAbortRef.current = null;
2724
2731
  resolvePromiseRef.current(result);
2725
2732
  resolvePromiseRef.current = null;
2726
2733
  }
2727
2734
  }, []);
2728
- const handler = (0, react.useCallback)(async () => {
2729
- return new Promise((resolve) => {
2735
+ const handler = (0, react.useCallback)(async (_args, context) => {
2736
+ const signal = context?.signal;
2737
+ return new Promise((resolve, reject) => {
2738
+ if (signal?.aborted) {
2739
+ reject(/* @__PURE__ */ new Error("Human-in-the-loop interaction aborted"));
2740
+ return;
2741
+ }
2730
2742
  resolvePromiseRef.current = resolve;
2743
+ if (signal) {
2744
+ const onAbort = () => {
2745
+ cleanupAbortRef.current = null;
2746
+ resolvePromiseRef.current = null;
2747
+ reject(/* @__PURE__ */ new Error("Human-in-the-loop interaction aborted"));
2748
+ };
2749
+ signal.addEventListener("abort", onAbort, { once: true });
2750
+ cleanupAbortRef.current = () => {
2751
+ signal.removeEventListener("abort", onAbort);
2752
+ };
2753
+ }
2731
2754
  });
2732
2755
  }, []);
2733
2756
  const RenderComponent = (0, react.useCallback)((props) => {
2734
2757
  const ToolComponent = tool.render;
2735
- if (props.status === "inProgress") {
2758
+ if (props.status === _copilotkit_core.ToolCallStatus.InProgress) {
2736
2759
  const enhancedProps = {
2737
2760
  ...props,
2738
2761
  name: tool.name,
2739
2762
  description: tool.description || "",
2763
+ agentId: tool.agentId,
2740
2764
  respond: void 0
2741
2765
  };
2742
2766
  return react.default.createElement(ToolComponent, enhancedProps);
2743
- } else if (props.status === "executing") {
2767
+ } else if (props.status === _copilotkit_core.ToolCallStatus.Executing) {
2744
2768
  const enhancedProps = {
2745
2769
  ...props,
2746
2770
  name: tool.name,
2747
2771
  description: tool.description || "",
2772
+ agentId: tool.agentId,
2748
2773
  respond
2749
2774
  };
2750
2775
  return react.default.createElement(ToolComponent, enhancedProps);
2751
- } else if (props.status === "complete") {
2776
+ } else if (props.status === _copilotkit_core.ToolCallStatus.Complete) {
2752
2777
  const enhancedProps = {
2753
2778
  ...props,
2754
2779
  name: tool.name,
2755
2780
  description: tool.description || "",
2781
+ agentId: tool.agentId,
2756
2782
  respond: void 0
2757
2783
  };
2758
2784
  return react.default.createElement(ToolComponent, enhancedProps);
2759
2785
  }
2760
- return react.default.createElement(ToolComponent, props);
2786
+ return props;
2761
2787
  }, [
2762
2788
  tool.render,
2763
2789
  tool.name,
2764
2790
  tool.description,
2791
+ tool.agentId,
2765
2792
  respond
2766
2793
  ]);
2767
2794
  useFrontendTool$1({
@@ -4950,21 +4977,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
4950
4977
 
4951
4978
  //#endregion
4952
4979
  //#region src/components/copilot-provider/copilotkit.tsx
4953
- /**
4954
- * This component will typically wrap your entire application (or a sub-tree of your application where you want to have a copilot). It provides the copilot context to all other components and hooks.
4955
- *
4956
- * ## Example
4957
- *
4958
- * You can find more information about self-hosting CopilotKit [here](/guides/self-hosting).
4959
- *
4960
- * ```tsx
4961
- * import { CopilotKit } from "@copilotkit/react-core";
4962
- *
4963
- * <CopilotKit runtimeUrl="<your-runtime-url>">
4964
- * // ... your app ...
4965
- * </CopilotKit>
4966
- * ```
4967
- */
4968
4980
  function CopilotKit({ children, ...props }) {
4969
4981
  const enabled = shouldShowDevConsole(props.showDevConsole);
4970
4982
  const showInspector = shouldShowDevConsole(props.enableInspector);
@@ -5453,7 +5465,11 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
5453
5465
  function validateProps(props) {
5454
5466
  const cloudFeatures = Object.keys(props).filter((key) => key.endsWith("_c"));
5455
5467
  const hasApiKey = props.publicApiKey || props.publicLicenseKey;
5456
- if (!props.runtimeUrl && !hasApiKey) throw new _copilotkit_shared.ConfigurationError("Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'");
5468
+ const hasLocalAgents = Object.keys({
5469
+ ...props.agents__unsafe_dev_only,
5470
+ ...props.selfManagedAgents
5471
+ }).length > 0;
5472
+ if (!props.runtimeUrl && !hasApiKey && !hasLocalAgents) throw new _copilotkit_shared.ConfigurationError("Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'");
5457
5473
  if (cloudFeatures.length > 0 && !hasApiKey) throw new _copilotkit_shared.MissingPublicApiKeyError(`Missing required prop: 'publicApiKey' or 'publicLicenseKey' to use cloud features: ${cloudFeatures.map(formatFeatureName).join(", ")}`);
5458
5474
  }
5459
5475