@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.
@@ -3524,6 +3524,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3524
3524
  const [shouldRenderInspector, setShouldRenderInspector] = (0, react.useState)(false);
3525
3525
  const [runtimeA2UIEnabled, setRuntimeA2UIEnabled] = (0, react.useState)(false);
3526
3526
  const [runtimeOpenGenUIEnabled, setRuntimeOpenGenUIEnabled] = (0, react.useState)(false);
3527
+ const [catalogToggleVersion, setCatalogToggleVersion] = (0, react.useState)(0);
3527
3528
  const openGenUIActive = runtimeOpenGenUIEnabled || !!openGenerativeUI;
3528
3529
  const a2uiCatalogProvided = !!a2ui?.catalog;
3529
3530
  const a2uiActive = runtimeA2UIEnabled || a2uiCatalogProvided;
@@ -3546,6 +3547,14 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3546
3547
  });
3547
3548
  const renderCustomMessagesList = useStableArrayProp(renderCustomMessages, "renderCustomMessages must be a stable array.");
3548
3549
  const renderActivityMessagesList = useStableArrayProp(renderActivityMessages, "renderActivityMessages must be a stable array.");
3550
+ const copilotkitRef = (0, react.useRef)(null);
3551
+ const rawCatalog = a2ui?.catalog;
3552
+ const filteredCatalog = (0, react.useMemo)(() => {
3553
+ if (!rawCatalog) return rawCatalog;
3554
+ if (!(rawCatalog instanceof _copilotkit_a2ui_renderer.Catalog)) return rawCatalog;
3555
+ const core = copilotkitRef.current;
3556
+ return (0, _copilotkit_a2ui_renderer.filterCatalog)(rawCatalog, (name) => core ? core.isCatalogComponentEnabled(name) : true);
3557
+ }, [rawCatalog, catalogToggleVersion]);
3549
3558
  const builtInActivityRenderers = (0, react.useMemo)(() => {
3550
3559
  const renderers = [{
3551
3560
  activityType: MCPAppsActivityType,
@@ -3559,7 +3568,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3559
3568
  });
3560
3569
  if (a2uiActive) renderers.unshift(createA2UIMessageRenderer({
3561
3570
  theme: a2ui?.theme ?? _copilotkit_a2ui_renderer.viewerTheme,
3562
- catalog: a2ui?.catalog,
3571
+ catalog: filteredCatalog,
3563
3572
  loadingComponent: a2ui?.loadingComponent,
3564
3573
  recovery: a2ui?.recovery
3565
3574
  }));
@@ -3567,7 +3576,8 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3567
3576
  }, [
3568
3577
  a2uiActive,
3569
3578
  openGenUIActive,
3570
- a2ui
3579
+ a2ui,
3580
+ filteredCatalog
3571
3581
  ]);
3572
3582
  const allActivityRenderers = (0, react.useMemo)(() => {
3573
3583
  return [...renderActivityMessagesList, ...builtInActivityRenderers];
@@ -3672,7 +3682,6 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3672
3682
  builtInFrontendTools,
3673
3683
  processedHumanInTheLoopTools
3674
3684
  ]);
3675
- const copilotkitRef = (0, react.useRef)(null);
3676
3685
  if (copilotkitRef.current === null) {
3677
3686
  copilotkitRef.current = new CopilotKitCoreReact({
3678
3687
  runtimeUrl: chatApiEndpoint,
@@ -3691,6 +3700,20 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3691
3700
  if (defaultThrottleMs !== void 0) copilotkitRef.current.setDefaultThrottleMs(defaultThrottleMs);
3692
3701
  }
3693
3702
  const copilotkit = copilotkitRef.current;
3703
+ (0, react.useEffect)(() => {
3704
+ if (!rawCatalog) return;
3705
+ if (!(rawCatalog instanceof _copilotkit_a2ui_renderer.Catalog)) return;
3706
+ const components = Array.from(rawCatalog.components.values()).map((comp) => ({
3707
+ name: comp.name,
3708
+ description: void 0,
3709
+ schema: comp.schema
3710
+ }));
3711
+ copilotkit.setCatalogComponents(components);
3712
+ const subscription = copilotkit.subscribe({ onCatalogComponentsChanged: () => {
3713
+ setCatalogToggleVersion((v) => v + 1);
3714
+ } });
3715
+ return () => subscription.unsubscribe();
3716
+ }, [copilotkit, rawCatalog]);
3694
3717
  (0, react.useEffect)(() => {
3695
3718
  const syncRuntimeInfo = () => {
3696
3719
  setRuntimeA2UIEnabled(copilotkit.a2uiEnabled);
@@ -3846,7 +3869,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3846
3869
  children: [
3847
3870
  a2uiActive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(A2UIBuiltInToolCallRenderer, {}),
3848
3871
  a2uiActive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(A2UICatalogContext, {
3849
- catalog: a2ui?.catalog,
3872
+ catalog: filteredCatalog,
3850
3873
  includeSchema: a2ui?.includeSchema
3851
3874
  }),
3852
3875
  children,
@@ -12244,4 +12267,4 @@ Object.defineProperty(exports, 'ɵrunMcpFollowUp', {
12244
12267
  return ɵrunMcpFollowUp;
12245
12268
  }
12246
12269
  });
12247
- //# sourceMappingURL=copilotkit-BrNiD3wI.cjs.map
12270
+ //# sourceMappingURL=copilotkit-2v7ami2b.cjs.map