@copilotkit/react-core 1.77.1 → 1.78.0

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.
@@ -1655,7 +1655,7 @@ function useRenderToolCall() {
1655
1655
 
1656
1656
  //#endregion
1657
1657
  //#region package.json
1658
- var version = "1.77.1";
1658
+ var version = "1.78.0";
1659
1659
 
1660
1660
  //#endregion
1661
1661
  //#region src/v2/components/CopilotKitInspector.tsx
@@ -3412,6 +3412,13 @@ const DEFAULT_DESIGN_SKILL = `When generating UI with generateSandboxedUi, follo
3412
3412
  - Use CSS Grid or Flexbox for layout. Ensure the UI looks good at any width.
3413
3413
  - Minimal transitions (150ms) for hover/focus states only. No decorative animations.
3414
3414
  - Keep the UI focused and dense — avoid excessive padding. Use compact spacing (8–12px gaps, 10–14px padding in controls).`;
3415
+ const DEFAULT_LEARNING = Object.freeze({});
3416
+ function toLearningConfig(learning) {
3417
+ if (learning === true) return DEFAULT_LEARNING;
3418
+ if (learning === false || learning === void 0) return void 0;
3419
+ const { autoStart: _autoStart, ...config } = learning;
3420
+ return config;
3421
+ }
3415
3422
  function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
3416
3423
  const empty = (0, react.useMemo)(() => [], []);
3417
3424
  const value = prop ?? empty;
@@ -3422,6 +3429,7 @@ function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
3422
3429
  return value;
3423
3430
  }
3424
3431
  const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, messageFilter, publicApiKey, publicLicenseKey, licenseToken, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, enableInspector, agentId, showIntelligenceIndicator = true, useSingleEndpoint, onError, a2ui, defaultThrottleMs, debug, learning }) => {
3432
+ const learningConfig = (0, react.useMemo)(() => toLearningConfig(learning), [learning]);
3425
3433
  const [shouldRenderInspector, setShouldRenderInspector] = (0, react.useState)(false);
3426
3434
  const [inspectorVisible, setInspectorVisible] = (0, react.useState)(false);
3427
3435
  (0, react.useEffect)(() => {
@@ -3657,7 +3665,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3657
3665
  renderActivityMessages: allActivityRenderers,
3658
3666
  renderCustomMessages: renderCustomMessagesList,
3659
3667
  debug,
3660
- learning
3668
+ learning: learningConfig
3661
3669
  });
3662
3670
  if (defaultThrottleMs !== void 0) copilotkitRef.current.setDefaultThrottleMs(defaultThrottleMs);
3663
3671
  }
@@ -3762,17 +3770,31 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3762
3770
  useSingleEndpoint,
3763
3771
  debug
3764
3772
  ]);
3765
- const learningEnabled = learning !== void 0;
3766
- const trajectoryId = learning?.trajectoryId;
3767
- const learningContainerIdsRef = (0, react.useRef)(learning?.learningContainerIds);
3773
+ const learningEnabled = learningConfig !== void 0;
3774
+ const autoStart = learningEnabled && (typeof learning !== "object" || learning.autoStart !== false);
3775
+ const suppliedTrajectoryId = autoStart ? learningConfig?.trajectoryId : void 0;
3776
+ const generatesTrajectoryId = autoStart && suppliedTrajectoryId === void 0;
3777
+ const learningContainerIdsRef = (0, react.useRef)(learningConfig?.learningContainerIds);
3778
+ const generatedTrajectoryIdRef = (0, react.useRef)(void 0);
3779
+ (0, react.useEffect)(() => {
3780
+ copilotkit.setLearningConfig(learningConfig);
3781
+ learningContainerIdsRef.current = learningConfig?.learningContainerIds;
3782
+ if (learningConfig?.sink === void 0 && !autoStart && learningConfig?.learningContainerIds !== void 0) console.warn("[CopilotKit] learningContainerIds is supported only with a custom sink. Authenticated Trajectory capture does not assign Learning Containers; remove learningContainerIds from the capture options.");
3783
+ }, [
3784
+ copilotkit,
3785
+ learningConfig,
3786
+ autoStart
3787
+ ]);
3788
+ const ignoresTrajectoryId = !autoStart && learningConfig?.trajectoryId !== void 0;
3768
3789
  (0, react.useEffect)(() => {
3769
- copilotkit.setLearningConfig(learning);
3770
- learningContainerIdsRef.current = learning?.learningContainerIds;
3771
- if (learning?.sink === void 0 && learning?.trajectoryId === void 0 && learning?.learningContainerIds !== void 0) console.warn("[CopilotKit] learningContainerIds is supported only with a custom sink. Authenticated Trajectory capture does not assign Learning Containers; remove learningContainerIds from the capture options.");
3772
- }, [copilotkit, learning]);
3790
+ if (!ignoresTrajectoryId) return;
3791
+ console.warn("[CopilotKit] learning.trajectoryId is ignored when autoStart is false; pass the ID to startTrajectory() instead.");
3792
+ }, [ignoresTrajectoryId]);
3773
3793
  (0, react.useEffect)(() => {
3794
+ if (!generatesTrajectoryId) generatedTrajectoryIdRef.current = void 0;
3774
3795
  if (!learningEnabled) return;
3775
3796
  let disposed = false;
3797
+ const trajectoryId = generatesTrajectoryId ? generatedTrajectoryIdRef.current ??= (0, _copilotkit_shared.randomUUID)() : suppliedTrajectoryId;
3776
3798
  if (trajectoryId !== void 0) copilotkit.startTrajectory({
3777
3799
  trajectoryId,
3778
3800
  learningContainerIds: learningContainerIdsRef.current
@@ -3786,7 +3808,8 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3786
3808
  }, [
3787
3809
  copilotkit,
3788
3810
  learningEnabled,
3789
- trajectoryId
3811
+ generatesTrajectoryId,
3812
+ suppliedTrajectoryId
3790
3813
  ]);
3791
3814
  const didMountRef = (0, react.useRef)(false);
3792
3815
  (0, react.useEffect)(() => {
@@ -3861,17 +3884,17 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3861
3884
  const hasNonReadyRuntimeEntitlement = runtimeEntitlements !== void 0 && runtimeEntitlements.status !== "ready";
3862
3885
  const hasLegacyRuntimeEntitlementFallback = runtimeLicenseStatus === "valid" || runtimeLicenseStatus === "expiring";
3863
3886
  const runtimeEntitlementRetryInProgress = retryableRuntimeEntitlementFailure && runtimeEntitlementRetryPending && !hasLegacyRuntimeEntitlementFallback;
3864
- const runtimeEntitlementFailureSettled = hasNonReadyRuntimeEntitlement && !runtimeEntitlementRetryInProgress && !hasLegacyRuntimeEntitlementFallback;
3887
+ const terminalRuntimeEntitlementFailure = hasNonReadyRuntimeEntitlement && !retryableRuntimeEntitlementFailure && !hasLegacyRuntimeEntitlementFallback;
3865
3888
  const licenseContextValue = (0, react.useMemo)(() => {
3866
3889
  const runtimeLicenseContext = (0, _copilotkit_shared.createLicenseContextValue)(runtimeEntitlementRetryInProgress ? void 0 : runtimeLicenseStatus, runtimeEntitlements);
3867
- if (!runtimeEntitlementFailureSettled) return runtimeLicenseContext;
3890
+ if (!terminalRuntimeEntitlementFailure) return runtimeLicenseContext;
3868
3891
  return {
3869
3892
  ...runtimeLicenseContext,
3870
3893
  checkFeature: () => false,
3871
3894
  getLimit: () => null
3872
3895
  };
3873
3896
  }, [
3874
- runtimeEntitlementFailureSettled,
3897
+ terminalRuntimeEntitlementFailure,
3875
3898
  runtimeEntitlementRetryInProgress,
3876
3899
  runtimeEntitlements,
3877
3900
  runtimeLicenseStatus
@@ -13354,4 +13377,4 @@ Object.defineProperty(exports, 'useToast', {
13354
13377
  return useToast;
13355
13378
  }
13356
13379
  });
13357
- //# sourceMappingURL=copilotkit-BG1d4-qU.cjs.map
13380
+ //# sourceMappingURL=copilotkit-BFeenQQ0.cjs.map