@copilotkit/react-core 1.56.4-canary.1777538870 → 1.56.5

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-tb4zqaMK.cjs');
4
+ const require_copilotkit = require('./copilotkit-DMFu29Kx.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.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { B as useConfigureSuggestions, Q as useRenderToolCall$1, U as useHumanInTheLoop$1, V as useSuggestions, Y as useRenderCustomMessages, Z as useAgent, a as ThreadsProvider, c as CoAgentStateRendersProvider, d as shouldShowDevConsole, et as useCopilotKit, f as useToast, g as useCopilotContext, h as CopilotContext, ht as useCopilotChatConfiguration, i as ThreadsContext, l as useCoAgentStateRenders, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, o as useThreads, p as CopilotMessagesContext, q as useFrontendTool$1, r as CoAgentStateRenderBridge, rt as defineToolCallRenderer, s as CoAgentStateRendersContext, t as CopilotKit, u as useAsyncCallback, z as useInterrupt } from "./copilotkit-Bd0m5HFp.mjs";
3
+ import { B as useConfigureSuggestions, Q as useRenderToolCall$1, U as useHumanInTheLoop$1, V as useSuggestions, Y as useRenderCustomMessages, Z as useAgent, a as ThreadsProvider, c as CoAgentStateRendersProvider, d as shouldShowDevConsole, et as useCopilotKit, f as useToast, g as useCopilotContext, h as CopilotContext, ht as useCopilotChatConfiguration, i as ThreadsContext, l as useCoAgentStateRenders, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, o as useThreads, p as CopilotMessagesContext, q as useFrontendTool$1, r as CoAgentStateRenderBridge, rt as defineToolCallRenderer, s as CoAgentStateRendersContext, t as CopilotKit, u as useAsyncCallback, z as useInterrupt } from "./copilotkit-OmIUrWym.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
@@ -2838,16 +2838,20 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
2838
2838
  return consumer;
2839
2839
  }, [normalizedConfig, resolvedConsumerAgentId]);
2840
2840
  const isGlobalConfig = rawConsumerAgentId === void 0 || rawConsumerAgentId === "*";
2841
+ const isDynamicConfigType = (0, react.useMemo)(() => !!normalizedConfig && "instructions" in normalizedConfig, [normalizedConfig]);
2841
2842
  const requestReload = (0, react.useCallback)(() => {
2842
2843
  if (!normalizedConfig) return;
2843
2844
  if (isGlobalConfig) {
2844
2845
  var _copilotkit$agents;
2846
+ const seen = /* @__PURE__ */ new Set();
2845
2847
  const agents = Object.values((_copilotkit$agents = copilotkit.agents) !== null && _copilotkit$agents !== void 0 ? _copilotkit$agents : {});
2846
2848
  for (const entry of agents) {
2847
2849
  const agentId = entry.agentId;
2848
2850
  if (!agentId) continue;
2851
+ seen.add(agentId);
2849
2852
  if (!entry.isRunning) copilotkit.reloadSuggestions(agentId);
2850
2853
  }
2854
+ if (targetAgentId && !seen.has(targetAgentId)) copilotkit.reloadSuggestions(targetAgentId);
2851
2855
  return;
2852
2856
  }
2853
2857
  if (!targetAgentId) return;
@@ -2892,6 +2896,26 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
2892
2896
  requestReload,
2893
2897
  ...extraDeps
2894
2898
  ]);
2899
+ (0, react.useEffect)(() => {
2900
+ if (!normalizedConfig || !isDynamicConfigType) return;
2901
+ if (!targetAgentId) return;
2902
+ if (!!copilotkit.getAgent(targetAgentId)) return;
2903
+ const subscription = copilotkit.subscribe({ onAgentsChanged: () => {
2904
+ if (copilotkit.getAgent(targetAgentId)) {
2905
+ requestReload();
2906
+ subscription.unsubscribe();
2907
+ }
2908
+ } });
2909
+ return () => {
2910
+ subscription.unsubscribe();
2911
+ };
2912
+ }, [
2913
+ copilotkit,
2914
+ normalizedConfig,
2915
+ isDynamicConfigType,
2916
+ targetAgentId,
2917
+ requestReload
2918
+ ]);
2895
2919
  }
2896
2920
  function isDynamicConfig(config) {
2897
2921
  return "instructions" in config;