@copilotkit/react-core 1.62.1 → 1.62.2-canary.1784333495

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-CdpDZi3i.cjs');
4
+ const require_copilotkit = require('./copilotkit-DLwoVUsE.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 CrewsResponseStatus, Bn as CopilotContext, Gn as LangGraphInterruptActionSetter, Hn as useCopilotContext, Jn as LangGraphInterruptRenderHandlerProps, Kn as LangGraphInterruptActionSetterArgs, Q as useAgent, Qn as CrewsResponse, Rn as CoagentInChatRenderFunction, Un as CoAgentStateRender, Vn as CopilotContextParams, Wn as LangGraphInterruptAction, Xn as QueuedInterruptEvent, Yn as LangGraphInterruptRenderProps, Zn as CrewsAgentState, ar as DocumentPointer, cr as ActionRenderProps, dr as ActionRenderPropsWait, er as CrewsStateItem, fr as CatchAllActionRenderProps, gr as RenderFunctionStatus, hr as FrontendActionAvailability, ir as SystemMessageFunction, lr as ActionRenderPropsNoArgs, mr as FrontendAction, n as defaultCopilotContextCategories, nr as CrewsToolStateItem, or as Tree, pr as CatchAllFrontendAction, qn as LangGraphInterruptRender, r as CopilotKitProps, rr as CopilotChatSuggestionConfiguration, sr as TreeNode, t as CopilotKit, tr as CrewsTaskStateItem, ur as ActionRenderPropsNoArgsWait, xt as useRenderToolCall$1, zn as CopilotApiConfig } from "./copilotkit-C-k8T6fY.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 CrewsResponseStatus, Bn as CopilotContext, Gn as LangGraphInterruptActionSetter, Hn as useCopilotContext, Jn as LangGraphInterruptRenderHandlerProps, Kn as LangGraphInterruptActionSetterArgs, Q as useAgent, Qn as CrewsResponse, Rn as CoagentInChatRenderFunction, Un as CoAgentStateRender, Vn as CopilotContextParams, Wn as LangGraphInterruptAction, Xn as QueuedInterruptEvent, Yn as LangGraphInterruptRenderProps, Zn as CrewsAgentState, ar as DocumentPointer, cr as ActionRenderProps, dr as ActionRenderPropsWait, er as CrewsStateItem, fr as CatchAllActionRenderProps, gr as RenderFunctionStatus, hr as FrontendActionAvailability, ir as SystemMessageFunction, lr as ActionRenderPropsNoArgs, mr as FrontendAction, n as defaultCopilotContextCategories, nr as CrewsToolStateItem, or as Tree, pr as CatchAllFrontendAction, qn as LangGraphInterruptRender, r as CopilotKitProps, rr as CopilotChatSuggestionConfiguration, sr as TreeNode, t as CopilotKit, tr as CrewsTaskStateItem, ur as ActionRenderPropsNoArgsWait, xt as useRenderToolCall$1, zn as CopilotApiConfig } from "./copilotkit-D6Wy_7iY.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-BtRkFsNR.mjs";
3
+ import { Et as useCopilotChatConfiguration, X as useConfigureSuggestions, Y as useInterrupt, Z as useSuggestions, a as ThreadsProvider, bt as useCopilotKit, c as CoAgentStateRendersProvider, d as shouldShowDevConsole, dt as defineToolCallRenderer, f as useToast, g as useCopilotContext, h as CopilotContext, i as ThreadsContext, l as useCoAgentStateRenders, lt as useRenderCustomMessages, 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, st as useFrontendTool$1, t as CopilotKit, u as useAsyncCallback, yt as useRenderToolCall$1 } from "./copilotkit-dtSVHJCs.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
@@ -2497,12 +2497,13 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
2497
2497
  }
2498
2498
  const copilotkit = copilotkitRef.current;
2499
2499
  (0, react.useEffect)(() => {
2500
- setRuntimeA2UIEnabled(copilotkit.a2uiEnabled);
2501
- const subscription = copilotkit.subscribe({ onRuntimeConnectionStatusChanged: () => {
2500
+ const syncRuntimeInfo = () => {
2502
2501
  setRuntimeA2UIEnabled(copilotkit.a2uiEnabled);
2503
2502
  setRuntimeOpenGenUIEnabled(copilotkit.openGenerativeUIEnabled);
2504
2503
  setRuntimeLicenseStatus(copilotkit.licenseStatus);
2505
- } });
2504
+ };
2505
+ const subscription = copilotkit.subscribe({ onRuntimeConnectionStatusChanged: syncRuntimeInfo });
2506
+ syncRuntimeInfo();
2506
2507
  return () => {
2507
2508
  subscription.unsubscribe();
2508
2509
  };
@@ -2848,57 +2849,58 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
2848
2849
  UseAgentUpdate.OnRunStatusChanged
2849
2850
  ];
2850
2851
  function useAgent({ agentId, updates, throttleMs } = {}) {
2851
- agentId ?? (agentId = _copilotkit_shared.DEFAULT_AGENT_ID);
2852
+ const chatConfig = useCopilotChatConfiguration();
2853
+ const resolvedAgentId = agentId ?? chatConfig?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
2852
2854
  const { copilotkit } = useCopilotKit();
2853
2855
  const providerThrottleMs = copilotkit.defaultThrottleMs;
2854
2856
  const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
2855
2857
  const updateFlags = (0, react.useMemo)(() => updates ?? ALL_UPDATES, [JSON.stringify(updates)]);
2856
2858
  const provisionalAgentCache = (0, react.useRef)(/* @__PURE__ */ new Map());
2857
2859
  const agent = (0, react.useMemo)(() => {
2858
- const existing = copilotkit.getAgent(agentId);
2860
+ const existing = copilotkit.getAgent(resolvedAgentId);
2859
2861
  if (existing) {
2860
- provisionalAgentCache.current.delete(agentId);
2862
+ provisionalAgentCache.current.delete(resolvedAgentId);
2861
2863
  return existing;
2862
2864
  }
2863
2865
  const isRuntimeConfigured = copilotkit.runtimeUrl !== void 0;
2864
2866
  const status = copilotkit.runtimeConnectionStatus;
2865
2867
  if (isRuntimeConfigured && (status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Disconnected || status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Connecting)) {
2866
- const cached = provisionalAgentCache.current.get(agentId);
2868
+ const cached = provisionalAgentCache.current.get(resolvedAgentId);
2867
2869
  if (cached) {
2868
2870
  copilotkit.applyHeadersToAgent(cached);
2869
2871
  return cached;
2870
2872
  }
2871
2873
  const provisional = new _copilotkit_core.ProxiedCopilotRuntimeAgent({
2872
2874
  runtimeUrl: copilotkit.runtimeUrl,
2873
- agentId,
2875
+ agentId: resolvedAgentId,
2874
2876
  transport: copilotkit.runtimeTransport,
2875
2877
  runtimeMode: "pending"
2876
2878
  });
2877
2879
  copilotkit.applyHeadersToAgent(provisional);
2878
- provisionalAgentCache.current.set(agentId, provisional);
2880
+ provisionalAgentCache.current.set(resolvedAgentId, provisional);
2879
2881
  return provisional;
2880
2882
  }
2881
2883
  if (isRuntimeConfigured && status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Error) {
2882
- const cached = provisionalAgentCache.current.get(agentId);
2884
+ const cached = provisionalAgentCache.current.get(resolvedAgentId);
2883
2885
  if (cached) {
2884
2886
  copilotkit.applyHeadersToAgent(cached);
2885
2887
  return cached;
2886
2888
  }
2887
2889
  const provisional = new _copilotkit_core.ProxiedCopilotRuntimeAgent({
2888
2890
  runtimeUrl: copilotkit.runtimeUrl,
2889
- agentId,
2891
+ agentId: resolvedAgentId,
2890
2892
  transport: copilotkit.runtimeTransport,
2891
2893
  runtimeMode: "pending"
2892
2894
  });
2893
2895
  copilotkit.applyHeadersToAgent(provisional);
2894
- provisionalAgentCache.current.set(agentId, provisional);
2896
+ provisionalAgentCache.current.set(resolvedAgentId, provisional);
2895
2897
  return provisional;
2896
2898
  }
2897
2899
  const knownAgents = Object.keys(copilotkit.agents ?? {});
2898
2900
  const runtimePart = isRuntimeConfigured ? `runtimeUrl=${copilotkit.runtimeUrl}` : "no runtimeUrl";
2899
- 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.");
2900
2902
  }, [
2901
- agentId,
2903
+ resolvedAgentId,
2902
2904
  copilotkit.agents,
2903
2905
  copilotkit.runtimeConnectionStatus,
2904
2906
  copilotkit.runtimeUrl,
@@ -2943,7 +2945,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
2943
2945
  (0, react.useEffect)(() => {
2944
2946
  if (agent instanceof _ag_ui_client.HttpAgent) copilotkit.applyHeadersToAgent(agent);
2945
2947
  }, [agent, JSON.stringify(copilotkit.headers)]);
2946
- const chatConfig = useCopilotChatConfiguration();
2947
2948
  const configThreadId = chatConfig?.threadId;
2948
2949
  const configHasExplicitThreadId = chatConfig?.hasExplicitThreadId;
2949
2950
  (0, react.useEffect)(() => {
@@ -5030,8 +5031,18 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
5030
5031
  }, [agent, getSubscriber]);
5031
5032
  };
5032
5033
  function CopilotListenersAgentSubscription() {
5033
- const resolvedAgentId = useCopilotChatConfiguration()?.agentId;
5034
- 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]) });
5035
5046
  usePredictStateSubscription(agent);
5036
5047
  return null;
5037
5048
  }