@copilotkit/react-core 1.64.2-canary.1785346263 → 1.64.2-canary.parallel1

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.
@@ -14,7 +14,7 @@ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
14
14
  import { Streamdown } from "streamdown";
15
15
  import { z } from "zod";
16
16
  import { createComponent } from "@lit-labs/react";
17
- import { A2UIProvider, A2UIRenderer, A2UI_SCHEMA_CONTEXT_DESCRIPTION, DEFAULT_SURFACE_ID, buildCatalogContextValue, extractCatalogComponentSchemas, initializeDefaultCatalog, injectStyles, useA2UIActions, useA2UIError, viewerTheme } from "@copilotkit/a2ui-renderer";
17
+ import { A2UIProvider, A2UIRenderer, A2UI_SCHEMA_CONTEXT_DESCRIPTION, Catalog, DEFAULT_SURFACE_ID, buildCatalogContextValue, extractCatalogComponentSchemas, filterCatalog, initializeDefaultCatalog, injectStyles, useA2UIActions, useA2UIError, viewerTheme } from "@copilotkit/a2ui-renderer";
18
18
  import { zodToJsonSchema } from "zod-to-json-schema";
19
19
  import { createPortal, flushSync } from "react-dom";
20
20
  import { useVirtualizer } from "@tanstack/react-virtual";
@@ -3494,6 +3494,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3494
3494
  const [shouldRenderInspector, setShouldRenderInspector] = useState(false);
3495
3495
  const [runtimeA2UIEnabled, setRuntimeA2UIEnabled] = useState(false);
3496
3496
  const [runtimeOpenGenUIEnabled, setRuntimeOpenGenUIEnabled] = useState(false);
3497
+ const [catalogToggleVersion, setCatalogToggleVersion] = useState(0);
3497
3498
  const openGenUIActive = runtimeOpenGenUIEnabled || !!openGenerativeUI;
3498
3499
  const a2uiCatalogProvided = !!a2ui?.catalog;
3499
3500
  const a2uiActive = runtimeA2UIEnabled || a2uiCatalogProvided;
@@ -3516,6 +3517,14 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3516
3517
  });
3517
3518
  const renderCustomMessagesList = useStableArrayProp(renderCustomMessages, "renderCustomMessages must be a stable array.");
3518
3519
  const renderActivityMessagesList = useStableArrayProp(renderActivityMessages, "renderActivityMessages must be a stable array.");
3520
+ const copilotkitRef = useRef(null);
3521
+ const rawCatalog = a2ui?.catalog;
3522
+ const filteredCatalog = useMemo(() => {
3523
+ if (!rawCatalog) return rawCatalog;
3524
+ if (!(rawCatalog instanceof Catalog)) return rawCatalog;
3525
+ const core = copilotkitRef.current;
3526
+ return filterCatalog(rawCatalog, (name) => core ? core.isCatalogComponentEnabled(name) : true);
3527
+ }, [rawCatalog, catalogToggleVersion]);
3519
3528
  const builtInActivityRenderers = useMemo(() => {
3520
3529
  const renderers = [{
3521
3530
  activityType: MCPAppsActivityType,
@@ -3529,7 +3538,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3529
3538
  });
3530
3539
  if (a2uiActive) renderers.unshift(createA2UIMessageRenderer({
3531
3540
  theme: a2ui?.theme ?? viewerTheme,
3532
- catalog: a2ui?.catalog,
3541
+ catalog: filteredCatalog,
3533
3542
  loadingComponent: a2ui?.loadingComponent,
3534
3543
  recovery: a2ui?.recovery
3535
3544
  }));
@@ -3537,7 +3546,8 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3537
3546
  }, [
3538
3547
  a2uiActive,
3539
3548
  openGenUIActive,
3540
- a2ui
3549
+ a2ui,
3550
+ filteredCatalog
3541
3551
  ]);
3542
3552
  const allActivityRenderers = useMemo(() => {
3543
3553
  return [...renderActivityMessagesList, ...builtInActivityRenderers];
@@ -3642,7 +3652,6 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3642
3652
  builtInFrontendTools,
3643
3653
  processedHumanInTheLoopTools
3644
3654
  ]);
3645
- const copilotkitRef = useRef(null);
3646
3655
  if (copilotkitRef.current === null) {
3647
3656
  copilotkitRef.current = new CopilotKitCoreReact({
3648
3657
  runtimeUrl: chatApiEndpoint,
@@ -3661,6 +3670,20 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3661
3670
  if (defaultThrottleMs !== void 0) copilotkitRef.current.setDefaultThrottleMs(defaultThrottleMs);
3662
3671
  }
3663
3672
  const copilotkit = copilotkitRef.current;
3673
+ useEffect(() => {
3674
+ if (!rawCatalog) return;
3675
+ if (!(rawCatalog instanceof Catalog)) return;
3676
+ const components = Array.from(rawCatalog.components.values()).map((comp) => ({
3677
+ name: comp.name,
3678
+ description: void 0,
3679
+ schema: comp.schema
3680
+ }));
3681
+ copilotkit.setCatalogComponents(components);
3682
+ const subscription = copilotkit.subscribe({ onCatalogComponentsChanged: () => {
3683
+ setCatalogToggleVersion((v) => v + 1);
3684
+ } });
3685
+ return () => subscription.unsubscribe();
3686
+ }, [copilotkit, rawCatalog]);
3664
3687
  useEffect(() => {
3665
3688
  const syncRuntimeInfo = () => {
3666
3689
  setRuntimeA2UIEnabled(copilotkit.a2uiEnabled);
@@ -3816,7 +3839,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3816
3839
  children: [
3817
3840
  a2uiActive && /* @__PURE__ */ jsx(A2UIBuiltInToolCallRenderer, {}),
3818
3841
  a2uiActive && /* @__PURE__ */ jsx(A2UICatalogContext, {
3819
- catalog: a2ui?.catalog,
3842
+ catalog: filteredCatalog,
3820
3843
  includeSchema: a2ui?.includeSchema
3821
3844
  }),
3822
3845
  children,
@@ -11699,4 +11722,4 @@ function validateProps(props) {
11699
11722
 
11700
11723
  //#endregion
11701
11724
  export { useCapabilities as $, CopilotChatMessageView as A, CopilotChatConfigurationProvider as At, CopilotChatAssistantMessage_default as B, CopilotModalHeader as C, CopilotKitInspector as Ct, CopilotChat as D, CopilotChatInput_default as Dt, DefaultOpenIcon as E, CopilotKitCoreReact as Et, CopilotChatSuggestionView as F, useLearnFromUserActionInCurrentThread as G, useLearningContainersInCurrentThread as H, CopilotChatSuggestionPill as I, useThreads$1 as J, useLearnFromUserAction as K, CopilotChatReasoningMessage_default as L, IntelligenceIndicator as M, getIntelligenceTurnAnchors as N, CopilotChatView_default as O, AudioRecorderError as Ot, IntelligenceIndicatorView as P, useAgentContext as Q, CopilotChatUserMessage_default as R, CopilotSidebarView as S, ɵrunMcpFollowUp as St, DefaultCloseIcon as T, useCopilotKit as Tt, useLearningContainers as U, CopilotChatToolCallsView as V, useAttachments as W, useConfigureSuggestions as X, useInterrupt as Y, useSuggestions as Z, WildcardToolCallRender as _, SandboxFunctionsContext as _t, ThreadsProvider as a, useComponent as at, CopilotSidebar as b, MCPAppsActivityRenderer as bt, CoAgentStateRendersProvider as c, useRenderCustomMessages as ct, shouldShowDevConsole as d, createA2UIMessageRenderer as dt, UseAgentUpdate as et, useToast as f, GenerateSandboxedUiArgsSchema as ft, useCopilotContext as g, OpenGenerativeUIToolRenderer as gt, CopilotContext as h, OpenGenerativeUIContentSchema as ht, ThreadsContext as i, useRenderTool as it, INTELLIGENCE_TURN_HEAD as j, useCopilotChatConfiguration as jt, CopilotChatAttachmentQueue as k, CopilotChatAudioRecorder as kt, useCoAgentStateRenders as l, CopilotKitProvider as lt, useCopilotMessagesContext as m, OpenGenerativeUIActivityType as mt, defaultCopilotContextCategories as n, useHumanInTheLoop as nt, useThreads as o, useFrontendTool as ot, CopilotMessagesContext as p, OpenGenerativeUIActivityRenderer as pt, useMemories as q, CoAgentStateRenderBridge as r, useDefaultRenderTool as rt, CoAgentStateRendersContext as s, useRenderActivityMessage as st, CopilotKit as t, useAgent as tt, useAsyncCallback as u, defineToolCallRenderer as ut, CopilotThreadsDrawer as v, useSandboxFunctions as vt, CopilotChatToggleButton as w, useRenderToolCall as wt, CopilotPopupView as x, MCPAppsActivityType as xt, CopilotPopup as y, MCPAppsActivityContentSchema as yt, CopilotChatAttachmentRenderer as z };
11702
- //# sourceMappingURL=copilotkit-BrZGzZw6.mjs.map
11725
+ //# sourceMappingURL=copilotkit-DnlgZWST.mjs.map