@copilotkit/react-core 1.54.1 → 1.55.0-next.8

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 (183) hide show
  1. package/CHANGELOG.md +127 -116
  2. package/dist/copilotkit-B3Mb1yVE.cjs +7975 -0
  3. package/dist/copilotkit-B3Mb1yVE.cjs.map +1 -0
  4. package/dist/copilotkit-DBzgOMby.d.cts +2182 -0
  5. package/dist/copilotkit-DBzgOMby.d.cts.map +1 -0
  6. package/dist/copilotkit-DNYSFuz5.mjs +7562 -0
  7. package/dist/copilotkit-DNYSFuz5.mjs.map +1 -0
  8. package/dist/copilotkit-Dy5w3qEV.d.mts +2182 -0
  9. package/dist/copilotkit-Dy5w3qEV.d.mts.map +1 -0
  10. package/dist/index.cjs +27 -28
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +3 -3
  13. package/dist/index.d.cts.map +1 -1
  14. package/dist/index.d.mts +3 -3
  15. package/dist/index.d.mts.map +1 -1
  16. package/dist/index.mjs +4 -5
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/index.umd.js +1941 -35
  19. package/dist/index.umd.js.map +1 -1
  20. package/dist/v2/index.cjs +77 -7
  21. package/dist/v2/index.css +1 -2
  22. package/dist/v2/index.d.cts +6 -4
  23. package/dist/v2/index.d.mts +6 -4
  24. package/dist/v2/index.mjs +7 -4
  25. package/dist/v2/index.umd.js +5725 -24
  26. package/dist/v2/index.umd.js.map +1 -1
  27. package/package.json +37 -9
  28. package/scripts/scope-preflight.mjs +101 -0
  29. package/src/components/CopilotListeners.tsx +2 -6
  30. package/src/components/copilot-provider/copilot-messages.tsx +1 -1
  31. package/src/components/copilot-provider/copilotkit-props.tsx +1 -1
  32. package/src/components/copilot-provider/copilotkit.tsx +4 -4
  33. package/src/context/copilot-messages-context.tsx +1 -1
  34. package/src/hooks/__tests__/use-coagent-config.test.ts +2 -2
  35. package/src/hooks/__tests__/use-coagent-state-render.e2e.test.tsx +2 -2
  36. package/src/hooks/__tests__/use-copilot-chat-internal-connect.test.tsx +3 -7
  37. package/src/hooks/__tests__/use-frontend-tool-available.test.tsx +1 -1
  38. package/src/hooks/__tests__/use-frontend-tool-remount.e2e.test.tsx +4 -4
  39. package/src/hooks/use-agent-nodename.ts +1 -1
  40. package/src/hooks/use-coagent-state-render-bridge.tsx +1 -4
  41. package/src/hooks/use-coagent.ts +1 -1
  42. package/src/hooks/use-configure-chat-suggestions.tsx +2 -2
  43. package/src/hooks/use-copilot-chat-suggestions.tsx +2 -2
  44. package/src/hooks/use-copilot-chat_internal.ts +2 -2
  45. package/src/hooks/use-copilot-readable.ts +1 -1
  46. package/src/hooks/use-frontend-tool.ts +2 -2
  47. package/src/hooks/use-human-in-the-loop.ts +2 -2
  48. package/src/hooks/use-langgraph-interrupt.ts +2 -5
  49. package/src/hooks/use-lazy-tool-renderer.tsx +1 -1
  50. package/src/hooks/use-render-tool-call.ts +1 -1
  51. package/src/lib/copilot-task.ts +1 -1
  52. package/src/setupTests.ts +18 -14
  53. package/src/v2/__tests__/A2UIMessageRenderer.test.tsx +176 -0
  54. package/src/v2/__tests__/globalSetup.ts +14 -0
  55. package/src/v2/__tests__/setup.ts +93 -0
  56. package/src/v2/__tests__/utils/test-helpers.tsx +470 -0
  57. package/src/v2/a2ui/A2UIMessageRenderer.tsx +206 -0
  58. package/src/v2/components/CopilotKitInspector.tsx +50 -0
  59. package/src/v2/components/MCPAppsActivityRenderer.tsx +785 -0
  60. package/src/v2/components/WildcardToolCallRender.tsx +86 -0
  61. package/src/v2/components/__tests__/license-warning-banner.test.tsx +46 -0
  62. package/src/v2/components/chat/CopilotChat.tsx +431 -0
  63. package/src/v2/components/chat/CopilotChatAssistantMessage.tsx +375 -0
  64. package/src/v2/components/chat/CopilotChatAudioRecorder.tsx +350 -0
  65. package/src/v2/components/chat/CopilotChatInput.tsx +1302 -0
  66. package/src/v2/components/chat/CopilotChatMessageView.tsx +556 -0
  67. package/src/v2/components/chat/CopilotChatReasoningMessage.tsx +252 -0
  68. package/src/v2/components/chat/CopilotChatSuggestionPill.tsx +59 -0
  69. package/src/v2/components/chat/CopilotChatSuggestionView.tsx +133 -0
  70. package/src/v2/components/chat/CopilotChatToggleButton.tsx +171 -0
  71. package/src/v2/components/chat/CopilotChatToolCallsView.tsx +40 -0
  72. package/src/v2/components/chat/CopilotChatUserMessage.tsx +388 -0
  73. package/src/v2/components/chat/CopilotChatView.tsx +598 -0
  74. package/src/v2/components/chat/CopilotModalHeader.tsx +129 -0
  75. package/src/v2/components/chat/CopilotPopup.tsx +81 -0
  76. package/src/v2/components/chat/CopilotPopupView.tsx +317 -0
  77. package/src/v2/components/chat/CopilotSidebar.tsx +76 -0
  78. package/src/v2/components/chat/CopilotSidebarView.tsx +255 -0
  79. package/src/v2/components/chat/__tests__/CopilotChat.e2e.test.tsx +1113 -0
  80. package/src/v2/components/chat/__tests__/CopilotChat.onError.test.tsx +73 -0
  81. package/src/v2/components/chat/__tests__/CopilotChat.slots.e2e.test.tsx +432 -0
  82. package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.tsx +150 -0
  83. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.slots.e2e.test.tsx +624 -0
  84. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.tsx +702 -0
  85. package/src/v2/components/chat/__tests__/CopilotChatCssClasses.test.tsx +107 -0
  86. package/src/v2/components/chat/__tests__/CopilotChatInput.slots.e2e.test.tsx +929 -0
  87. package/src/v2/components/chat/__tests__/CopilotChatInput.test.tsx +986 -0
  88. package/src/v2/components/chat/__tests__/CopilotChatMessageView.slots.e2e.test.tsx +1004 -0
  89. package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.tsx +169 -0
  90. package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.slots.e2e.test.tsx +530 -0
  91. package/src/v2/components/chat/__tests__/CopilotChatToolRendering.e2e.test.tsx +782 -0
  92. package/src/v2/components/chat/__tests__/CopilotChatToolRerenders.e2e.test.tsx +2413 -0
  93. package/src/v2/components/chat/__tests__/CopilotChatUserMessage.slots.e2e.test.tsx +621 -0
  94. package/src/v2/components/chat/__tests__/CopilotChatView.onClick.e2e.test.tsx +853 -0
  95. package/src/v2/components/chat/__tests__/CopilotChatView.slots.e2e.test.tsx +1050 -0
  96. package/src/v2/components/chat/__tests__/CopilotModalHeader.slots.e2e.test.tsx +484 -0
  97. package/src/v2/components/chat/__tests__/CopilotPopupView.slots.e2e.test.tsx +612 -0
  98. package/src/v2/components/chat/__tests__/CopilotSidebarView.slots.e2e.test.tsx +502 -0
  99. package/src/v2/components/chat/__tests__/MCPAppsActivityRenderer.e2e.test.tsx +1011 -0
  100. package/src/v2/components/chat/__tests__/setup.ts +1 -0
  101. package/src/v2/components/chat/index.ts +79 -0
  102. package/src/v2/components/index.ts +7 -0
  103. package/src/v2/components/license-warning-banner.tsx +198 -0
  104. package/src/v2/components/ui/button.tsx +123 -0
  105. package/src/v2/components/ui/dropdown-menu.tsx +258 -0
  106. package/src/v2/components/ui/tooltip.tsx +60 -0
  107. package/src/v2/hooks/__tests__/standard-schema-types.test.tsx +152 -0
  108. package/src/v2/hooks/__tests__/standard-schema.test.tsx +282 -0
  109. package/src/v2/hooks/__tests__/use-agent-context-timing.e2e.test.tsx +132 -0
  110. package/src/v2/hooks/__tests__/use-agent-context.test.tsx +401 -0
  111. package/src/v2/hooks/__tests__/use-agent-error-state.test.tsx +44 -0
  112. package/src/v2/hooks/__tests__/use-agent-stability.test.tsx +205 -0
  113. package/src/v2/hooks/__tests__/use-agent.e2e.test.tsx +148 -0
  114. package/src/v2/hooks/__tests__/use-component.test.tsx +123 -0
  115. package/src/v2/hooks/__tests__/use-configure-suggestions.e2e.test.tsx +696 -0
  116. package/src/v2/hooks/__tests__/use-default-render-tool.test.tsx +153 -0
  117. package/src/v2/hooks/__tests__/use-frontend-tool-available.test.tsx +167 -0
  118. package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.tsx +2129 -0
  119. package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.tsx +1261 -0
  120. package/src/v2/hooks/__tests__/use-interrupt.test.tsx +397 -0
  121. package/src/v2/hooks/__tests__/use-katex-styles.test.tsx +56 -0
  122. package/src/v2/hooks/__tests__/use-keyboard-height.test.tsx +192 -0
  123. package/src/v2/hooks/__tests__/use-render-tool.test.tsx +259 -0
  124. package/src/v2/hooks/__tests__/use-suggestions.e2e.test.tsx +524 -0
  125. package/src/v2/hooks/__tests__/use-threads.test.tsx +433 -0
  126. package/src/v2/hooks/__tests__/zod-regression.test.tsx +311 -0
  127. package/src/v2/hooks/index.ts +18 -0
  128. package/src/v2/hooks/use-agent-context.tsx +45 -0
  129. package/src/v2/hooks/use-agent.tsx +155 -0
  130. package/src/v2/hooks/use-component.tsx +89 -0
  131. package/src/v2/hooks/use-configure-suggestions.tsx +187 -0
  132. package/src/v2/hooks/use-default-render-tool.tsx +254 -0
  133. package/src/v2/hooks/use-frontend-tool.tsx +43 -0
  134. package/src/v2/hooks/use-human-in-the-loop.tsx +81 -0
  135. package/src/v2/hooks/use-interrupt.tsx +305 -0
  136. package/src/v2/hooks/use-keyboard-height.tsx +67 -0
  137. package/src/v2/hooks/use-render-activity-message.tsx +73 -0
  138. package/src/v2/hooks/use-render-custom-messages.tsx +93 -0
  139. package/src/v2/hooks/use-render-tool-call.tsx +175 -0
  140. package/src/v2/hooks/use-render-tool.tsx +181 -0
  141. package/src/v2/hooks/use-suggestions.tsx +91 -0
  142. package/src/v2/hooks/use-threads.tsx +256 -0
  143. package/src/v2/hooks/useKatexStyles.ts +27 -0
  144. package/src/v2/index.css +1 -1
  145. package/src/v2/index.ts +18 -2
  146. package/src/v2/lib/__tests__/completePartialMarkdown.test.ts +495 -0
  147. package/src/v2/lib/__tests__/renderSlot.test.tsx +588 -0
  148. package/src/v2/lib/react-core.ts +156 -0
  149. package/src/v2/lib/slots.tsx +143 -0
  150. package/src/v2/lib/transcription-client.ts +184 -0
  151. package/src/v2/lib/utils.ts +8 -0
  152. package/src/v2/providers/CopilotChatConfigurationProvider.tsx +162 -0
  153. package/src/v2/providers/CopilotKitProvider.tsx +600 -0
  154. package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.tsx +546 -0
  155. package/src/v2/providers/__tests__/CopilotKitProvider.license.test.tsx +101 -0
  156. package/src/v2/providers/__tests__/CopilotKitProvider.onError.test.tsx +69 -0
  157. package/src/v2/providers/__tests__/CopilotKitProvider.renderCustomMessages.e2e.test.tsx +881 -0
  158. package/src/v2/providers/__tests__/CopilotKitProvider.stability.test.tsx +740 -0
  159. package/src/v2/providers/__tests__/CopilotKitProvider.test.tsx +642 -0
  160. package/src/v2/providers/__tests__/CopilotKitProvider.wildcard.test.tsx +294 -0
  161. package/src/v2/providers/index.ts +14 -0
  162. package/src/v2/styles/globals.css +230 -0
  163. package/src/v2/types/__tests__/defineToolCallRenderer.test.tsx +525 -0
  164. package/src/v2/types/defineToolCallRenderer.ts +65 -0
  165. package/src/v2/types/frontend-tool.ts +8 -0
  166. package/src/v2/types/human-in-the-loop.ts +33 -0
  167. package/src/v2/types/index.ts +7 -0
  168. package/src/v2/types/interrupt.ts +15 -0
  169. package/src/v2/types/react-activity-message-renderer.ts +27 -0
  170. package/src/v2/types/react-custom-message-renderer.ts +17 -0
  171. package/src/v2/types/react-tool-call-renderer.ts +32 -0
  172. package/tsdown.config.ts +34 -10
  173. package/vitest.config.mjs +4 -3
  174. package/LICENSE +0 -21
  175. package/dist/copilotkit-BRPQ2sqS.d.cts +0 -670
  176. package/dist/copilotkit-BRPQ2sqS.d.cts.map +0 -1
  177. package/dist/copilotkit-C94ayZbs.cjs +0 -2161
  178. package/dist/copilotkit-C94ayZbs.cjs.map +0 -1
  179. package/dist/copilotkit-CwZMFmSK.d.mts +0 -670
  180. package/dist/copilotkit-CwZMFmSK.d.mts.map +0 -1
  181. package/dist/copilotkit-Yh_Ld_FX.mjs +0 -2031
  182. package/dist/copilotkit-Yh_Ld_FX.mjs.map +0 -1
  183. package/dist/v2/index.css.map +0 -1
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
- "version": "1.54.1",
13
+ "version": "1.55.0-next.8",
14
14
  "sideEffects": [
15
15
  "**/*.css"
16
16
  ],
@@ -39,30 +39,58 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@tailwindcss/cli": "^4.1.11",
42
+ "@tailwindcss/postcss": "^4.1.11",
43
+ "@tailwindcss/typography": "^0.5.16",
44
+ "@valibot/to-json-schema": "^1.5.0",
45
+ "tailwindcss": "^4.0.8",
46
+ "@testing-library/jest-dom": "^6.0.0",
42
47
  "@testing-library/react": "^16.3.0",
43
48
  "@testing-library/react-hooks": "^8.0.1",
49
+ "@testing-library/user-event": "^14.0.0",
50
+ "arktype": "^2.1.29",
44
51
  "@types/react": "^19.1.0",
45
52
  "@types/react-dom": "^19.0.2",
53
+ "autoprefixer": "^10.4.20",
54
+ "concurrently": "^9.1.0",
46
55
  "eslint": "^8.56.0",
47
56
  "jsdom": "^26.1.0",
57
+ "phoenix": "^1.8.4",
58
+ "postcss": "^8.5.6",
48
59
  "react": "^19.1.0",
49
60
  "react-dom": "^19.2.0",
50
61
  "vitest": "^3.2.4",
51
62
  "tsdown": "^0.20.3",
52
63
  "typescript": "^5.2.3",
64
+ "valibot": "^1.2.0",
53
65
  "zod": ">=3.0.0",
54
- "eslint-config-custom": "1.4.13",
55
- "tsconfig": "1.4.13"
66
+ "eslint-config-custom": "1.4.12",
67
+ "tsconfig": "1.4.12"
56
68
  },
57
69
  "dependencies": {
58
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",
59
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",
60
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",
61
86
  "untruncate-json": "^0.0.1",
62
- "@copilotkit/runtime-client-gql": "1.54.1",
63
- "@copilotkit/shared": "1.54.1",
64
- "@copilotkitnext/core": "1.54.1",
65
- "@copilotkitnext/react": "1.54.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"
66
94
  },
67
95
  "keywords": [
68
96
  "copilotkit",
@@ -77,7 +105,7 @@
77
105
  "textarea"
78
106
  ],
79
107
  "scripts": {
80
- "build:css": "tailwindcss -i ./src/v2/index.css -o ./dist/v2/index.css -m",
108
+ "build:css": "tailwindcss -i ./src/v2/styles/globals.css -o ./dist/v2/index.css -m && node scripts/scope-preflight.mjs ./dist/v2/index.css",
81
109
  "build": "tsdown && pnpm run build:css",
82
110
  "dev": "tsdown --watch",
83
111
  "test": "vitest run",
@@ -86,6 +114,6 @@
86
114
  "link:global": "pnpm link --global",
87
115
  "unlink:global": "pnpm unlink --global",
88
116
  "publint": "publint .",
89
- "attw": "attw --pack . --profile node16"
117
+ "attw": "attw --pack . --profile node16 --ignore-rules internal-resolution-error"
90
118
  }
91
119
  }
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Post-processes compiled Tailwind CSS to scope all @layer base rules
3
+ * under [data-copilotkit], preventing CopilotKit styles from leaking
4
+ * into the host application.
5
+ *
6
+ * Run after `tailwindcss` CLI: node scripts/scope-preflight.mjs <file>
7
+ */
8
+
9
+ import { readFileSync, writeFileSync } from "fs";
10
+ import postcss from "postcss";
11
+
12
+ const SCOPE = "[data-copilotkit]";
13
+ const file = process.argv[2];
14
+ if (!file) {
15
+ console.error("Usage: node scripts/scope-preflight.mjs <css-file>");
16
+ process.exit(1);
17
+ }
18
+
19
+ /** Selectors that are already scoped and should be left alone. */
20
+ function isAlreadyScoped(selector) {
21
+ return (
22
+ selector.includes("[data-copilot") ||
23
+ selector.includes("[data-sidebar")
24
+ );
25
+ }
26
+
27
+ /** Rewrite a single selector to be scoped under [data-copilotkit]. */
28
+ function scopeSelector(sel) {
29
+ sel = sel.trim();
30
+
31
+ // Already scoped — keep as-is
32
+ if (isAlreadyScoped(sel)) return sel;
33
+
34
+ // html, :host → [data-copilotkit]
35
+ if (sel === "html" || sel === ":host" || sel === "html,:host") {
36
+ return SCOPE;
37
+ }
38
+
39
+ // body → null (remove)
40
+ if (sel === "body") return null;
41
+
42
+ // ::backdrop → null (cannot be scoped to a container)
43
+ if (sel === "::backdrop") return null;
44
+
45
+ // Bare universal selector → scope to container + descendants
46
+ if (sel === "*") return `${SCOPE}, ${SCOPE} *`;
47
+
48
+ // Pseudo-elements (::) and vendor pseudo-classes (:-) → descendant only
49
+ // These can't be combined with an attribute selector suffix
50
+ if (sel.startsWith(":")) {
51
+ return `${SCOPE} ${sel}`;
52
+ }
53
+
54
+ // Element / attribute selectors → descendant AND self-matching
55
+ // e.g. button → [data-copilotkit] button, button[data-copilotkit]
56
+ // This ensures <button data-copilotkit> also receives the preflight reset
57
+ return `${SCOPE} ${sel}, ${sel}${SCOPE}`;
58
+ }
59
+
60
+ function scopeRule(rule) {
61
+ const newSelectors = [];
62
+
63
+ for (const sel of rule.selectors) {
64
+ const scoped = scopeSelector(sel);
65
+ if (scoped !== null) {
66
+ // scopeSelector may return comma-separated selectors (for *)
67
+ if (typeof scoped === "string" && scoped.includes(", ")) {
68
+ newSelectors.push(...scoped.split(", "));
69
+ } else if (scoped) {
70
+ newSelectors.push(scoped);
71
+ }
72
+ }
73
+ }
74
+
75
+ if (newSelectors.length === 0) {
76
+ rule.remove();
77
+ } else {
78
+ rule.selectors = newSelectors;
79
+ }
80
+ }
81
+
82
+ /** Recursively scope all rules within a node (handles @supports, @media, etc.) */
83
+ function scopeChildren(node) {
84
+ node.walk((child) => {
85
+ if (child.type === "rule") {
86
+ scopeRule(child);
87
+ }
88
+ // @supports / @media blocks are walked automatically
89
+ });
90
+ }
91
+
92
+ // --- Main ---
93
+ const css = readFileSync(file, "utf8");
94
+ const root = postcss.parse(css);
95
+
96
+ root.walkAtRules("layer", (layer) => {
97
+ if (layer.params !== "base") return;
98
+ scopeChildren(layer);
99
+ });
100
+
101
+ writeFileSync(file, root.toString());
@@ -1,9 +1,5 @@
1
1
  import { useCallback, useEffect, useMemo, useRef } from "react";
2
- import {
3
- useAgent,
4
- useCopilotChatConfiguration,
5
- useCopilotKit,
6
- } from "@copilotkitnext/react";
2
+ import { useAgent, useCopilotChatConfiguration, useCopilotKit } from "../v2";
7
3
  import { CopilotKitError, parseJson } from "@copilotkit/shared";
8
4
  import { useCopilotContext } from "../context";
9
5
  import {
@@ -12,7 +8,7 @@ import {
12
8
  AGUIConnectNotImplementedError,
13
9
  } from "@ag-ui/client";
14
10
  import { useErrorToast } from "./error-boundary/error-utils";
15
- import { CopilotKitCoreSubscriber } from "@copilotkitnext/core";
11
+ import { CopilotKitCoreSubscriber } from "@copilotkit/core";
16
12
  import { useToast } from "./toast/toast-provider";
17
13
  import { CopilotKitLowLevelError } from "@copilotkit/shared";
18
14
 
@@ -29,7 +29,7 @@ import {
29
29
  CopilotKitError,
30
30
  CopilotKitErrorCode,
31
31
  } from "@copilotkit/shared";
32
- import { Suggestion } from "@copilotkitnext/core";
32
+ import { Suggestion } from "@copilotkit/core";
33
33
 
34
34
  // Helper to determine if error should show as banner based on visibility and legacy patterns
35
35
  function shouldShowAsBanner(gqlError: GraphQLError): boolean {
@@ -2,7 +2,7 @@ import { ForwardedParametersInput } from "@copilotkit/runtime-client-gql";
2
2
  import { ReactNode } from "react";
3
3
  import { AuthState } from "../../context/copilot-context";
4
4
  import { CopilotErrorHandler } from "@copilotkit/shared";
5
- import { CopilotKitProviderProps } from "@copilotkitnext/react";
5
+ import { CopilotKitProviderProps } from "../../v2";
6
6
  /**
7
7
  * Props for CopilotKit.
8
8
  */
@@ -25,9 +25,9 @@ import {
25
25
  import {
26
26
  CopilotChatConfigurationProvider,
27
27
  CopilotKitInspector,
28
- CopilotKitProvider as CopilotKitNextProvider,
28
+ CopilotKitProvider as CopilotKitV2Provider,
29
29
  useCopilotKit,
30
- } from "@copilotkitnext/react";
30
+ } from "../../v2";
31
31
  import {
32
32
  CopilotContext,
33
33
  CopilotApiConfig,
@@ -90,14 +90,14 @@ export function CopilotKit({ children, ...props }: CopilotKitProps) {
90
90
  showUsageBanner={enabled}
91
91
  >
92
92
  <ThreadsProvider threadId={props.threadId}>
93
- <CopilotKitNextProvider
93
+ <CopilotKitV2Provider
94
94
  {...props}
95
95
  showDevConsole={showInspector}
96
96
  renderCustomMessages={renderArr}
97
97
  useSingleEndpoint={props.useSingleEndpoint ?? true}
98
98
  >
99
99
  <CopilotKitInternal {...props}>{children}</CopilotKitInternal>
100
- </CopilotKitNextProvider>
100
+ </CopilotKitV2Provider>
101
101
  </ThreadsProvider>
102
102
  </CopilotErrorBoundary>
103
103
  </ToastProvider>
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { Message } from "@copilotkit/runtime-client-gql";
6
6
  import React from "react";
7
- import { Suggestion } from "@copilotkitnext/core";
7
+ import { Suggestion } from "@copilotkit/core";
8
8
 
9
9
  export interface CopilotMessagesContextParams {
10
10
  messages: Message[];
@@ -3,7 +3,7 @@ import { renderHook, waitFor } from "@testing-library/react";
3
3
  import { useCoAgent } from "../use-coagent";
4
4
  import type { AgentSubscriber } from "@ag-ui/client";
5
5
 
6
- // Mock functions for @copilotkitnext/react
6
+ // Mock functions for v2
7
7
  const mockSetState = vi.fn();
8
8
  const mockRunAgent = vi.fn();
9
9
  const mockAbortRun = vi.fn();
@@ -29,7 +29,7 @@ const mockAgent = {
29
29
  }),
30
30
  };
31
31
 
32
- vi.mock("@copilotkitnext/react", () => ({
32
+ vi.mock("../../v2", () => ({
33
33
  useAgent: vi.fn(() => ({ agent: mockAgent })),
34
34
  useCopilotKit: vi.fn(() => ({
35
35
  copilotkit: {
@@ -11,7 +11,7 @@ import {
11
11
  } from "../../context";
12
12
  import type { Claim } from "../use-coagent-state-render-bridge.helpers";
13
13
  import { createTestCopilotContext } from "../../test-helpers/copilot-context";
14
- import { useRenderCustomMessages } from "@copilotkitnext/react";
14
+ import { useRenderCustomMessages } from "../../v2";
15
15
 
16
16
  type TestMessage = {
17
17
  id: string;
@@ -40,7 +40,7 @@ const mockAgent = {
40
40
 
41
41
  let lastSubscriber: TestAgentSubscriber | null = null;
42
42
 
43
- vi.mock("@copilotkitnext/react", () => ({
43
+ vi.mock("../../v2", () => ({
44
44
  useAgent: vi.fn(() => ({ agent: mockAgent })),
45
45
  useCopilotKit: vi.fn(() => ({
46
46
  copilotkit: {
@@ -4,12 +4,8 @@ import { renderHook, act } from "@testing-library/react";
4
4
  import { useCopilotChatInternal } from "../use-copilot-chat_internal";
5
5
  import { CoAgentStateRendersProvider, CopilotContext } from "../../context";
6
6
  import { createTestCopilotContext } from "../../test-helpers/copilot-context";
7
- import {
8
- useAgent,
9
- useCopilotKit,
10
- useCopilotChatConfiguration,
11
- } from "@copilotkitnext/react";
12
- import { CopilotKitCoreRuntimeConnectionStatus } from "@copilotkitnext/core";
7
+ import { useAgent, useCopilotKit, useCopilotChatConfiguration } from "../../v2";
8
+ import { CopilotKitCoreRuntimeConnectionStatus } from "@copilotkit/core";
13
9
 
14
10
  // ---------------------------------------------------------------------------
15
11
  // Mutable state that tests can tweak between renders
@@ -37,7 +33,7 @@ let mockConfigThreadId: string | undefined = "config-thread-id";
37
33
  // ---------------------------------------------------------------------------
38
34
  // Module mocks
39
35
  // ---------------------------------------------------------------------------
40
- vi.mock("@copilotkitnext/react", () => ({
36
+ vi.mock("../../v2", () => ({
41
37
  useAgent: vi.fn(() => ({ agent: mockAgent })),
42
38
  useCopilotKit: vi.fn(() => ({
43
39
  copilotkit: {
@@ -6,7 +6,7 @@ import { useFrontendTool } from "../use-frontend-tool";
6
6
  // Track what gets passed to the v2 hook
7
7
  let lastV2ToolCall: any = null;
8
8
 
9
- vi.mock("@copilotkitnext/react", () => ({
9
+ vi.mock("../../v2", () => ({
10
10
  useFrontendTool: vi.fn((tool: any) => {
11
11
  lastV2ToolCall = tool;
12
12
  }),
@@ -1,11 +1,11 @@
1
1
  import { vi } from "vitest";
2
2
  import React, { useEffect } from "react";
3
3
  import { render, waitFor } from "@testing-library/react";
4
- import { ToolCallStatus } from "@copilotkitnext/core";
4
+ import { ToolCallStatus } from "@copilotkit/core";
5
5
  import { useFrontendTool } from "../use-frontend-tool";
6
- import * as copilotkitNextReact from "@copilotkitnext/react";
6
+ import * as copilotKitV2React from "../../v2";
7
7
 
8
- vi.mock("@copilotkitnext/react", () => {
8
+ vi.mock("../../v2", () => {
9
9
  let currentRender: any = null;
10
10
  const listeners = new Set<() => void>();
11
11
 
@@ -24,7 +24,7 @@ vi.mock("@copilotkitnext/react", () => {
24
24
  };
25
25
  });
26
26
 
27
- const toolRenderModule = copilotkitNextReact as unknown as {
27
+ const toolRenderModule = copilotKitV2React as unknown as {
28
28
  __getCurrentRender: () => any;
29
29
  __subscribeRender: (listener: () => void) => () => void;
30
30
  };
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useRef } from "react";
2
2
  import type { AgentSubscriber } from "@ag-ui/client";
3
- import { useAgent } from "@copilotkitnext/react";
3
+ import { useAgent } from "../v2";
4
4
 
5
5
  export function useAgentNodeName(agentName?: string) {
6
6
  const { agent } = useAgent({ agentId: agentName });
@@ -1,7 +1,4 @@
1
- import {
2
- ReactCustomMessageRendererPosition,
3
- useAgent,
4
- } from "@copilotkitnext/react";
1
+ import { ReactCustomMessageRendererPosition, useAgent } from "../v2";
5
2
  import { useCallback, useEffect, useMemo, useState } from "react";
6
3
  import type { AgentSubscriber } from "@ag-ui/client";
7
4
  import { useCoAgentStateRenders } from "../context";
@@ -90,7 +90,7 @@
90
90
 
91
91
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
92
92
  import { Message } from "@copilotkit/shared";
93
- import { useAgent, useCopilotKit } from "@copilotkitnext/react";
93
+ import { useAgent, useCopilotKit } from "../v2";
94
94
  import { type AgentSubscriber } from "@ag-ui/client";
95
95
  import { useAgentNodeName } from "./use-agent-nodename";
96
96
 
@@ -3,8 +3,8 @@ import {
3
3
  useCopilotChatConfiguration,
4
4
  useCopilotKit,
5
5
  useSuggestions,
6
- } from "@copilotkitnext/react";
7
- import { StaticSuggestionsConfig, Suggestion } from "@copilotkitnext/core";
6
+ } from "../v2";
7
+ import { StaticSuggestionsConfig, Suggestion } from "@copilotkit/core";
8
8
  import { useCopilotContext } from "../context";
9
9
  import { useEffect, useMemo } from "react";
10
10
 
@@ -63,9 +63,9 @@ import {
63
63
  useCopilotChatConfiguration,
64
64
  useCopilotKit,
65
65
  useSuggestions,
66
- } from "@copilotkitnext/react";
66
+ } from "../v2";
67
67
  import { useEffect } from "react";
68
- import { StaticSuggestionsConfig, Suggestion } from "@copilotkitnext/core";
68
+ import { StaticSuggestionsConfig, Suggestion } from "@copilotkit/core";
69
69
 
70
70
  type StaticSuggestionInput = Omit<Suggestion, "isLoading"> &
71
71
  Partial<Pick<Suggestion, "isLoading">>;
@@ -20,11 +20,11 @@ import {
20
20
  useCopilotKit,
21
21
  useRenderCustomMessages,
22
22
  useSuggestions,
23
- } from "@copilotkitnext/react";
23
+ } from "../v2";
24
24
  import {
25
25
  Suggestion,
26
26
  CopilotKitCoreRuntimeConnectionStatus,
27
- } from "@copilotkitnext/core";
27
+ } from "@copilotkit/core";
28
28
  import { useLazyToolRenderer } from "./use-lazy-tool-renderer";
29
29
  import {
30
30
  AbstractAgent,
@@ -61,7 +61,7 @@
61
61
  * }
62
62
  * ```
63
63
  */
64
- import { useCopilotKit } from "@copilotkitnext/react";
64
+ import { useCopilotKit } from "../v2";
65
65
  import { useEffect, useRef } from "react";
66
66
 
67
67
  /**
@@ -6,11 +6,11 @@ import {
6
6
  MappedParameterTypes,
7
7
  } from "@copilotkit/shared";
8
8
  import { parseJson } from "@copilotkit/shared";
9
- import { ToolCallStatus } from "@copilotkitnext/core";
9
+ import { ToolCallStatus } from "@copilotkit/core";
10
10
  import {
11
11
  type ReactFrontendTool,
12
12
  useFrontendTool as useFrontendToolVNext,
13
- } from "@copilotkitnext/react";
13
+ } from "../v2";
14
14
 
15
15
  type FrontendToolOptions<T extends Parameter[] | []> = ReactFrontendTool<
16
16
  MappedParameterTypes<T>
@@ -11,8 +11,8 @@ import {
11
11
  getZodParameters,
12
12
  parseJson,
13
13
  } from "@copilotkit/shared";
14
- import { useHumanInTheLoop as useHumanInTheLoopVNext } from "@copilotkitnext/react";
15
- import { ToolCallStatus } from "@copilotkitnext/core";
14
+ import { useHumanInTheLoop as useHumanInTheLoopVNext } from "../v2";
15
+ import { ToolCallStatus } from "@copilotkit/core";
16
16
  import React, {
17
17
  ComponentType,
18
18
  FunctionComponent,
@@ -1,14 +1,11 @@
1
1
  import React, { useCallback, useRef } from "react";
2
2
  import { LangGraphInterruptRender } from "../types/interrupt-action";
3
- import {
4
- useInterrupt,
5
- useCopilotChatConfiguration,
6
- } from "@copilotkitnext/react";
3
+ import { useInterrupt, useCopilotChatConfiguration } from "../v2";
7
4
  import type {
8
5
  InterruptEvent,
9
6
  InterruptRenderProps,
10
7
  InterruptHandlerProps,
11
- } from "@copilotkitnext/react";
8
+ } from "../v2";
12
9
  import { MetaEventName } from "@copilotkit/runtime-client-gql";
13
10
  import { parseJson } from "@copilotkit/shared";
14
11
  import { useAgentNodeName } from "./use-agent-nodename";
@@ -1,4 +1,4 @@
1
- import { useRenderToolCall } from "@copilotkitnext/react";
1
+ import { useRenderToolCall } from "../v2";
2
2
  import { AIMessage, Message, ToolResult } from "@copilotkit/shared";
3
3
  import React, { useCallback } from "react";
4
4
 
@@ -1,6 +1,6 @@
1
1
  import { type Parameter, getZodParameters } from "@copilotkit/shared";
2
2
  import { parseJson } from "@copilotkit/shared";
3
- import { defineToolCallRenderer, useCopilotKit } from "@copilotkitnext/react";
3
+ import { defineToolCallRenderer, useCopilotKit } from "../v2";
4
4
  import type React from "react";
5
5
  import { useEffect, useRef } from "react";
6
6
  import {
@@ -43,7 +43,7 @@
43
43
  * }
44
44
  * ```
45
45
  *
46
- * Have a look at the [Presentation Example App](https://github.com/CopilotKit/CopilotKit/blob/main/src/v1.x/examples/next-openai/src/app/presentation/page.tsx) for a more complete example.
46
+ * Have a look at the [Presentation Example App](https://github.com/CopilotKit/CopilotKit/blob/main/examples/v1/next-openai/src/app/presentation/page.tsx) for a more complete example.
47
47
  */
48
48
 
49
49
  import {
package/src/setupTests.ts CHANGED
@@ -12,20 +12,24 @@ vi.mock("@segment/analytics-node", () => ({
12
12
  })),
13
13
  }));
14
14
 
15
- vi.mock("@copilotkit/shared", () => ({
16
- parseJson: vi.fn((jsonString, defaultValue) => {
17
- try {
18
- return JSON.parse(jsonString);
19
- } catch {
20
- return defaultValue;
21
- }
22
- }),
23
- dataToUUID: vi.fn((data) => JSON.stringify(data)),
24
- getZodParameters: vi.fn(() => z.object({})),
25
- randomId: vi.fn(() => "test-random-id"),
26
- CopilotKitAgentDiscoveryError: vi.fn(),
27
- randomUUID: vi.fn(() => "mock-thread-id"),
28
- }));
15
+ vi.mock("@copilotkit/shared", async (importOriginal) => {
16
+ const actual = await importOriginal<typeof import("@copilotkit/shared")>();
17
+ return {
18
+ ...actual,
19
+ parseJson: vi.fn((jsonString, defaultValue) => {
20
+ try {
21
+ return JSON.parse(jsonString);
22
+ } catch {
23
+ return defaultValue;
24
+ }
25
+ }),
26
+ dataToUUID: vi.fn((data) => JSON.stringify(data)),
27
+ getZodParameters: vi.fn(() => z.object({})),
28
+ randomId: vi.fn(() => "test-random-id"),
29
+ CopilotKitAgentDiscoveryError: vi.fn(),
30
+ randomUUID: vi.fn(() => "mock-thread-id"),
31
+ };
32
+ });
29
33
 
30
34
  // Mock react-dom/test-utils to avoid compatibility issues
31
35
  vi.mock("react-dom/test-utils", () => ({