@copilotkit/react-core 1.70.0 → 1.70.2

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 (37) hide show
  1. package/dist/{copilotkit-CbZGwElm.d.mts → copilotkit--Jyzm6hS.d.mts} +50 -20
  2. package/dist/copilotkit--Jyzm6hS.d.mts.map +1 -0
  3. package/dist/{copilotkit-B7aFKfQR.mjs → copilotkit-B1jSvZeb.mjs} +395 -291
  4. package/dist/copilotkit-B1jSvZeb.mjs.map +1 -0
  5. package/dist/{copilotkit-BuzP0VeG.d.cts → copilotkit-BLYaCGcz.d.cts} +50 -20
  6. package/dist/copilotkit-BLYaCGcz.d.cts.map +1 -0
  7. package/dist/{copilotkit-BE76j111.cjs → copilotkit-DcFo270Y.cjs} +395 -291
  8. package/dist/copilotkit-DcFo270Y.cjs.map +1 -0
  9. package/dist/index.cjs +5 -4
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +2 -2
  12. package/dist/index.d.cts.map +1 -1
  13. package/dist/index.d.mts +2 -2
  14. package/dist/index.d.mts.map +1 -1
  15. package/dist/index.mjs +5 -4
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/index.umd.js +198 -207
  18. package/dist/index.umd.js.map +1 -1
  19. package/dist/v2/headless.cjs +58 -1
  20. package/dist/v2/headless.cjs.map +1 -1
  21. package/dist/v2/headless.mjs +59 -2
  22. package/dist/v2/headless.mjs.map +1 -1
  23. package/dist/v2/index.cjs +1 -1
  24. package/dist/v2/index.css +1 -1
  25. package/dist/v2/index.d.cts +1 -1
  26. package/dist/v2/index.d.mts +1 -1
  27. package/dist/v2/index.mjs +1 -1
  28. package/dist/v2/index.umd.js +395 -291
  29. package/dist/v2/index.umd.js.map +1 -1
  30. package/package.json +11 -8
  31. package/skills/react-core/SKILL.md +1 -1
  32. package/skills/react-core/references/attachments.md +20 -0
  33. package/skills/react-core/references/threads.md +1 -1
  34. package/dist/copilotkit-B7aFKfQR.mjs.map +0 -1
  35. package/dist/copilotkit-BE76j111.cjs.map +0 -1
  36. package/dist/copilotkit-BuzP0VeG.d.cts.map +0 -1
  37. package/dist/copilotkit-CbZGwElm.d.mts.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { CopilotKitCoreReact, useCopilotKit, useCopilotKit as useCopilotKit$1 } from "@copilotkit/react-core/v2/context";
2
2
  import React, { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
3
3
  import { DEFAULT_AGENT_ID, partialJSONParse, randomUUID } from "@copilotkit/shared";
4
- import { jsx } from "react/jsx-runtime";
4
+ import { Fragment, jsx } from "react/jsx-runtime";
5
5
  import { HttpAgent, randomUUID as randomUUID$1 } from "@ag-ui/client";
6
6
  import { CopilotKitCoreRuntimeConnectionStatus, ProxiedCopilotRuntimeAgent, ToolCallStatus, ɵInterruptState, ɵcreateThreadStore, ɵselectFetchMoreError, ɵselectHasNextPage, ɵselectIsFetchingNextPage, ɵselectIsMutating, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading } from "@copilotkit/core";
7
7
  import { z } from "zod";
@@ -252,6 +252,62 @@ const CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId,
252
252
  const useCopilotChatConfiguration = () => {
253
253
  return useContext(CopilotChatConfiguration);
254
254
  };
255
+ /**
256
+ * Reports modal open/close requests to the host, and — when `open` is
257
+ * supplied — makes the modal state of an already-established chat
258
+ * configuration **controlled** for the subtree it wraps.
259
+ *
260
+ * This is deliberately a scope component rather than another mode inside
261
+ * {@link CopilotChatConfigurationProvider}. The provider resolves modal state
262
+ * across a nested chain (own state, parent sync, drawer mutual-exclusion, the
263
+ * modal-closer registry); a controlled branch inside that resolution would add
264
+ * a fourth interacting mode. Overriding the context for the subtree instead
265
+ * leaves every one of those paths untouched:
266
+ *
267
+ * - `isModalOpen` is replaced with the host's `open`, so the rendered surface
268
+ * follows the prop from the very first frame (no open-then-close flash).
269
+ * - `setModalOpen` still calls the underlying setter, so the existing
270
+ * parent-sync and drawer mutual-exclusion side effects continue to run, and
271
+ * *then* reports the request through `onOpenChange`.
272
+ * - The wrapped setter is registered as the modal closer, so the drawer's
273
+ * mobile mutual-exclusion reaches the host instead of silently flipping
274
+ * state that nothing displays.
275
+ *
276
+ * A host that supplies `open` and ignores `onOpenChange` gets a modal pinned
277
+ * to `open`, which is the standard controlled-component contract. A host that
278
+ * supplies only `onOpenChange` is notified while the modal keeps managing
279
+ * itself.
280
+ *
281
+ * Renders `children` unchanged when no chat configuration is in scope.
282
+ */
283
+ const ControlledModalOpenScope = ({ children, open, onOpenChange }) => {
284
+ const parentConfig = useContext(CopilotChatConfiguration);
285
+ const parentSetModalOpen = parentConfig?.setModalOpen;
286
+ const registerModalCloser = parentConfig?.ɵregisterModalCloser;
287
+ const setModalOpen = useCallback((next) => {
288
+ parentSetModalOpen?.(next);
289
+ onOpenChange?.(next);
290
+ }, [parentSetModalOpen, onOpenChange]);
291
+ useEffect(() => {
292
+ if (!registerModalCloser) return;
293
+ return registerModalCloser(setModalOpen);
294
+ }, [registerModalCloser, setModalOpen]);
295
+ const configurationValue = useMemo(() => parentConfig ? {
296
+ ...parentConfig,
297
+ isModalOpen: open ?? parentConfig.isModalOpen,
298
+ setModalOpen
299
+ } : null, [
300
+ parentConfig,
301
+ open,
302
+ setModalOpen
303
+ ]);
304
+ if (!configurationValue) return /* @__PURE__ */ jsx(Fragment, { children });
305
+ return /* @__PURE__ */ jsx(CopilotChatConfiguration.Provider, {
306
+ value: configurationValue,
307
+ children
308
+ });
309
+ };
310
+ ControlledModalOpenScope.displayName = "ControlledModalOpenScope";
255
311
 
256
312
  //#endregion
257
313
  //#region src/v2/hooks/use-agent.tsx
@@ -478,7 +534,8 @@ function useFrontendTool(tool, deps) {
478
534
  tool.name,
479
535
  tool.available,
480
536
  copilotkit,
481
- JSON.stringify(extraDeps)
537
+ JSON.stringify(extraDeps),
538
+ JSON.stringify(tool.webmcp ?? null)
482
539
  ]);
483
540
  }
484
541