@copilotkit/react-core 1.55.0-next.9 → 1.55.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.
- package/CHANGELOG.md +36 -6
- package/dist/{copilotkit-DeOzjPsb.mjs → copilotkit-BY5S1-0P.mjs} +2402 -552
- package/dist/copilotkit-BY5S1-0P.mjs.map +1 -0
- package/dist/{copilotkit-BqcyhQjT.d.mts → copilotkit-BuhSUZHb.d.mts} +228 -17
- package/dist/copilotkit-BuhSUZHb.d.mts.map +1 -0
- package/dist/{copilotkit-BDNjFNmk.cjs → copilotkit-Bz5-ImDl.cjs} +2421 -541
- package/dist/copilotkit-Bz5-ImDl.cjs.map +1 -0
- package/dist/{copilotkit-l-IBF4Xp.d.cts → copilotkit-dwDWYpya.d.cts} +228 -17
- package/dist/copilotkit-dwDWYpya.d.cts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +1400 -238
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/index.cjs +13 -1
- package/dist/v2/index.css +1 -1
- package/dist/v2/index.d.cts +3 -3
- package/dist/v2/index.d.mts +3 -3
- package/dist/v2/index.mjs +3 -2
- package/dist/v2/index.umd.js +2442 -552
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +62 -54
- package/scripts/scope-preflight.mjs +1 -2
- package/src/components/CopilotListeners.tsx +41 -8
- package/src/components/copilot-provider/copilotkit-props.tsx +4 -2
- package/src/components/toast/toast-provider.tsx +269 -194
- package/src/v2/__tests__/A2UIMessageRenderer.test.tsx +86 -22
- package/src/v2/__tests__/utils/test-helpers.tsx +67 -0
- package/src/v2/a2ui/A2UICatalogContext.tsx +79 -0
- package/src/v2/a2ui/A2UIMessageRenderer.tsx +125 -37
- package/src/v2/a2ui/A2UIToolCallRenderer.tsx +290 -0
- package/src/v2/components/CopilotKitInspector.tsx +2 -0
- package/src/v2/components/OpenGenerativeUIRenderer.tsx +598 -0
- package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.tsx +665 -0
- package/src/v2/components/chat/CopilotChat.tsx +193 -50
- package/src/v2/components/chat/CopilotChatAssistantMessage.tsx +17 -2
- package/src/v2/components/chat/CopilotChatAttachmentQueue.tsx +481 -0
- package/src/v2/components/chat/CopilotChatAttachmentRenderer.tsx +139 -0
- package/src/v2/components/chat/CopilotChatInput.tsx +146 -77
- package/src/v2/components/chat/CopilotChatMessageView.tsx +253 -149
- package/src/v2/components/chat/CopilotChatSuggestionView.tsx +1 -0
- package/src/v2/components/chat/CopilotChatUserMessage.tsx +54 -0
- package/src/v2/components/chat/CopilotChatView.tsx +179 -66
- package/src/v2/components/chat/__tests__/CopilotChat.attachments.test.tsx +168 -0
- package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.tsx +63 -2
- package/src/v2/components/chat/__tests__/CopilotChatInput.test.tsx +544 -1
- package/src/v2/components/chat/__tests__/CopilotChatPerf.e2e.test.tsx +268 -0
- package/src/v2/components/chat/__tests__/CopilotChatPropsRerender.e2e.test.tsx +249 -0
- package/src/v2/components/chat/__tests__/MCPAppsActivityRenderer.e2e.test.tsx +43 -2
- package/src/v2/components/chat/__tests__/copilot-chat-throttle.test.tsx +138 -0
- package/src/v2/components/chat/index.ts +9 -0
- package/src/v2/components/chat/scroll-element-context.ts +13 -0
- package/src/v2/hooks/__tests__/use-agent-throttle.test.tsx +1003 -0
- package/src/v2/hooks/__tests__/use-attachments.test.tsx +169 -0
- package/src/v2/hooks/__tests__/use-threads.test.tsx +54 -0
- package/src/v2/hooks/index.ts +5 -0
- package/src/v2/hooks/use-agent.tsx +95 -10
- package/src/v2/hooks/use-attachments.tsx +269 -0
- package/src/v2/hooks/use-frontend-tool.tsx +5 -2
- package/src/v2/hooks/use-render-activity-message.tsx +9 -2
- package/src/v2/hooks/use-threads.tsx +35 -15
- package/src/v2/index.ts +5 -1
- package/src/v2/lib/__tests__/processPartialHtml.test.ts +112 -0
- package/src/v2/lib/__tests__/slots.test.ts +56 -0
- package/src/v2/lib/processPartialHtml.ts +45 -0
- package/src/v2/lib/slots.tsx +42 -1
- package/src/v2/providers/CopilotChatConfigurationProvider.tsx +9 -3
- package/src/v2/providers/CopilotKitProvider.tsx +268 -32
- package/src/v2/providers/SandboxFunctionsContext.ts +10 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.sandboxFunctions.test.tsx +198 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.test.tsx +71 -0
- package/src/v2/providers/index.ts +7 -0
- package/src/v2/styles/globals.css +2 -1
- package/src/v2/types/index.ts +1 -0
- package/src/v2/types/sandbox-function.ts +11 -0
- package/dist/copilotkit-BDNjFNmk.cjs.map +0 -1
- package/dist/copilotkit-BqcyhQjT.d.mts.map +0 -1
- package/dist/copilotkit-DeOzjPsb.mjs.map +0 -1
- package/dist/copilotkit-l-IBF4Xp.d.cts.map +0 -1
- 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";
|
package/src/v2/types/index.ts
CHANGED
|
@@ -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
|
+
};
|