@copilotkit/react-core 1.62.2 → 1.62.3

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-lHheGQWt.cjs');
4
+ const require_copilotkit = require('./copilotkit-5MptLWNR.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 { $n as ActionRenderPropsNoArgs, An as CopilotContext, Bn as QueuedInterruptEvent, Fn as LangGraphInterruptActionSetter, Gn as CrewsTaskStateItem, H as useAgent, Hn as CrewsResponse, In as LangGraphInterruptActionSetterArgs, Jn as SystemMessageFunction, Kn as CrewsToolStateItem, Ln as LangGraphInterruptRender, Mn as useCopilotContext, Nn as CoAgentStateRender, On as CoagentInChatRenderFunction, Pn as LangGraphInterruptAction, Qn as ActionRenderProps, Rn as LangGraphInterruptRenderHandlerProps, Un as CrewsResponseStatus, Vn as CrewsAgentState, Wn as CrewsStateItem, Xn as Tree, Yn as DocumentPointer, Zn as TreeNode, ar as FrontendActionAvailability, dt as useRenderToolCall$1, er as ActionRenderPropsNoArgsWait, ir as FrontendAction, jn as CopilotContextParams, kn as CopilotApiConfig, n as defaultCopilotContextCategories, nr as CatchAllActionRenderProps, or as RenderFunctionStatus, qn as CopilotChatSuggestionConfiguration, r as CopilotKitProps, rr as CatchAllFrontendAction, t as CopilotKit, tr as ActionRenderPropsWait, zn as LangGraphInterruptRenderProps } from "./copilotkit-Cga6AHO0.cjs";
1
+ import { $n as CrewsToolStateItem, Bn as CoAgentStateRender, Fn as CoagentInChatRenderFunction, Gn as LangGraphInterruptRenderHandlerProps, Hn as LangGraphInterruptActionSetter, In as CopilotApiConfig, Jn as CrewsAgentState, Kn as LangGraphInterruptRenderProps, Ln as CopilotContext, Qn as CrewsTaskStateItem, Rn as CopilotContextParams, Un as LangGraphInterruptActionSetterArgs, Vn as LangGraphInterruptAction, Wn as LangGraphInterruptRender, Xn as CrewsResponseStatus, Y as useAgent, Yn as CrewsResponse, Zn as CrewsStateItem, ar as ActionRenderProps, cr as ActionRenderPropsWait, dr as FrontendAction, er as CopilotChatSuggestionConfiguration, fr as FrontendActionAvailability, ir as TreeNode, lr as CatchAllActionRenderProps, n as defaultCopilotContextCategories, nr as DocumentPointer, or as ActionRenderPropsNoArgs, pr as RenderFunctionStatus, qn as QueuedInterruptEvent, r as CopilotKitProps, rr as Tree, sr as ActionRenderPropsNoArgsWait, t as CopilotKit, tr as SystemMessageFunction, ur as CatchAllFrontendAction, vt as useRenderToolCall$1, zn as useCopilotContext } from "./copilotkit-BfFY1fzd.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 { $n as ActionRenderPropsNoArgs, An as CopilotContext, Bn as QueuedInterruptEvent, Fn as LangGraphInterruptActionSetter, Gn as CrewsTaskStateItem, H as useAgent, Hn as CrewsResponse, In as LangGraphInterruptActionSetterArgs, Jn as SystemMessageFunction, Kn as CrewsToolStateItem, Ln as LangGraphInterruptRender, Mn as useCopilotContext, Nn as CoAgentStateRender, On as CoagentInChatRenderFunction, Pn as LangGraphInterruptAction, Qn as ActionRenderProps, Rn as LangGraphInterruptRenderHandlerProps, Un as CrewsResponseStatus, Vn as CrewsAgentState, Wn as CrewsStateItem, Xn as Tree, Yn as DocumentPointer, Zn as TreeNode, ar as FrontendActionAvailability, dt as useRenderToolCall$1, er as ActionRenderPropsNoArgsWait, ir as FrontendAction, jn as CopilotContextParams, kn as CopilotApiConfig, n as defaultCopilotContextCategories, nr as CatchAllActionRenderProps, or as RenderFunctionStatus, qn as CopilotChatSuggestionConfiguration, r as CopilotKitProps, rr as CatchAllFrontendAction, t as CopilotKit, tr as ActionRenderPropsWait, zn as LangGraphInterruptRenderProps } from "./copilotkit-DnLpJ2Cl.mjs";
1
+ import { $n as CrewsToolStateItem, Bn as CoAgentStateRender, Fn as CoagentInChatRenderFunction, Gn as LangGraphInterruptRenderHandlerProps, Hn as LangGraphInterruptActionSetter, In as CopilotApiConfig, Jn as CrewsAgentState, Kn as LangGraphInterruptRenderProps, Ln as CopilotContext, Qn as CrewsTaskStateItem, Rn as CopilotContextParams, Un as LangGraphInterruptActionSetterArgs, Vn as LangGraphInterruptAction, Wn as LangGraphInterruptRender, Xn as CrewsResponseStatus, Y as useAgent, Yn as CrewsResponse, Zn as CrewsStateItem, ar as ActionRenderProps, cr as ActionRenderPropsWait, dr as FrontendAction, er as CopilotChatSuggestionConfiguration, fr as FrontendActionAvailability, ir as TreeNode, lr as CatchAllActionRenderProps, n as defaultCopilotContextCategories, nr as DocumentPointer, or as ActionRenderPropsNoArgs, pr as RenderFunctionStatus, qn as QueuedInterruptEvent, r as CopilotKitProps, rr as Tree, sr as ActionRenderPropsNoArgsWait, t as CopilotKit, tr as SystemMessageFunction, ur as CatchAllFrontendAction, vt as useRenderToolCall$1, zn as useCopilotContext } from "./copilotkit-Bp6BD8xe.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 { J as useInterrupt, X as useSuggestions, Y as useConfigureSuggestions, _t as useRenderToolCall$1, a as ThreadsProvider, at as useFrontendTool$1, c as CoAgentStateRendersProvider, d as shouldShowDevConsole, et as useAgent, f as useToast, g as useCopilotContext, h as CopilotContext, i as ThreadsContext, l as useCoAgentStateRenders, lt as defineToolCallRenderer, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, o as useThreads, p as CopilotMessagesContext, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, st as useRenderCustomMessages, t as CopilotKit, tt as useHumanInTheLoop$1, u as useAsyncCallback, vt as useCopilotKit, wt as useCopilotChatConfiguration } from "./copilotkit-CmcMFc8o.mjs";
3
+ import { Tt as useCopilotChatConfiguration, X as useConfigureSuggestions, Y as useInterrupt, Z as useSuggestions, a as ThreadsProvider, c as CoAgentStateRendersProvider, ct as useRenderCustomMessages, d as shouldShowDevConsole, f as useToast, g as useCopilotContext, h as CopilotContext, i as ThreadsContext, l as useCoAgentStateRenders, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, nt as useHumanInTheLoop$1, o as useThreads, ot as useFrontendTool$1, p as CopilotMessagesContext, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, t as CopilotKit, tt as useAgent, u as useAsyncCallback, ut as defineToolCallRenderer, vt as useRenderToolCall$1, yt as useCopilotKit } from "./copilotkit-ympAovXs.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
@@ -2849,57 +2849,58 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
2849
2849
  UseAgentUpdate.OnRunStatusChanged
2850
2850
  ];
2851
2851
  function useAgent({ agentId, updates, throttleMs } = {}) {
2852
- agentId ?? (agentId = _copilotkit_shared.DEFAULT_AGENT_ID);
2852
+ const chatConfig = useCopilotChatConfiguration();
2853
+ const resolvedAgentId = agentId ?? chatConfig?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
2853
2854
  const { copilotkit } = useCopilotKit();
2854
2855
  const providerThrottleMs = copilotkit.defaultThrottleMs;
2855
2856
  const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
2856
2857
  const updateFlags = (0, react.useMemo)(() => updates ?? ALL_UPDATES, [JSON.stringify(updates)]);
2857
2858
  const provisionalAgentCache = (0, react.useRef)(/* @__PURE__ */ new Map());
2858
2859
  const agent = (0, react.useMemo)(() => {
2859
- const existing = copilotkit.getAgent(agentId);
2860
+ const existing = copilotkit.getAgent(resolvedAgentId);
2860
2861
  if (existing) {
2861
- provisionalAgentCache.current.delete(agentId);
2862
+ provisionalAgentCache.current.delete(resolvedAgentId);
2862
2863
  return existing;
2863
2864
  }
2864
2865
  const isRuntimeConfigured = copilotkit.runtimeUrl !== void 0;
2865
2866
  const status = copilotkit.runtimeConnectionStatus;
2866
2867
  if (isRuntimeConfigured && (status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Disconnected || status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Connecting)) {
2867
- const cached = provisionalAgentCache.current.get(agentId);
2868
+ const cached = provisionalAgentCache.current.get(resolvedAgentId);
2868
2869
  if (cached) {
2869
2870
  copilotkit.applyHeadersToAgent(cached);
2870
2871
  return cached;
2871
2872
  }
2872
2873
  const provisional = new _copilotkit_core.ProxiedCopilotRuntimeAgent({
2873
2874
  runtimeUrl: copilotkit.runtimeUrl,
2874
- agentId,
2875
+ agentId: resolvedAgentId,
2875
2876
  transport: copilotkit.runtimeTransport,
2876
2877
  runtimeMode: "pending"
2877
2878
  });
2878
2879
  copilotkit.applyHeadersToAgent(provisional);
2879
- provisionalAgentCache.current.set(agentId, provisional);
2880
+ provisionalAgentCache.current.set(resolvedAgentId, provisional);
2880
2881
  return provisional;
2881
2882
  }
2882
2883
  if (isRuntimeConfigured && status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Error) {
2883
- const cached = provisionalAgentCache.current.get(agentId);
2884
+ const cached = provisionalAgentCache.current.get(resolvedAgentId);
2884
2885
  if (cached) {
2885
2886
  copilotkit.applyHeadersToAgent(cached);
2886
2887
  return cached;
2887
2888
  }
2888
2889
  const provisional = new _copilotkit_core.ProxiedCopilotRuntimeAgent({
2889
2890
  runtimeUrl: copilotkit.runtimeUrl,
2890
- agentId,
2891
+ agentId: resolvedAgentId,
2891
2892
  transport: copilotkit.runtimeTransport,
2892
2893
  runtimeMode: "pending"
2893
2894
  });
2894
2895
  copilotkit.applyHeadersToAgent(provisional);
2895
- provisionalAgentCache.current.set(agentId, provisional);
2896
+ provisionalAgentCache.current.set(resolvedAgentId, provisional);
2896
2897
  return provisional;
2897
2898
  }
2898
2899
  const knownAgents = Object.keys(copilotkit.agents ?? {});
2899
2900
  const runtimePart = isRuntimeConfigured ? `runtimeUrl=${copilotkit.runtimeUrl}` : "no runtimeUrl";
2900
- throw new Error(`useAgent: Agent '${agentId}' not found after runtime sync (${runtimePart}). ` + (knownAgents.length ? `Known agents: [${knownAgents.join(", ")}]` : "No agents registered.") + " Verify your runtime /info and/or agents__unsafe_dev_only.");
2901
+ throw new Error(`useAgent: Agent '${resolvedAgentId}' not found after runtime sync (${runtimePart}). ` + (knownAgents.length ? `Known agents: [${knownAgents.join(", ")}]` : "No agents registered.") + " Verify your runtime /info and/or agents__unsafe_dev_only.");
2901
2902
  }, [
2902
- agentId,
2903
+ resolvedAgentId,
2903
2904
  copilotkit.agents,
2904
2905
  copilotkit.runtimeConnectionStatus,
2905
2906
  copilotkit.runtimeUrl,
@@ -2944,7 +2945,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
2944
2945
  (0, react.useEffect)(() => {
2945
2946
  if (agent instanceof _ag_ui_client.HttpAgent) copilotkit.applyHeadersToAgent(agent);
2946
2947
  }, [agent, JSON.stringify(copilotkit.headers)]);
2947
- const chatConfig = useCopilotChatConfiguration();
2948
2948
  const configThreadId = chatConfig?.threadId;
2949
2949
  const configHasExplicitThreadId = chatConfig?.hasExplicitThreadId;
2950
2950
  (0, react.useEffect)(() => {
@@ -5031,8 +5031,18 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
5031
5031
  }, [agent, getSubscriber]);
5032
5032
  };
5033
5033
  function CopilotListenersAgentSubscription() {
5034
- const resolvedAgentId = useCopilotChatConfiguration()?.agentId;
5035
- const { agent } = useAgent({ agentId: resolvedAgentId });
5034
+ const { copilotkit } = useCopilotKit();
5035
+ const configAgentId = useCopilotChatConfiguration()?.agentId;
5036
+ const { agent } = useAgent({ agentId: (0, react.useMemo)(() => {
5037
+ const requested = configAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
5038
+ const registered = copilotkit.agents ?? {};
5039
+ if (registered[requested]) return requested;
5040
+ if (requested === _copilotkit_shared.DEFAULT_AGENT_ID) {
5041
+ const firstRegistered = Object.keys(registered)[0];
5042
+ if (firstRegistered) return firstRegistered;
5043
+ }
5044
+ return requested;
5045
+ }, [configAgentId, copilotkit.agents]) });
5036
5046
  usePredictStateSubscription(agent);
5037
5047
  return null;
5038
5048
  }