@copilotkit/react-core 2.0.0-rc.43 → 2.0.0-rc.44

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.
Files changed (65) hide show
  1. package/dist/{MarkdownRendererContext-C2J_lgqF.d.cts → MarkdownRendererContext-QFCldfW_.d.cts} +1 -1
  2. package/dist/{MarkdownRendererContext-C2J_lgqF.d.cts.map → MarkdownRendererContext-QFCldfW_.d.cts.map} +1 -1
  3. package/dist/{MarkdownRendererContext-CytkPOAJ.d.mts → MarkdownRendererContext-aK63ZFd-.d.mts} +1 -1
  4. package/dist/{MarkdownRendererContext-CytkPOAJ.d.mts.map → MarkdownRendererContext-aK63ZFd-.d.mts.map} +1 -1
  5. package/dist/{MarkdownSurfaces-DytbRzj2.cjs → MarkdownSurfaces-Do948N1P.cjs} +2 -2
  6. package/dist/{MarkdownSurfaces-DytbRzj2.cjs.map → MarkdownSurfaces-Do948N1P.cjs.map} +1 -1
  7. package/dist/{MarkdownSurfaces-DlYqJkAE.mjs → MarkdownSurfaces-rtE9wRUP.mjs} +2 -2
  8. package/dist/{MarkdownSurfaces-DlYqJkAE.mjs.map → MarkdownSurfaces-rtE9wRUP.mjs.map} +1 -1
  9. package/dist/{ProviderMarkdown-i_i2osOH.cjs → ProviderMarkdown-D0eI0aPo.cjs} +23 -1
  10. package/dist/ProviderMarkdown-D0eI0aPo.cjs.map +1 -0
  11. package/dist/{ProviderMarkdown-BZaPDROY.mjs → ProviderMarkdown-epL7F3Vt.mjs} +19 -3
  12. package/dist/ProviderMarkdown-epL7F3Vt.mjs.map +1 -0
  13. package/dist/accessibility-BLK-gE0R.mjs.map +1 -1
  14. package/dist/accessibility-GnodqxkH.cjs.map +1 -1
  15. package/dist/chat-BZ_bvAkg.d.mts +38 -0
  16. package/dist/chat-BZ_bvAkg.d.mts.map +1 -0
  17. package/dist/chat-CpZVyF_t.d.cts +38 -0
  18. package/dist/chat-CpZVyF_t.d.cts.map +1 -0
  19. package/dist/generative-ui/map.cjs +26 -0
  20. package/dist/generative-ui/map.cjs.map +1 -0
  21. package/dist/generative-ui/map.d.cts +23 -0
  22. package/dist/generative-ui/map.d.cts.map +1 -0
  23. package/dist/generative-ui/map.d.mts +23 -0
  24. package/dist/generative-ui/map.d.mts.map +1 -0
  25. package/dist/generative-ui/map.mjs +24 -0
  26. package/dist/generative-ui/map.mjs.map +1 -0
  27. package/dist/generative-ui/native.d.cts +3 -2
  28. package/dist/generative-ui/native.d.cts.map +1 -1
  29. package/dist/generative-ui/native.d.mts +3 -2
  30. package/dist/generative-ui/native.d.mts.map +1 -1
  31. package/dist/generative-ui.cjs +2 -2
  32. package/dist/generative-ui.d.cts +5 -4
  33. package/dist/generative-ui.d.cts.map +1 -1
  34. package/dist/generative-ui.d.mts +5 -4
  35. package/dist/generative-ui.d.mts.map +1 -1
  36. package/dist/generative-ui.mjs +2 -2
  37. package/dist/{hooks-DqsOIh8A.d.mts → hooks-D2H3iL0N.d.mts} +2 -2
  38. package/dist/{hooks-DqsOIh8A.d.mts.map → hooks-D2H3iL0N.d.mts.map} +1 -1
  39. package/dist/{hooks-2Ur8NQhj.d.cts → hooks-Dy8HeEdr.d.cts} +2 -2
  40. package/dist/{hooks-2Ur8NQhj.d.cts.map → hooks-Dy8HeEdr.d.cts.map} +1 -1
  41. package/dist/index.cjs +12 -26
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.cts +4 -3
  44. package/dist/index.d.cts.map +1 -1
  45. package/dist/index.d.mts +4 -3
  46. package/dist/index.d.mts.map +1 -1
  47. package/dist/index.mjs +11 -25
  48. package/dist/index.mjs.map +1 -1
  49. package/dist/index.umd.js +44 -21
  50. package/dist/index.umd.js.map +1 -1
  51. package/dist/{chat-C5XWeO1M.d.mts → runtime-context-B7f4M85q.d.mts} +21 -39
  52. package/dist/runtime-context-B7f4M85q.d.mts.map +1 -0
  53. package/dist/{chat-DtHs4alO.d.cts → runtime-context-CIkZS0ap.d.cts} +21 -39
  54. package/dist/runtime-context-CIkZS0ap.d.cts.map +1 -0
  55. package/dist/{standard-s8jByRiE.mjs → standard-CSBR4FhM.mjs} +31 -15
  56. package/dist/standard-CSBR4FhM.mjs.map +1 -0
  57. package/dist/{standard-CqGTZUZy.cjs → standard-DBjcBGyd.cjs} +31 -15
  58. package/dist/standard-DBjcBGyd.cjs.map +1 -0
  59. package/package.json +14 -7
  60. package/dist/ProviderMarkdown-BZaPDROY.mjs.map +0 -1
  61. package/dist/ProviderMarkdown-i_i2osOH.cjs.map +0 -1
  62. package/dist/chat-C5XWeO1M.d.mts.map +0 -1
  63. package/dist/chat-DtHs4alO.d.cts.map +0 -1
  64. package/dist/standard-CqGTZUZy.cjs.map +0 -1
  65. package/dist/standard-s8jByRiE.mjs.map +0 -1
package/dist/index.umd.js CHANGED
@@ -82,8 +82,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
82
82
 
83
83
  //#endregion
84
84
  //#region src/lib/use-latest-ref.ts
85
- const useIsomorphicLayoutEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect;
86
- /**
85
+ /**
87
86
  * A ref that holds the latest `value`, for callbacks that run after render
88
87
  * (event handlers, controller callbacks). The ref changes in a layout effect,
89
88
  * not during render, so a render that React throws away leaves it alone.
@@ -95,6 +94,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
95
94
  });
96
95
  return ref;
97
96
  }
97
+ var useIsomorphicLayoutEffect;
98
+ var init_use_latest_ref = __esmMin((() => {
99
+ useIsomorphicLayoutEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect;
100
+ }));
98
101
 
99
102
  //#endregion
100
103
  //#region src/lib/utils.ts
@@ -759,6 +762,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
759
762
 
760
763
  //#endregion
761
764
  //#region src/components/chat/CopilotChatInput.tsx
765
+ init_use_latest_ref();
762
766
  init_CopilotIcon();
763
767
  init_slots();
764
768
  init_utils();
@@ -1373,7 +1377,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1373
1377
 
1374
1378
  //#endregion
1375
1379
  //#region package.json
1376
- var version$1 = "2.0.0-rc.43";
1380
+ var version$1 = "2.0.0-rc.44";
1377
1381
 
1378
1382
  //#endregion
1379
1383
  //#region src/components/CopilotKitInspector.tsx
@@ -5054,13 +5058,18 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
5054
5058
  return typeof value === "object" && value !== null && "Map" in value && typeof value.Map === "function";
5055
5059
  }
5056
5060
  /**
5057
- * Imports maplibre-gl on the client. The package is an optional peer
5058
- * dependency. The import rejects when it is not installed.
5061
+ * Loads maplibre-gl on the client with the `map` loader of the
5062
+ * `generativeUI` config. This module never imports the package itself: a
5063
+ * bundler resolves each dynamic import at build time, so an app without the
5064
+ * optional peer would fail to build. Rejects when the module is not
5065
+ * maplibre-gl.
5059
5066
  */
5060
- async function loadMapLibre() {
5061
- const module = await import("maplibre-gl");
5062
- const fromDefault = "default" in module ? module.default : void 0;
5063
- return isMapLibre(fromDefault) ? fromDefault : module;
5067
+ async function loadMapLibre(loader) {
5068
+ const loaded = await loader();
5069
+ const fromDefault = typeof loaded === "object" && loaded !== null && "default" in loaded ? loaded.default : void 0;
5070
+ if (isMapLibre(fromDefault)) return fromDefault;
5071
+ if (isMapLibre(loaded)) return loaded;
5072
+ throw new Error("The map loader did not give maplibre-gl.");
5064
5073
  }
5065
5074
  /**
5066
5075
  * True when the element is in dark mode: it, or an ancestor, has the `dark`
@@ -5082,8 +5091,9 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
5082
5091
  return isDark;
5083
5092
  }
5084
5093
  /**
5085
- * A MapLibre map with markers. maplibre-gl loads only in the browser. When
5086
- * it is not installed, or WebGL is not there, the component shows a list of
5094
+ * A MapLibre map with markers. maplibre-gl loads only in the browser, with
5095
+ * the `map` loader of the `generativeUI` config. Without the loader, when
5096
+ * the load fails, or when WebGL is not there, the component shows a list of
5087
5097
  * the places. A click on a place or a marker sets `selected`.
5088
5098
  */
5089
5099
  function MapView(props) {
@@ -5094,16 +5104,24 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
5094
5104
  const { zoom, route } = props;
5095
5105
  const height = props.height ?? 240;
5096
5106
  const containerRef = (0, react.useRef)(null);
5097
- const [status, setStatus] = (0, react.useState)("loading");
5107
+ const runtime = useRequiredGenerativeUIRuntime();
5108
+ const { theme } = runtime;
5109
+ const loaderRef = useLatestRef(runtime.config.map);
5110
+ const hasLoader = runtime.config.map !== void 0;
5111
+ const [status, setStatus] = (0, react.useState)(hasLoader ? "loading" : "fallback");
5098
5112
  const setSelectedRef = (0, react.useRef)(props.setSelected);
5099
5113
  setSelectedRef.current = props.setSelected;
5100
- const { theme } = useRequiredGenerativeUIRuntime();
5101
5114
  const styleUrl = useIsDark(containerRef) ? theme?.dark?.mapStyle || theme?.mapStyle || DEFAULT_DARK_MAP_STYLE : theme?.mapStyle || DEFAULT_MAP_STYLE;
5102
5115
  (0, react.useEffect)(() => {
5103
5116
  let isCancelled = false;
5104
5117
  let map;
5105
- async function mount() {
5106
- const maplibregl = await loadMapLibre();
5118
+ const loader = loaderRef.current;
5119
+ if (!loader) {
5120
+ setStatus("fallback");
5121
+ return;
5122
+ }
5123
+ async function mount(load) {
5124
+ const maplibregl = await loadMapLibre(load);
5107
5125
  const container = containerRef.current;
5108
5126
  if (isCancelled || !container) return;
5109
5127
  const first = markers[0];
@@ -5164,7 +5182,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
5164
5182
  });
5165
5183
  setStatus("ready");
5166
5184
  }
5167
- mount().catch(() => {
5185
+ mount(loader).catch(() => {
5168
5186
  map?.remove();
5169
5187
  map = void 0;
5170
5188
  if (!isCancelled) setStatus("fallback");
@@ -5176,6 +5194,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
5176
5194
  } catch {}
5177
5195
  };
5178
5196
  }, [
5197
+ hasLoader,
5198
+ loaderRef,
5179
5199
  markers,
5180
5200
  center,
5181
5201
  zoom,
@@ -5263,6 +5283,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
5263
5283
  var init_Map = __esmMin((() => {
5264
5284
  init_runtime_context();
5265
5285
  init_Chart();
5286
+ init_use_latest_ref();
5266
5287
  init_styles();
5267
5288
  DEFAULT_MAP_STYLE = "https://tiles.openfreemap.org/styles/positron";
5268
5289
  DEFAULT_DARK_MAP_STYLE = "https://tiles.openfreemap.org/styles/dark";
@@ -7921,9 +7942,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
7921
7942
  }
7922
7943
  /**
7923
7944
  * The generative UI config of the provider. That is the `generativeUI` prop
7924
- * when the app sets one. Otherwise, when the runtime turns generative UI on,
7925
- * it is the standard UI for the agents of the runtime, once the standard UI
7926
- * has loaded. `undefined` while generative UI is off, or still loading.
7945
+ * when it has a `ui`. Otherwise, when the runtime turns generative UI on, it
7946
+ * is the standard UI for the agents of the runtime, once the standard UI has
7947
+ * loaded, with the other options of the prop (such as `map` or `theme`).
7948
+ * `undefined` while generative UI is off, or still loading.
7927
7949
  */
7928
7950
  function useStandardUIFallback(generativeUI, runtimeInfo) {
7929
7951
  const fallback = (0, _copilotkit_core.ɵresolveGenerativeUIDefault)({
@@ -7947,11 +7969,12 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
7947
7969
  };
7948
7970
  }, [active, standardUI]);
7949
7971
  return (0, react.useMemo)(() => {
7950
- if (generativeUI) return generativeUI;
7972
+ if (generativeUI?.ui) return generativeUI;
7951
7973
  if (!active || !standardUI) return void 0;
7952
7974
  return {
7975
+ ...generativeUI,
7953
7976
  ui: standardUI,
7954
- agentIds
7977
+ agentIds: generativeUI?.agentIds ?? agentIds
7955
7978
  };
7956
7979
  }, [
7957
7980
  generativeUI,