@copilotkit/react-core 1.55.0-next.9 → 1.55.1-next.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +46 -6
  2. package/dist/{copilotkit-DeOzjPsb.mjs → copilotkit-BY5S1-0P.mjs} +2402 -552
  3. package/dist/copilotkit-BY5S1-0P.mjs.map +1 -0
  4. package/dist/{copilotkit-BqcyhQjT.d.mts → copilotkit-BuhSUZHb.d.mts} +228 -17
  5. package/dist/copilotkit-BuhSUZHb.d.mts.map +1 -0
  6. package/dist/{copilotkit-BDNjFNmk.cjs → copilotkit-Bz5-ImDl.cjs} +2421 -541
  7. package/dist/copilotkit-Bz5-ImDl.cjs.map +1 -0
  8. package/dist/{copilotkit-l-IBF4Xp.d.cts → copilotkit-dwDWYpya.d.cts} +228 -17
  9. package/dist/copilotkit-dwDWYpya.d.cts.map +1 -0
  10. package/dist/index.cjs +1 -1
  11. package/dist/index.d.cts +1 -1
  12. package/dist/index.d.mts +1 -1
  13. package/dist/index.mjs +1 -1
  14. package/dist/index.umd.js +1400 -238
  15. package/dist/index.umd.js.map +1 -1
  16. package/dist/v2/index.cjs +13 -1
  17. package/dist/v2/index.css +1 -1
  18. package/dist/v2/index.d.cts +3 -3
  19. package/dist/v2/index.d.mts +3 -3
  20. package/dist/v2/index.mjs +3 -2
  21. package/dist/v2/index.umd.js +2442 -552
  22. package/dist/v2/index.umd.js.map +1 -1
  23. package/package.json +62 -54
  24. package/scripts/scope-preflight.mjs +1 -2
  25. package/src/components/CopilotListeners.tsx +41 -8
  26. package/src/components/copilot-provider/copilotkit-props.tsx +4 -2
  27. package/src/components/toast/toast-provider.tsx +269 -194
  28. package/src/v2/__tests__/A2UIMessageRenderer.test.tsx +86 -22
  29. package/src/v2/__tests__/utils/test-helpers.tsx +67 -0
  30. package/src/v2/a2ui/A2UICatalogContext.tsx +79 -0
  31. package/src/v2/a2ui/A2UIMessageRenderer.tsx +125 -37
  32. package/src/v2/a2ui/A2UIToolCallRenderer.tsx +290 -0
  33. package/src/v2/components/CopilotKitInspector.tsx +2 -0
  34. package/src/v2/components/OpenGenerativeUIRenderer.tsx +598 -0
  35. package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.tsx +665 -0
  36. package/src/v2/components/chat/CopilotChat.tsx +193 -50
  37. package/src/v2/components/chat/CopilotChatAssistantMessage.tsx +17 -2
  38. package/src/v2/components/chat/CopilotChatAttachmentQueue.tsx +481 -0
  39. package/src/v2/components/chat/CopilotChatAttachmentRenderer.tsx +139 -0
  40. package/src/v2/components/chat/CopilotChatInput.tsx +146 -77
  41. package/src/v2/components/chat/CopilotChatMessageView.tsx +253 -149
  42. package/src/v2/components/chat/CopilotChatSuggestionView.tsx +1 -0
  43. package/src/v2/components/chat/CopilotChatUserMessage.tsx +54 -0
  44. package/src/v2/components/chat/CopilotChatView.tsx +179 -66
  45. package/src/v2/components/chat/__tests__/CopilotChat.attachments.test.tsx +168 -0
  46. package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.tsx +63 -2
  47. package/src/v2/components/chat/__tests__/CopilotChatInput.test.tsx +544 -1
  48. package/src/v2/components/chat/__tests__/CopilotChatPerf.e2e.test.tsx +268 -0
  49. package/src/v2/components/chat/__tests__/CopilotChatPropsRerender.e2e.test.tsx +249 -0
  50. package/src/v2/components/chat/__tests__/MCPAppsActivityRenderer.e2e.test.tsx +43 -2
  51. package/src/v2/components/chat/__tests__/copilot-chat-throttle.test.tsx +138 -0
  52. package/src/v2/components/chat/index.ts +9 -0
  53. package/src/v2/components/chat/scroll-element-context.ts +13 -0
  54. package/src/v2/hooks/__tests__/use-agent-throttle.test.tsx +1003 -0
  55. package/src/v2/hooks/__tests__/use-attachments.test.tsx +169 -0
  56. package/src/v2/hooks/__tests__/use-threads.test.tsx +54 -0
  57. package/src/v2/hooks/index.ts +5 -0
  58. package/src/v2/hooks/use-agent.tsx +95 -10
  59. package/src/v2/hooks/use-attachments.tsx +269 -0
  60. package/src/v2/hooks/use-frontend-tool.tsx +5 -2
  61. package/src/v2/hooks/use-render-activity-message.tsx +9 -2
  62. package/src/v2/hooks/use-threads.tsx +35 -15
  63. package/src/v2/index.ts +5 -1
  64. package/src/v2/lib/__tests__/processPartialHtml.test.ts +112 -0
  65. package/src/v2/lib/__tests__/slots.test.ts +56 -0
  66. package/src/v2/lib/processPartialHtml.ts +45 -0
  67. package/src/v2/lib/slots.tsx +42 -1
  68. package/src/v2/providers/CopilotChatConfigurationProvider.tsx +9 -3
  69. package/src/v2/providers/CopilotKitProvider.tsx +268 -32
  70. package/src/v2/providers/SandboxFunctionsContext.ts +10 -0
  71. package/src/v2/providers/__tests__/CopilotKitProvider.sandboxFunctions.test.tsx +198 -0
  72. package/src/v2/providers/__tests__/CopilotKitProvider.test.tsx +71 -0
  73. package/src/v2/providers/index.ts +7 -0
  74. package/src/v2/styles/globals.css +2 -1
  75. package/src/v2/types/index.ts +1 -0
  76. package/src/v2/types/sandbox-function.ts +11 -0
  77. package/dist/copilotkit-BDNjFNmk.cjs.map +0 -1
  78. package/dist/copilotkit-BqcyhQjT.d.mts.map +0 -1
  79. package/dist/copilotkit-DeOzjPsb.mjs.map +0 -1
  80. package/dist/copilotkit-l-IBF4Xp.d.cts.map +0 -1
  81. package/src/v2/components/__tests__/license-warning-banner.test.tsx +0 -46
@@ -573,6 +573,76 @@ describe("CopilotKitProvider", () => {
573
573
  });
574
574
  });
575
575
 
576
+ describe("useSingleEndpoint → runtimeTransport mapping", () => {
577
+ it("maps useSingleEndpoint=true to 'single' transport", () => {
578
+ const { result } = renderHook(() => useCopilotKit(), {
579
+ wrapper: ({ children }) => (
580
+ <CopilotKitProvider useSingleEndpoint={true}>
581
+ {children}
582
+ </CopilotKitProvider>
583
+ ),
584
+ });
585
+
586
+ expect(result.current.copilotkit.runtimeTransport).toBe("single");
587
+ });
588
+
589
+ it("maps useSingleEndpoint=false to 'rest' transport", () => {
590
+ const { result } = renderHook(() => useCopilotKit(), {
591
+ wrapper: ({ children }) => (
592
+ <CopilotKitProvider useSingleEndpoint={false}>
593
+ {children}
594
+ </CopilotKitProvider>
595
+ ),
596
+ });
597
+
598
+ expect(result.current.copilotkit.runtimeTransport).toBe("rest");
599
+ });
600
+
601
+ it("maps omitted useSingleEndpoint to 'auto' transport", () => {
602
+ const { result } = renderHook(() => useCopilotKit(), {
603
+ wrapper: ({ children }) => (
604
+ <CopilotKitProvider>{children}</CopilotKitProvider>
605
+ ),
606
+ });
607
+
608
+ expect(result.current.copilotkit.runtimeTransport).toBe("auto");
609
+ });
610
+
611
+ it("updates transport when useSingleEndpoint prop changes", () => {
612
+ let capturedCopilotkit: ReturnType<typeof useCopilotKit>["copilotkit"];
613
+
614
+ function Collector({ children }: { children?: React.ReactNode }) {
615
+ const { copilotkit } = useCopilotKit();
616
+ capturedCopilotkit = copilotkit;
617
+ return <>{children}</>;
618
+ }
619
+
620
+ const { rerender } = render(
621
+ <CopilotKitProvider useSingleEndpoint={false}>
622
+ <Collector />
623
+ </CopilotKitProvider>,
624
+ );
625
+
626
+ expect(capturedCopilotkit!.runtimeTransport).toBe("rest");
627
+
628
+ rerender(
629
+ <CopilotKitProvider useSingleEndpoint={true}>
630
+ <Collector />
631
+ </CopilotKitProvider>,
632
+ );
633
+
634
+ expect(capturedCopilotkit!.runtimeTransport).toBe("single");
635
+
636
+ rerender(
637
+ <CopilotKitProvider>
638
+ <Collector />
639
+ </CopilotKitProvider>,
640
+ );
641
+
642
+ expect(capturedCopilotkit!.runtimeTransport).toBe("auto");
643
+ });
644
+ });
645
+
576
646
  describe("Edge cases", () => {
577
647
  it("handles empty arrays for tools", () => {
578
648
  const { result } = renderHook(() => useCopilotKit(), {
@@ -583,6 +653,7 @@ describe("CopilotKitProvider", () => {
583
653
  ),
584
654
  });
585
655
 
656
+ // No built-in tools when openGenerativeUI is not configured
586
657
  expect(result.current.copilotkit.tools).toHaveLength(0);
587
658
  expect(result.current.copilotkit.renderToolCalls).toHaveLength(0);
588
659
  });
@@ -12,3 +12,10 @@ export {
12
12
  type CopilotKitProviderProps,
13
13
  type CopilotKitContextValue,
14
14
  } from "./CopilotKitProvider";
15
+
16
+ export type { Anchor as InspectorAnchor } from "@copilotkit/web-inspector";
17
+
18
+ export {
19
+ SandboxFunctionsContext,
20
+ useSandboxFunctions,
21
+ } from "./SandboxFunctionsContext";
@@ -119,7 +119,8 @@
119
119
  }
120
120
 
121
121
  @theme {
122
- --animate-pulse-cursor: pulse-cursor 0.9s cubic-bezier(0.4, 0, 0.2, 1) infinite;
122
+ --animate-pulse-cursor: pulse-cursor 0.9s cubic-bezier(0.4, 0, 0.2, 1)
123
+ infinite;
123
124
  @keyframes pulse-cursor {
124
125
  0%,
125
126
  100% {
@@ -5,3 +5,4 @@ export * from "./frontend-tool";
5
5
  export * from "./human-in-the-loop";
6
6
  export * from "./defineToolCallRenderer";
7
7
  export * from "./interrupt";
8
+ export * from "./sandbox-function";
@@ -0,0 +1,11 @@
1
+ import type { StandardSchemaV1 } from "@copilotkit/shared";
2
+
3
+ export type SandboxFunction<
4
+ TParams extends StandardSchemaV1 = StandardSchemaV1,
5
+ > = {
6
+ name: string;
7
+ description: string;
8
+ parameters: TParams;
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ handler: (args: any) => Promise<unknown>;
11
+ };