@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.
- package/CHANGELOG.md +127 -116
- package/dist/copilotkit-B3Mb1yVE.cjs +7975 -0
- package/dist/copilotkit-B3Mb1yVE.cjs.map +1 -0
- package/dist/copilotkit-DBzgOMby.d.cts +2182 -0
- package/dist/copilotkit-DBzgOMby.d.cts.map +1 -0
- package/dist/copilotkit-DNYSFuz5.mjs +7562 -0
- package/dist/copilotkit-DNYSFuz5.mjs.map +1 -0
- package/dist/copilotkit-Dy5w3qEV.d.mts +2182 -0
- package/dist/copilotkit-Dy5w3qEV.d.mts.map +1 -0
- package/dist/index.cjs +27 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -5
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +1941 -35
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/index.cjs +77 -7
- package/dist/v2/index.css +1 -2
- package/dist/v2/index.d.cts +6 -4
- package/dist/v2/index.d.mts +6 -4
- package/dist/v2/index.mjs +7 -4
- package/dist/v2/index.umd.js +5725 -24
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +37 -9
- package/scripts/scope-preflight.mjs +101 -0
- package/src/components/CopilotListeners.tsx +2 -6
- package/src/components/copilot-provider/copilot-messages.tsx +1 -1
- package/src/components/copilot-provider/copilotkit-props.tsx +1 -1
- package/src/components/copilot-provider/copilotkit.tsx +4 -4
- package/src/context/copilot-messages-context.tsx +1 -1
- package/src/hooks/__tests__/use-coagent-config.test.ts +2 -2
- package/src/hooks/__tests__/use-coagent-state-render.e2e.test.tsx +2 -2
- package/src/hooks/__tests__/use-copilot-chat-internal-connect.test.tsx +3 -7
- package/src/hooks/__tests__/use-frontend-tool-available.test.tsx +1 -1
- package/src/hooks/__tests__/use-frontend-tool-remount.e2e.test.tsx +4 -4
- package/src/hooks/use-agent-nodename.ts +1 -1
- package/src/hooks/use-coagent-state-render-bridge.tsx +1 -4
- package/src/hooks/use-coagent.ts +1 -1
- package/src/hooks/use-configure-chat-suggestions.tsx +2 -2
- package/src/hooks/use-copilot-chat-suggestions.tsx +2 -2
- package/src/hooks/use-copilot-chat_internal.ts +2 -2
- package/src/hooks/use-copilot-readable.ts +1 -1
- package/src/hooks/use-frontend-tool.ts +2 -2
- package/src/hooks/use-human-in-the-loop.ts +2 -2
- package/src/hooks/use-langgraph-interrupt.ts +2 -5
- package/src/hooks/use-lazy-tool-renderer.tsx +1 -1
- package/src/hooks/use-render-tool-call.ts +1 -1
- package/src/lib/copilot-task.ts +1 -1
- package/src/setupTests.ts +18 -14
- package/src/v2/__tests__/A2UIMessageRenderer.test.tsx +176 -0
- package/src/v2/__tests__/globalSetup.ts +14 -0
- package/src/v2/__tests__/setup.ts +93 -0
- package/src/v2/__tests__/utils/test-helpers.tsx +470 -0
- package/src/v2/a2ui/A2UIMessageRenderer.tsx +206 -0
- package/src/v2/components/CopilotKitInspector.tsx +50 -0
- package/src/v2/components/MCPAppsActivityRenderer.tsx +785 -0
- package/src/v2/components/WildcardToolCallRender.tsx +86 -0
- package/src/v2/components/__tests__/license-warning-banner.test.tsx +46 -0
- package/src/v2/components/chat/CopilotChat.tsx +431 -0
- package/src/v2/components/chat/CopilotChatAssistantMessage.tsx +375 -0
- package/src/v2/components/chat/CopilotChatAudioRecorder.tsx +350 -0
- package/src/v2/components/chat/CopilotChatInput.tsx +1302 -0
- package/src/v2/components/chat/CopilotChatMessageView.tsx +556 -0
- package/src/v2/components/chat/CopilotChatReasoningMessage.tsx +252 -0
- package/src/v2/components/chat/CopilotChatSuggestionPill.tsx +59 -0
- package/src/v2/components/chat/CopilotChatSuggestionView.tsx +133 -0
- package/src/v2/components/chat/CopilotChatToggleButton.tsx +171 -0
- package/src/v2/components/chat/CopilotChatToolCallsView.tsx +40 -0
- package/src/v2/components/chat/CopilotChatUserMessage.tsx +388 -0
- package/src/v2/components/chat/CopilotChatView.tsx +598 -0
- package/src/v2/components/chat/CopilotModalHeader.tsx +129 -0
- package/src/v2/components/chat/CopilotPopup.tsx +81 -0
- package/src/v2/components/chat/CopilotPopupView.tsx +317 -0
- package/src/v2/components/chat/CopilotSidebar.tsx +76 -0
- package/src/v2/components/chat/CopilotSidebarView.tsx +255 -0
- package/src/v2/components/chat/__tests__/CopilotChat.e2e.test.tsx +1113 -0
- package/src/v2/components/chat/__tests__/CopilotChat.onError.test.tsx +73 -0
- package/src/v2/components/chat/__tests__/CopilotChat.slots.e2e.test.tsx +432 -0
- package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.tsx +150 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.slots.e2e.test.tsx +624 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.tsx +702 -0
- package/src/v2/components/chat/__tests__/CopilotChatCssClasses.test.tsx +107 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.slots.e2e.test.tsx +929 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.test.tsx +986 -0
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.slots.e2e.test.tsx +1004 -0
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.tsx +169 -0
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.slots.e2e.test.tsx +530 -0
- package/src/v2/components/chat/__tests__/CopilotChatToolRendering.e2e.test.tsx +782 -0
- package/src/v2/components/chat/__tests__/CopilotChatToolRerenders.e2e.test.tsx +2413 -0
- package/src/v2/components/chat/__tests__/CopilotChatUserMessage.slots.e2e.test.tsx +621 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.onClick.e2e.test.tsx +853 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.slots.e2e.test.tsx +1050 -0
- package/src/v2/components/chat/__tests__/CopilotModalHeader.slots.e2e.test.tsx +484 -0
- package/src/v2/components/chat/__tests__/CopilotPopupView.slots.e2e.test.tsx +612 -0
- package/src/v2/components/chat/__tests__/CopilotSidebarView.slots.e2e.test.tsx +502 -0
- package/src/v2/components/chat/__tests__/MCPAppsActivityRenderer.e2e.test.tsx +1011 -0
- package/src/v2/components/chat/__tests__/setup.ts +1 -0
- package/src/v2/components/chat/index.ts +79 -0
- package/src/v2/components/index.ts +7 -0
- package/src/v2/components/license-warning-banner.tsx +198 -0
- package/src/v2/components/ui/button.tsx +123 -0
- package/src/v2/components/ui/dropdown-menu.tsx +258 -0
- package/src/v2/components/ui/tooltip.tsx +60 -0
- package/src/v2/hooks/__tests__/standard-schema-types.test.tsx +152 -0
- package/src/v2/hooks/__tests__/standard-schema.test.tsx +282 -0
- package/src/v2/hooks/__tests__/use-agent-context-timing.e2e.test.tsx +132 -0
- package/src/v2/hooks/__tests__/use-agent-context.test.tsx +401 -0
- package/src/v2/hooks/__tests__/use-agent-error-state.test.tsx +44 -0
- package/src/v2/hooks/__tests__/use-agent-stability.test.tsx +205 -0
- package/src/v2/hooks/__tests__/use-agent.e2e.test.tsx +148 -0
- package/src/v2/hooks/__tests__/use-component.test.tsx +123 -0
- package/src/v2/hooks/__tests__/use-configure-suggestions.e2e.test.tsx +696 -0
- package/src/v2/hooks/__tests__/use-default-render-tool.test.tsx +153 -0
- package/src/v2/hooks/__tests__/use-frontend-tool-available.test.tsx +167 -0
- package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.tsx +2129 -0
- package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.tsx +1261 -0
- package/src/v2/hooks/__tests__/use-interrupt.test.tsx +397 -0
- package/src/v2/hooks/__tests__/use-katex-styles.test.tsx +56 -0
- package/src/v2/hooks/__tests__/use-keyboard-height.test.tsx +192 -0
- package/src/v2/hooks/__tests__/use-render-tool.test.tsx +259 -0
- package/src/v2/hooks/__tests__/use-suggestions.e2e.test.tsx +524 -0
- package/src/v2/hooks/__tests__/use-threads.test.tsx +433 -0
- package/src/v2/hooks/__tests__/zod-regression.test.tsx +311 -0
- package/src/v2/hooks/index.ts +18 -0
- package/src/v2/hooks/use-agent-context.tsx +45 -0
- package/src/v2/hooks/use-agent.tsx +155 -0
- package/src/v2/hooks/use-component.tsx +89 -0
- package/src/v2/hooks/use-configure-suggestions.tsx +187 -0
- package/src/v2/hooks/use-default-render-tool.tsx +254 -0
- package/src/v2/hooks/use-frontend-tool.tsx +43 -0
- package/src/v2/hooks/use-human-in-the-loop.tsx +81 -0
- package/src/v2/hooks/use-interrupt.tsx +305 -0
- package/src/v2/hooks/use-keyboard-height.tsx +67 -0
- package/src/v2/hooks/use-render-activity-message.tsx +73 -0
- package/src/v2/hooks/use-render-custom-messages.tsx +93 -0
- package/src/v2/hooks/use-render-tool-call.tsx +175 -0
- package/src/v2/hooks/use-render-tool.tsx +181 -0
- package/src/v2/hooks/use-suggestions.tsx +91 -0
- package/src/v2/hooks/use-threads.tsx +256 -0
- package/src/v2/hooks/useKatexStyles.ts +27 -0
- package/src/v2/index.css +1 -1
- package/src/v2/index.ts +18 -2
- package/src/v2/lib/__tests__/completePartialMarkdown.test.ts +495 -0
- package/src/v2/lib/__tests__/renderSlot.test.tsx +588 -0
- package/src/v2/lib/react-core.ts +156 -0
- package/src/v2/lib/slots.tsx +143 -0
- package/src/v2/lib/transcription-client.ts +184 -0
- package/src/v2/lib/utils.ts +8 -0
- package/src/v2/providers/CopilotChatConfigurationProvider.tsx +162 -0
- package/src/v2/providers/CopilotKitProvider.tsx +600 -0
- package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.tsx +546 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.license.test.tsx +101 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.onError.test.tsx +69 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.renderCustomMessages.e2e.test.tsx +881 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.stability.test.tsx +740 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.test.tsx +642 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.wildcard.test.tsx +294 -0
- package/src/v2/providers/index.ts +14 -0
- package/src/v2/styles/globals.css +230 -0
- package/src/v2/types/__tests__/defineToolCallRenderer.test.tsx +525 -0
- package/src/v2/types/defineToolCallRenderer.ts +65 -0
- package/src/v2/types/frontend-tool.ts +8 -0
- package/src/v2/types/human-in-the-loop.ts +33 -0
- package/src/v2/types/index.ts +7 -0
- package/src/v2/types/interrupt.ts +15 -0
- package/src/v2/types/react-activity-message-renderer.ts +27 -0
- package/src/v2/types/react-custom-message-renderer.ts +17 -0
- package/src/v2/types/react-tool-call-renderer.ts +32 -0
- package/tsdown.config.ts +34 -10
- package/vitest.config.mjs +4 -3
- package/LICENSE +0 -21
- package/dist/copilotkit-BRPQ2sqS.d.cts +0 -670
- package/dist/copilotkit-BRPQ2sqS.d.cts.map +0 -1
- package/dist/copilotkit-C94ayZbs.cjs +0 -2161
- package/dist/copilotkit-C94ayZbs.cjs.map +0 -1
- package/dist/copilotkit-CwZMFmSK.d.mts +0 -670
- package/dist/copilotkit-CwZMFmSK.d.mts.map +0 -1
- package/dist/copilotkit-Yh_Ld_FX.mjs +0 -2031
- package/dist/copilotkit-Yh_Ld_FX.mjs.map +0 -1
- 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.
|
|
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.
|
|
55
|
-
"tsconfig": "1.4.
|
|
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
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"@
|
|
65
|
-
"@
|
|
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/
|
|
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 "@
|
|
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 "@
|
|
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 "
|
|
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
|
|
28
|
+
CopilotKitProvider as CopilotKitV2Provider,
|
|
29
29
|
useCopilotKit,
|
|
30
|
-
} from "
|
|
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
|
-
<
|
|
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
|
-
</
|
|
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 "@
|
|
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
|
|
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("
|
|
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 "
|
|
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("
|
|
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
|
-
|
|
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("
|
|
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("
|
|
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 "@
|
|
4
|
+
import { ToolCallStatus } from "@copilotkit/core";
|
|
5
5
|
import { useFrontendTool } from "../use-frontend-tool";
|
|
6
|
-
import * as
|
|
6
|
+
import * as copilotKitV2React from "../../v2";
|
|
7
7
|
|
|
8
|
-
vi.mock("
|
|
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 =
|
|
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 "
|
|
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";
|
package/src/hooks/use-coagent.ts
CHANGED
|
@@ -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 "
|
|
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 "
|
|
7
|
-
import { StaticSuggestionsConfig, Suggestion } from "@
|
|
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 "
|
|
66
|
+
} from "../v2";
|
|
67
67
|
import { useEffect } from "react";
|
|
68
|
-
import { StaticSuggestionsConfig, Suggestion } from "@
|
|
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 "
|
|
23
|
+
} from "../v2";
|
|
24
24
|
import {
|
|
25
25
|
Suggestion,
|
|
26
26
|
CopilotKitCoreRuntimeConnectionStatus,
|
|
27
|
-
} from "@
|
|
27
|
+
} from "@copilotkit/core";
|
|
28
28
|
import { useLazyToolRenderer } from "./use-lazy-tool-renderer";
|
|
29
29
|
import {
|
|
30
30
|
AbstractAgent,
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
MappedParameterTypes,
|
|
7
7
|
} from "@copilotkit/shared";
|
|
8
8
|
import { parseJson } from "@copilotkit/shared";
|
|
9
|
-
import { ToolCallStatus } from "@
|
|
9
|
+
import { ToolCallStatus } from "@copilotkit/core";
|
|
10
10
|
import {
|
|
11
11
|
type ReactFrontendTool,
|
|
12
12
|
useFrontendTool as useFrontendToolVNext,
|
|
13
|
-
} from "
|
|
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 "
|
|
15
|
-
import { ToolCallStatus } from "@
|
|
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 "
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import { type Parameter, getZodParameters } from "@copilotkit/shared";
|
|
2
2
|
import { parseJson } from "@copilotkit/shared";
|
|
3
|
-
import { defineToolCallRenderer, useCopilotKit } from "
|
|
3
|
+
import { defineToolCallRenderer, useCopilotKit } from "../v2";
|
|
4
4
|
import type React from "react";
|
|
5
5
|
import { useEffect, useRef } from "react";
|
|
6
6
|
import {
|
package/src/lib/copilot-task.ts
CHANGED
|
@@ -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/
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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", () => ({
|