@copilotkit/react-core 1.55.0-next.8 → 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.
Files changed (94) hide show
  1. package/CHANGELOG.md +48 -5
  2. package/dist/{copilotkit-DNYSFuz5.mjs → copilotkit-BY5S1-0P.mjs} +2772 -858
  3. package/dist/copilotkit-BY5S1-0P.mjs.map +1 -0
  4. package/dist/{copilotkit-Dy5w3qEV.d.mts → copilotkit-BuhSUZHb.d.mts} +230 -17
  5. package/dist/copilotkit-BuhSUZHb.d.mts.map +1 -0
  6. package/dist/{copilotkit-B3Mb1yVE.cjs → copilotkit-Bz5-ImDl.cjs} +2776 -832
  7. package/dist/copilotkit-Bz5-ImDl.cjs.map +1 -0
  8. package/dist/{copilotkit-DBzgOMby.d.cts → copilotkit-dwDWYpya.d.cts} +230 -17
  9. package/dist/copilotkit-dwDWYpya.d.cts.map +1 -0
  10. package/dist/index.cjs +9 -4
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +1 -1
  13. package/dist/index.d.mts +1 -1
  14. package/dist/index.mjs +9 -4
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/index.umd.js +1624 -396
  17. package/dist/index.umd.js.map +1 -1
  18. package/dist/v2/index.cjs +13 -1
  19. package/dist/v2/index.css +1 -1
  20. package/dist/v2/index.d.cts +3 -3
  21. package/dist/v2/index.d.mts +3 -3
  22. package/dist/v2/index.mjs +3 -2
  23. package/dist/v2/index.umd.js +2746 -790
  24. package/dist/v2/index.umd.js.map +1 -1
  25. package/package.json +62 -54
  26. package/scripts/scope-preflight.mjs +1 -2
  27. package/src/components/CopilotListeners.tsx +41 -8
  28. package/src/components/copilot-provider/__tests__/copilot-messages-key.test.tsx +92 -0
  29. package/src/components/copilot-provider/copilotkit-props.tsx +4 -2
  30. package/src/components/copilot-provider/copilotkit.tsx +3 -3
  31. package/src/components/toast/toast-provider.tsx +269 -194
  32. package/src/hooks/__tests__/use-copilot-chat-internal-connect.test.tsx +27 -16
  33. package/src/hooks/use-copilot-chat_internal.ts +15 -4
  34. package/src/v2/__tests__/A2UIMessageRenderer.test.tsx +86 -22
  35. package/src/v2/__tests__/utils/test-helpers.tsx +107 -7
  36. package/src/v2/a2ui/A2UICatalogContext.tsx +79 -0
  37. package/src/v2/a2ui/A2UIMessageRenderer.tsx +125 -37
  38. package/src/v2/a2ui/A2UIToolCallRenderer.tsx +290 -0
  39. package/src/v2/components/CopilotKitInspector.tsx +2 -0
  40. package/src/v2/components/OpenGenerativeUIRenderer.tsx +598 -0
  41. package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.tsx +665 -0
  42. package/src/v2/components/chat/CopilotChat.tsx +197 -52
  43. package/src/v2/components/chat/CopilotChatAssistantMessage.tsx +17 -2
  44. package/src/v2/components/chat/CopilotChatAttachmentQueue.tsx +481 -0
  45. package/src/v2/components/chat/CopilotChatAttachmentRenderer.tsx +139 -0
  46. package/src/v2/components/chat/CopilotChatInput.tsx +146 -77
  47. package/src/v2/components/chat/CopilotChatMessageView.tsx +260 -151
  48. package/src/v2/components/chat/CopilotChatSuggestionView.tsx +1 -0
  49. package/src/v2/components/chat/CopilotChatUserMessage.tsx +54 -0
  50. package/src/v2/components/chat/CopilotChatView.tsx +179 -66
  51. package/src/v2/components/chat/__tests__/CopilotChat.attachments.test.tsx +168 -0
  52. package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.tsx +63 -2
  53. package/src/v2/components/chat/__tests__/CopilotChatInput.test.tsx +544 -1
  54. package/src/v2/components/chat/__tests__/CopilotChatPerf.e2e.test.tsx +268 -0
  55. package/src/v2/components/chat/__tests__/CopilotChatPropsRerender.e2e.test.tsx +249 -0
  56. package/src/v2/components/chat/__tests__/CopilotChatToolRendering.e2e.test.tsx +5 -2
  57. package/src/v2/components/chat/__tests__/CopilotChatToolRerenders.e2e.test.tsx +5 -2
  58. package/src/v2/components/chat/__tests__/MCPAppsActivityRenderer.e2e.test.tsx +60 -3
  59. package/src/v2/components/chat/__tests__/copilot-chat-throttle.test.tsx +138 -0
  60. package/src/v2/components/chat/index.ts +9 -0
  61. package/src/v2/components/chat/scroll-element-context.ts +13 -0
  62. package/src/v2/hooks/__tests__/use-agent-context-timing.e2e.test.tsx +8 -0
  63. package/src/v2/hooks/__tests__/use-agent-thread-isolation.test.tsx +327 -0
  64. package/src/v2/hooks/__tests__/use-agent-throttle.test.tsx +1003 -0
  65. package/src/v2/hooks/__tests__/use-agent.e2e.test.tsx +13 -2
  66. package/src/v2/hooks/__tests__/use-attachments.test.tsx +169 -0
  67. package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.tsx +23 -4
  68. package/src/v2/hooks/__tests__/use-threads.test.tsx +54 -0
  69. package/src/v2/hooks/index.ts +5 -0
  70. package/src/v2/hooks/use-agent.tsx +220 -15
  71. package/src/v2/hooks/use-attachments.tsx +269 -0
  72. package/src/v2/hooks/use-frontend-tool.tsx +5 -2
  73. package/src/v2/hooks/use-render-activity-message.tsx +9 -2
  74. package/src/v2/hooks/use-render-custom-messages.tsx +6 -1
  75. package/src/v2/hooks/use-threads.tsx +35 -15
  76. package/src/v2/index.ts +5 -1
  77. package/src/v2/lib/__tests__/processPartialHtml.test.ts +112 -0
  78. package/src/v2/lib/__tests__/slots.test.ts +56 -0
  79. package/src/v2/lib/processPartialHtml.ts +45 -0
  80. package/src/v2/lib/slots.tsx +42 -1
  81. package/src/v2/providers/CopilotChatConfigurationProvider.tsx +9 -3
  82. package/src/v2/providers/CopilotKitProvider.tsx +268 -32
  83. package/src/v2/providers/SandboxFunctionsContext.ts +10 -0
  84. package/src/v2/providers/__tests__/CopilotKitProvider.sandboxFunctions.test.tsx +198 -0
  85. package/src/v2/providers/__tests__/CopilotKitProvider.test.tsx +71 -0
  86. package/src/v2/providers/index.ts +7 -0
  87. package/src/v2/styles/globals.css +2 -1
  88. package/src/v2/types/index.ts +1 -0
  89. package/src/v2/types/sandbox-function.ts +11 -0
  90. package/dist/copilotkit-B3Mb1yVE.cjs.map +0 -1
  91. package/dist/copilotkit-DBzgOMby.d.cts.map +0 -1
  92. package/dist/copilotkit-DNYSFuz5.mjs.map +0 -1
  93. package/dist/copilotkit-Dy5w3qEV.d.mts.map +0 -1
  94. package/src/v2/components/__tests__/license-warning-banner.test.tsx +0 -46
package/package.json CHANGED
@@ -1,21 +1,41 @@
1
1
  {
2
2
  "name": "@copilotkit/react-core",
3
+ "version": "1.55.0",
3
4
  "private": false,
5
+ "keywords": [
6
+ "ai",
7
+ "assistant",
8
+ "automation",
9
+ "copilot",
10
+ "copilotkit",
11
+ "javascript",
12
+ "nextjs",
13
+ "nodejs",
14
+ "react",
15
+ "textarea"
16
+ ],
4
17
  "homepage": "https://github.com/CopilotKit/CopilotKit",
18
+ "license": "MIT",
5
19
  "repository": {
6
20
  "type": "git",
7
21
  "url": "https://github.com/CopilotKit/CopilotKit.git"
8
22
  },
9
23
  "type": "module",
10
- "publishConfig": {
11
- "access": "public"
12
- },
13
- "version": "1.55.0-next.8",
14
24
  "sideEffects": [
15
25
  "**/*.css"
16
26
  ],
17
27
  "main": "./dist/index.cjs",
18
28
  "module": "./dist/index.mjs",
29
+ "types": "./dist/index.d.cts",
30
+ "typesVersions": {
31
+ "*": {
32
+ "v2": [
33
+ "./dist/v2/index.d.cts"
34
+ ]
35
+ }
36
+ },
37
+ "unpkg": "./dist/index.umd.js",
38
+ "jsdelivr": "./dist/index.umd.js",
19
39
  "exports": {
20
40
  ".": {
21
41
  "import": "./dist/index.mjs",
@@ -28,28 +48,49 @@
28
48
  "./package.json": "./package.json",
29
49
  "./v2/styles.css": "./dist/v2/index.css"
30
50
  },
31
- "unpkg": "./dist/index.umd.js",
32
- "jsdelivr": "./dist/index.umd.js",
33
- "types": "./dist/index.d.cts",
34
- "license": "MIT",
35
- "peerDependencies": {
36
- "react": "^18 || ^19 || ^19.0.0-rc",
37
- "react-dom": "^18 || ^19 || ^19.0.0-rc",
38
- "zod": ">=3.0.0"
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "dependencies": {
55
+ "@ag-ui/client": "0.0.52",
56
+ "@ag-ui/core": "0.0.52",
57
+ "@jetbrains/websandbox": "^1.1.3",
58
+ "@lit-labs/react": "^2.0.2",
59
+ "@radix-ui/react-dropdown-menu": "^2.1.15",
60
+ "@radix-ui/react-slot": "^1.2.3",
61
+ "@radix-ui/react-tooltip": "^1.2.7",
62
+ "@scarf/scarf": "^1.3.0",
63
+ "@tanstack/react-virtual": "^3.13.0",
64
+ "class-variance-authority": "^0.7.1",
65
+ "clsx": "^2.1.1",
66
+ "katex": "^0.16.22",
67
+ "lucide-react": "^0.525.0",
68
+ "react-markdown": "^8.0.7",
69
+ "rxjs": "7.8.1",
70
+ "streamdown": "^1.3.0",
71
+ "tailwind-merge": "^3.3.1",
72
+ "tw-animate-css": "^1.3.5",
73
+ "untruncate-json": "^0.0.1",
74
+ "use-stick-to-bottom": "^1.1.1",
75
+ "zod-to-json-schema": "^3.24.5",
76
+ "@copilotkit/a2ui-renderer": "1.55.0",
77
+ "@copilotkit/core": "1.55.0",
78
+ "@copilotkit/runtime-client-gql": "1.55.0",
79
+ "@copilotkit/shared": "1.55.0",
80
+ "@copilotkit/web-inspector": "1.55.0"
39
81
  },
40
82
  "devDependencies": {
41
83
  "@tailwindcss/cli": "^4.1.11",
42
84
  "@tailwindcss/postcss": "^4.1.11",
43
85
  "@tailwindcss/typography": "^0.5.16",
44
- "@valibot/to-json-schema": "^1.5.0",
45
- "tailwindcss": "^4.0.8",
46
86
  "@testing-library/jest-dom": "^6.0.0",
47
87
  "@testing-library/react": "^16.3.0",
48
88
  "@testing-library/react-hooks": "^8.0.1",
49
89
  "@testing-library/user-event": "^14.0.0",
50
- "arktype": "^2.1.29",
51
90
  "@types/react": "^19.1.0",
52
91
  "@types/react-dom": "^19.0.2",
92
+ "@valibot/to-json-schema": "^1.5.0",
93
+ "arktype": "^2.1.29",
53
94
  "autoprefixer": "^10.4.20",
54
95
  "concurrently": "^9.1.0",
55
96
  "eslint": "^8.56.0",
@@ -58,52 +99,19 @@
58
99
  "postcss": "^8.5.6",
59
100
  "react": "^19.1.0",
60
101
  "react-dom": "^19.2.0",
61
- "vitest": "^3.2.4",
102
+ "tailwindcss": "^4.0.8",
62
103
  "tsdown": "^0.20.3",
63
104
  "typescript": "^5.2.3",
64
105
  "valibot": "^1.2.0",
106
+ "vitest": "^3.2.4",
65
107
  "zod": ">=3.0.0",
66
- "eslint-config-custom": "1.4.12",
67
108
  "tsconfig": "1.4.12"
68
109
  },
69
- "dependencies": {
70
- "@ag-ui/client": "^0.0.48",
71
- "@ag-ui/core": "0.0.48",
72
- "@lit-labs/react": "^2.0.2",
73
- "@radix-ui/react-dropdown-menu": "^2.1.15",
74
- "@radix-ui/react-slot": "^1.2.3",
75
- "@radix-ui/react-tooltip": "^1.2.7",
76
- "@scarf/scarf": "^1.3.0",
77
- "class-variance-authority": "^0.7.1",
78
- "clsx": "^2.1.1",
79
- "katex": "^0.16.22",
80
- "lucide-react": "^0.525.0",
81
- "react-markdown": "^8.0.7",
82
- "streamdown": "^1.3.0",
83
- "tailwind-merge": "^3.3.1",
84
- "ts-deepmerge": "^7.0.3",
85
- "tw-animate-css": "^1.3.5",
86
- "untruncate-json": "^0.0.1",
87
- "use-stick-to-bottom": "^1.1.1",
88
- "rxjs": "7.8.1",
89
- "@copilotkit/a2ui-renderer": "1.55.0-next.8",
90
- "@copilotkit/core": "1.55.0-next.8",
91
- "@copilotkit/runtime-client-gql": "1.55.0-next.8",
92
- "@copilotkit/shared": "1.55.0-next.8",
93
- "@copilotkit/web-inspector": "1.55.0-next.8"
110
+ "peerDependencies": {
111
+ "react": "^18 || ^19 || ^19.0.0-rc",
112
+ "react-dom": "^18 || ^19 || ^19.0.0-rc",
113
+ "zod": ">=3.0.0"
94
114
  },
95
- "keywords": [
96
- "copilotkit",
97
- "copilot",
98
- "react",
99
- "nextjs",
100
- "nodejs",
101
- "ai",
102
- "assistant",
103
- "javascript",
104
- "automation",
105
- "textarea"
106
- ],
107
115
  "scripts": {
108
116
  "build:css": "tailwindcss -i ./src/v2/styles/globals.css -o ./dist/v2/index.css -m && node scripts/scope-preflight.mjs ./dist/v2/index.css",
109
117
  "build": "tsdown && pnpm run build:css",
@@ -19,8 +19,7 @@ if (!file) {
19
19
  /** Selectors that are already scoped and should be left alone. */
20
20
  function isAlreadyScoped(selector) {
21
21
  return (
22
- selector.includes("[data-copilot") ||
23
- selector.includes("[data-sidebar")
22
+ selector.includes("[data-copilot") || selector.includes("[data-sidebar")
24
23
  );
25
24
  }
26
25
 
@@ -72,14 +72,47 @@ export function CopilotListeners() {
72
72
 
73
73
  useEffect(() => {
74
74
  const subscriber: CopilotKitCoreSubscriber = {
75
- onError: ({ error }) => {
76
- setBannerError(
77
- new CopilotKitLowLevelError({
78
- error,
79
- message: error.message,
80
- url: typeof window !== "undefined" ? window.location.href : "",
81
- }),
82
- );
75
+ onError: ({ error, code, context }) => {
76
+ // Silently ignore abort errors (e.g. from navigation during active requests)
77
+ if (
78
+ error.name === "AbortError" ||
79
+ error.message === "Fetch is aborted" ||
80
+ error.message === "signal is aborted without reason" ||
81
+ error.message === "component unmounted" ||
82
+ !error.message
83
+ ) {
84
+ return;
85
+ }
86
+
87
+ // Always log full error details in development
88
+ if (process.env.NODE_ENV === "development") {
89
+ console.error(
90
+ "[CopilotKit] Agent error:",
91
+ error.message,
92
+ "\n Code:",
93
+ code,
94
+ "\n Context:",
95
+ context,
96
+ "\n Stack:",
97
+ error.stack,
98
+ );
99
+ }
100
+
101
+ const ckError = new CopilotKitLowLevelError({
102
+ error,
103
+ message: error.message,
104
+ url: typeof window !== "undefined" ? window.location.href : "",
105
+ });
106
+
107
+ // Attach original error details for the banner to display
108
+ (ckError as any).details = {
109
+ code,
110
+ context,
111
+ stack: error.stack,
112
+ originalMessage: error.message,
113
+ };
114
+
115
+ setBannerError(ckError);
83
116
  },
84
117
  };
85
118
  const subscription = copilotkit.subscribe(subscriber);
@@ -0,0 +1,92 @@
1
+ import { render } from "@testing-library/react";
2
+ import React from "react";
3
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
4
+
5
+ /**
6
+ * Regression test: CopilotMessages children must have React keys.
7
+ *
8
+ * When CopilotMessages receives multiple children (e.g. memoizedChildren +
9
+ * RegisteredActionsRenderer), React treats them as a dynamic list and warns
10
+ * if they lack keys. This test verifies the fix by rendering a minimal
11
+ * reproduction using the same pattern as CopilotKitInternal.
12
+ */
13
+
14
+ // Minimal stand-in for CopilotMessages – renders children inside a provider-like wrapper.
15
+ function CopilotMessages({ children }: { children: React.ReactNode }) {
16
+ const memoized = React.useMemo(() => children, [children]);
17
+ return <div data-testid="messages">{memoized}</div>;
18
+ }
19
+
20
+ describe("CopilotMessages children keys", () => {
21
+ let consoleErrorSpy: ReturnType<typeof vi.spyOn>;
22
+ const keyWarnings: string[] = [];
23
+
24
+ beforeEach(() => {
25
+ keyWarnings.length = 0;
26
+ consoleErrorSpy = vi
27
+ .spyOn(console, "error")
28
+ .mockImplementation((...args: any[]) => {
29
+ const msg = args.map(String).join(" ");
30
+ if (
31
+ msg.includes('unique "key" prop') ||
32
+ msg.includes("unique 'key' prop") ||
33
+ msg.includes("unique key")
34
+ ) {
35
+ keyWarnings.push(msg);
36
+ }
37
+ });
38
+ });
39
+
40
+ afterEach(() => {
41
+ consoleErrorSpy.mockRestore();
42
+ });
43
+
44
+ it("warns about missing keys when children array lacks keys (pre-fix pattern)", () => {
45
+ const ChildA = () => <div>app content</div>;
46
+ const ChildB = () => <span>actions</span>;
47
+
48
+ // Passing an explicit array as children – this is what JSX compiles to
49
+ // when you write: <CopilotMessages>{memoizedChildren}<RegisteredActionsRenderer /></CopilotMessages>
50
+ // React sees: { children: [memoizedChildren, <RegisteredActionsRenderer />] }
51
+ render(<CopilotMessages>{[<ChildA />, <ChildB />]}</CopilotMessages>);
52
+
53
+ expect(keyWarnings.length).toBeGreaterThan(0);
54
+ });
55
+
56
+ it("does NOT warn when children array elements have keys (post-fix pattern)", () => {
57
+ const ChildA = () => <div>app content</div>;
58
+ const ChildB = () => <span>actions</span>;
59
+
60
+ // The fix: wrap in keyed elements
61
+ render(
62
+ <CopilotMessages>
63
+ {[
64
+ <React.Fragment key="children">
65
+ <ChildA />
66
+ </React.Fragment>,
67
+ <ChildB key="actions" />,
68
+ ]}
69
+ </CopilotMessages>,
70
+ );
71
+
72
+ expect(keyWarnings).toHaveLength(0);
73
+ });
74
+
75
+ it("does NOT warn with the actual fix pattern (keyed JSX children)", () => {
76
+ const MemoChildren = React.memo(() => <div>app content</div>);
77
+ MemoChildren.displayName = "MemoChildren";
78
+ const RegisteredActionsRenderer = React.memo(() => null);
79
+ RegisteredActionsRenderer.displayName = "RegisteredActionsRenderer";
80
+
81
+ render(
82
+ <CopilotMessages>
83
+ <React.Fragment key="children">
84
+ <MemoChildren />
85
+ </React.Fragment>
86
+ <RegisteredActionsRenderer key="actions" />
87
+ </CopilotMessages>,
88
+ );
89
+
90
+ expect(keyWarnings).toHaveLength(0);
91
+ });
92
+ });
@@ -129,9 +129,11 @@ export interface CopilotKitProps extends Omit<
129
129
  credentials?: RequestCredentials;
130
130
 
131
131
  /**
132
- * Whether to show the dev console.
132
+ * Whether to show the dev console (error banners and toasts).
133
133
  *
134
- * Set to `true` to show error banners and toasts, `false` to hide all error UI.
134
+ * @deprecated Use `enableInspector` to control the AG-UI inspector,
135
+ * which is what most users want. `showDevConsole` only controls
136
+ * error toasts/banners, not the inspector button.
135
137
  * Defaults to `false` for production safety.
136
138
  */
137
139
  showDevConsole?: boolean;
@@ -14,7 +14,7 @@
14
14
  * ```
15
15
  */
16
16
 
17
- import {
17
+ import React, {
18
18
  useCallback,
19
19
  useEffect,
20
20
  useMemo,
@@ -761,8 +761,8 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
761
761
  <CoAgentStateRendersProvider>
762
762
  <MessagesTapProvider>
763
763
  <CopilotMessages>
764
- {memoizedChildren}
765
- <RegisteredActionsRenderer />
764
+ <React.Fragment key="children">{memoizedChildren}</React.Fragment>
765
+ <RegisteredActionsRenderer key="actions" />
766
766
  </CopilotMessages>
767
767
  </MessagesTapProvider>
768
768
  {bannerError && showDevConsole && (