@copilotkit/react-core 1.10.0-next.9 → 1.10.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 +104 -0
- package/dist/{chunk-VH45SC6Z.mjs → chunk-2GRWTU7W.mjs} +2 -2
- package/dist/chunk-3BASANUO.mjs +170 -0
- package/dist/chunk-3BASANUO.mjs.map +1 -0
- package/dist/{chunk-PHIMGB3K.mjs → chunk-5P46WS5M.mjs} +25 -19
- package/dist/chunk-5P46WS5M.mjs.map +1 -0
- package/dist/{chunk-AWFAFFO5.mjs → chunk-6ZLPNY7X.mjs} +7 -3
- package/dist/chunk-6ZLPNY7X.mjs.map +1 -0
- package/dist/{chunk-TTI4Z6GK.mjs → chunk-BEFEBKKI.mjs} +7 -7
- package/dist/chunk-BEFEBKKI.mjs.map +1 -0
- package/dist/{chunk-VSH4JSN3.mjs → chunk-F26O2HTO.mjs} +13 -7
- package/dist/chunk-F26O2HTO.mjs.map +1 -0
- package/dist/{chunk-GRCHDHC4.mjs → chunk-JY3STRON.mjs} +22 -4
- package/dist/chunk-JY3STRON.mjs.map +1 -0
- package/dist/{chunk-ZTZJIDRJ.mjs → chunk-N4VN2B5S.mjs} +2 -2
- package/dist/{chunk-FTP6FDYS.mjs → chunk-NTH42BY5.mjs} +2 -2
- package/dist/chunk-PIF5KJYI.mjs +103 -0
- package/dist/chunk-PIF5KJYI.mjs.map +1 -0
- package/dist/chunk-WSXTUD36.mjs +759 -0
- package/dist/chunk-WSXTUD36.mjs.map +1 -0
- package/dist/chunk-YIBUNEBN.mjs +34 -0
- package/dist/chunk-YIBUNEBN.mjs.map +1 -0
- package/dist/components/copilot-provider/copilotkit-props.d.ts +9 -1
- package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.js +1052 -72
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +6 -3
- package/dist/components/copilot-provider/index.js +1052 -72
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +6 -3
- package/dist/components/dev-console/console-trigger.d.ts +8 -0
- package/dist/components/dev-console/console-trigger.js +1131 -0
- package/dist/components/dev-console/console-trigger.js.map +1 -0
- package/dist/components/dev-console/console-trigger.mjs +13 -0
- package/dist/components/dev-console/developer-console-modal.d.ts +10 -0
- package/dist/components/dev-console/developer-console-modal.js +977 -0
- package/dist/components/dev-console/developer-console-modal.js.map +1 -0
- package/dist/components/dev-console/developer-console-modal.mjs +12 -0
- package/dist/components/dev-console/developer-console-modal.mjs.map +1 -0
- package/dist/components/dev-console/icons.d.ts +9 -0
- package/dist/components/dev-console/icons.js +131 -0
- package/dist/components/dev-console/icons.js.map +1 -0
- package/dist/components/dev-console/icons.mjs +16 -0
- package/dist/components/dev-console/icons.mjs.map +1 -0
- package/dist/components/error-boundary/error-boundary.js +6 -2
- package/dist/components/error-boundary/error-boundary.js.map +1 -1
- package/dist/components/error-boundary/error-boundary.mjs +2 -2
- package/dist/components/index.js +1052 -72
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +6 -3
- package/dist/components/usage-banner.d.ts +2 -1
- package/dist/components/usage-banner.js +6 -2
- package/dist/components/usage-banner.js.map +1 -1
- package/dist/components/usage-banner.mjs +1 -1
- package/dist/hooks/index.d.ts +5 -5
- package/dist/hooks/index.js +58 -26
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +13 -10
- package/dist/hooks/use-coagent.d.ts +1 -1
- package/dist/hooks/use-coagent.js +18 -6
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +8 -5
- package/dist/hooks/use-copilot-chat-headless_c.d.ts +33 -0
- package/dist/hooks/{use-copilot-chat-light.js → use-copilot-chat-headless_c.js} +88 -19
- package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -0
- package/dist/hooks/{use-copilot-chat-light.mjs → use-copilot-chat-headless_c.mjs} +14 -8
- package/dist/hooks/use-copilot-chat-headless_c.mjs.map +1 -0
- package/dist/hooks/use-copilot-chat.d.ts +85 -4
- package/dist/hooks/use-copilot-chat.js +38 -61
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +8 -8
- package/dist/hooks/use-copilot-chat_internal.d.ts +98 -12
- package/dist/hooks/use-copilot-chat_internal.js +13 -1
- package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
- package/dist/hooks/use-copilot-chat_internal.mjs +7 -4
- package/dist/hooks/use-langgraph-interrupt.js +13 -1
- package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt.mjs +8 -5
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1203 -200
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -11
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +7 -4
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +7 -4
- package/dist/utils/extract.js.map +1 -1
- package/dist/utils/extract.mjs +6 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +6 -3
- package/dist/utils/suggestions.js.map +1 -1
- package/dist/utils/suggestions.mjs +6 -3
- package/package.json +3 -3
- package/src/components/copilot-provider/copilotkit-props.tsx +10 -1
- package/src/components/copilot-provider/copilotkit.tsx +25 -16
- package/src/components/dev-console/console-trigger.tsx +190 -0
- package/src/components/dev-console/developer-console-modal.tsx +866 -0
- package/src/components/dev-console/icons.tsx +101 -0
- package/src/components/usage-banner.tsx +8 -3
- package/src/hooks/index.ts +6 -7
- package/src/hooks/use-coagent.ts +6 -11
- package/src/hooks/use-copilot-chat-headless_c.ts +257 -0
- package/src/hooks/use-copilot-chat.ts +103 -154
- package/src/hooks/use-copilot-chat_internal.ts +122 -15
- package/dist/chunk-AWFAFFO5.mjs.map +0 -1
- package/dist/chunk-GRCHDHC4.mjs.map +0 -1
- package/dist/chunk-MWHILKQH.mjs +0 -18
- package/dist/chunk-MWHILKQH.mjs.map +0 -1
- package/dist/chunk-PHIMGB3K.mjs.map +0 -1
- package/dist/chunk-TTI4Z6GK.mjs.map +0 -1
- package/dist/chunk-VSH4JSN3.mjs.map +0 -1
- package/dist/hooks/use-copilot-chat-light.d.ts +0 -211
- package/dist/hooks/use-copilot-chat-light.js.map +0 -1
- package/src/hooks/use-copilot-chat-light.ts +0 -219
- /package/dist/{chunk-VH45SC6Z.mjs.map → chunk-2GRWTU7W.mjs.map} +0 -0
- /package/dist/{chunk-ZTZJIDRJ.mjs.map → chunk-N4VN2B5S.mjs.map} +0 -0
- /package/dist/{chunk-FTP6FDYS.mjs.map → chunk-NTH42BY5.mjs.map} +0 -0
- /package/dist/{hooks/use-copilot-chat-light.mjs.map → components/dev-console/console-trigger.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,109 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
+
## 1.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8674da1: - refactor(headless): completely overhaul headless ui to better support agentic features
|
|
8
|
+
|
|
9
|
+
Headless UI has been in a bad state for a bit now. When we added support for different
|
|
10
|
+
agentic runtimes we acquired tech-debt that, with this PR, is being alleviated.
|
|
11
|
+
|
|
12
|
+
As such, the following features have been updated to be completely functional with Headless UI.
|
|
13
|
+
|
|
14
|
+
- Generative UI
|
|
15
|
+
- Suggestions
|
|
16
|
+
- Agentic Generative UI
|
|
17
|
+
- Interrupts
|
|
18
|
+
|
|
19
|
+
In addition, a variety of QOL changes have been made.
|
|
20
|
+
|
|
21
|
+
- New AG-UI based message types
|
|
22
|
+
- Inline code rendering is fixed
|
|
23
|
+
|
|
24
|
+
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- 967d0ab: - refactor(chat): separate useCopilotChat into internal implementation and public API
|
|
29
|
+
- 6d1de58: - fix: address issues that would cause headless UI breaking changes in the next release
|
|
30
|
+
|
|
31
|
+
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
32
|
+
|
|
33
|
+
- fix: more fixes addressing breaking changes in new Headless UI
|
|
34
|
+
|
|
35
|
+
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
36
|
+
|
|
37
|
+
- chore: address linting issues
|
|
38
|
+
|
|
39
|
+
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
40
|
+
|
|
41
|
+
- chore: fixing branding and docs
|
|
42
|
+
|
|
43
|
+
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
44
|
+
|
|
45
|
+
- chore: more docs fixing
|
|
46
|
+
|
|
47
|
+
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
48
|
+
|
|
49
|
+
- 6de24ce: - fix rerender issues by moving suggestions to the messages context
|
|
50
|
+
- b64555d: - feat: adds dev console
|
|
51
|
+
- Updated dependencies [a8c0263]
|
|
52
|
+
- Updated dependencies [8674da1]
|
|
53
|
+
- Updated dependencies [6d1de58]
|
|
54
|
+
- @copilotkit/shared@1.10.0
|
|
55
|
+
- @copilotkit/runtime-client-gql@1.10.0
|
|
56
|
+
|
|
57
|
+
## 1.10.0-next.13
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- @copilotkit/runtime-client-gql@1.10.0-next.13
|
|
62
|
+
- @copilotkit/shared@1.10.0-next.13
|
|
63
|
+
|
|
64
|
+
## 1.10.0-next.12
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- b64555d: - feat: adds dev console
|
|
69
|
+
- @copilotkit/runtime-client-gql@1.10.0-next.12
|
|
70
|
+
- @copilotkit/shared@1.10.0-next.12
|
|
71
|
+
|
|
72
|
+
## 1.10.0-next.11
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- @copilotkit/runtime-client-gql@1.10.0-next.11
|
|
77
|
+
- @copilotkit/shared@1.10.0-next.11
|
|
78
|
+
|
|
79
|
+
## 1.10.0-next.10
|
|
80
|
+
|
|
81
|
+
### Patch Changes
|
|
82
|
+
|
|
83
|
+
- 6d1de58: - fix: address issues that would cause headless UI breaking changes in the next release
|
|
84
|
+
|
|
85
|
+
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
86
|
+
|
|
87
|
+
- fix: more fixes addressing breaking changes in new Headless UI
|
|
88
|
+
|
|
89
|
+
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
90
|
+
|
|
91
|
+
- chore: address linting issues
|
|
92
|
+
|
|
93
|
+
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
94
|
+
|
|
95
|
+
- chore: fixing branding and docs
|
|
96
|
+
|
|
97
|
+
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
98
|
+
|
|
99
|
+
- chore: more docs fixing
|
|
100
|
+
|
|
101
|
+
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
102
|
+
|
|
103
|
+
- Updated dependencies [6d1de58]
|
|
104
|
+
- @copilotkit/shared@1.10.0-next.10
|
|
105
|
+
- @copilotkit/runtime-client-gql@1.10.0-next.10
|
|
106
|
+
|
|
3
107
|
## 1.10.0-next.9
|
|
4
108
|
|
|
5
109
|
### Patch Changes
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-4CEQJ2X6.mjs";
|
|
4
4
|
import {
|
|
5
5
|
defaultCopilotContextCategories
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5P46WS5M.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__async,
|
|
9
9
|
__spreadValues
|
|
@@ -117,4 +117,4 @@ ${instructions}
|
|
|
117
117
|
export {
|
|
118
118
|
CopilotTask
|
|
119
119
|
};
|
|
120
|
-
//# sourceMappingURL=chunk-
|
|
120
|
+
//# sourceMappingURL=chunk-2GRWTU7W.mjs.map
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DeveloperConsoleModal
|
|
3
|
+
} from "./chunk-WSXTUD36.mjs";
|
|
4
|
+
import {
|
|
5
|
+
CopilotKitIcon
|
|
6
|
+
} from "./chunk-PIF5KJYI.mjs";
|
|
7
|
+
import {
|
|
8
|
+
useCopilotContext
|
|
9
|
+
} from "./chunk-TEMLWRRT.mjs";
|
|
10
|
+
|
|
11
|
+
// src/components/dev-console/console-trigger.tsx
|
|
12
|
+
import { useState, useEffect, useRef } from "react";
|
|
13
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
function ConsoleTrigger({ position = "bottom-right" }) {
|
|
15
|
+
const context = useCopilotContext();
|
|
16
|
+
const hasApiKey = Boolean(context.copilotApiConfig.publicApiKey);
|
|
17
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
18
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
19
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
20
|
+
const [buttonPosition, setButtonPosition] = useState(null);
|
|
21
|
+
const [mounted, setMounted] = useState(false);
|
|
22
|
+
const dragRef = useRef(null);
|
|
23
|
+
const buttonRef = useRef(null);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
setMounted(true);
|
|
26
|
+
if (typeof window !== "undefined" && !buttonPosition) {
|
|
27
|
+
const buttonSize = 60;
|
|
28
|
+
const margin = 24;
|
|
29
|
+
const initialPosition = {
|
|
30
|
+
x: margin,
|
|
31
|
+
y: window.innerHeight - buttonSize - margin
|
|
32
|
+
};
|
|
33
|
+
setButtonPosition(initialPosition);
|
|
34
|
+
}
|
|
35
|
+
}, [position]);
|
|
36
|
+
const handleMouseDown = (e) => {
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
if (!buttonPosition)
|
|
39
|
+
return;
|
|
40
|
+
dragRef.current = {
|
|
41
|
+
startX: e.clientX,
|
|
42
|
+
startY: e.clientY,
|
|
43
|
+
buttonX: buttonPosition.x,
|
|
44
|
+
buttonY: buttonPosition.y
|
|
45
|
+
};
|
|
46
|
+
setIsDragging(true);
|
|
47
|
+
};
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (!isDragging)
|
|
50
|
+
return;
|
|
51
|
+
const handleMouseMove = (e) => {
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
e.stopPropagation();
|
|
54
|
+
if (!dragRef.current)
|
|
55
|
+
return;
|
|
56
|
+
const deltaX = e.clientX - dragRef.current.startX;
|
|
57
|
+
const deltaY = e.clientY - dragRef.current.startY;
|
|
58
|
+
let newX = dragRef.current.buttonX + deltaX;
|
|
59
|
+
let newY = dragRef.current.buttonY + deltaY;
|
|
60
|
+
newX = Math.max(0, Math.min(newX, window.innerWidth - 60));
|
|
61
|
+
newY = Math.max(0, Math.min(newY, window.innerHeight - 60));
|
|
62
|
+
setButtonPosition({ x: newX, y: newY });
|
|
63
|
+
};
|
|
64
|
+
const handleMouseUp = (e) => {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
e.stopPropagation();
|
|
67
|
+
setIsDragging(false);
|
|
68
|
+
dragRef.current = null;
|
|
69
|
+
};
|
|
70
|
+
document.addEventListener("mousemove", handleMouseMove, { capture: true, passive: false });
|
|
71
|
+
document.addEventListener("mouseup", handleMouseUp, { capture: true, passive: false });
|
|
72
|
+
return () => {
|
|
73
|
+
document.removeEventListener("mousemove", handleMouseMove, { capture: true });
|
|
74
|
+
document.removeEventListener("mouseup", handleMouseUp, { capture: true });
|
|
75
|
+
};
|
|
76
|
+
}, [isDragging]);
|
|
77
|
+
if (!mounted || !buttonPosition) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
81
|
+
/* @__PURE__ */ jsxs(
|
|
82
|
+
"button",
|
|
83
|
+
{
|
|
84
|
+
ref: buttonRef,
|
|
85
|
+
onClick: () => {
|
|
86
|
+
if (!isDragging) {
|
|
87
|
+
setIsModalOpen(true);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
onMouseDown: handleMouseDown,
|
|
91
|
+
onMouseEnter: () => setIsHovered(true),
|
|
92
|
+
onMouseLeave: () => setIsHovered(false),
|
|
93
|
+
style: {
|
|
94
|
+
position: "fixed",
|
|
95
|
+
left: `${buttonPosition.x}px`,
|
|
96
|
+
top: `${buttonPosition.y}px`,
|
|
97
|
+
zIndex: 2147483647,
|
|
98
|
+
width: "60px",
|
|
99
|
+
height: "60px",
|
|
100
|
+
background: isDragging ? "#000000" : isHovered ? "#111111" : "#000000",
|
|
101
|
+
color: "white",
|
|
102
|
+
borderRadius: "50%",
|
|
103
|
+
boxShadow: isDragging ? "0 8px 32px rgba(0, 0, 0, 0.6), 0 4px 16px rgba(0, 0, 0, 0.4)" : isHovered ? "0 12px 40px rgba(0, 0, 0, 0.7), 0 6px 20px rgba(0, 0, 0, 0.5)" : "0 6px 20px rgba(0, 0, 0, 0.5), 0 3px 10px rgba(0, 0, 0, 0.3)",
|
|
104
|
+
transition: isDragging ? "none" : "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
|
|
105
|
+
display: "flex",
|
|
106
|
+
alignItems: "center",
|
|
107
|
+
justifyContent: "center",
|
|
108
|
+
border: "none",
|
|
109
|
+
cursor: isDragging ? "grabbing" : "grab",
|
|
110
|
+
opacity: 1,
|
|
111
|
+
userSelect: "none",
|
|
112
|
+
transform: isDragging ? "scale(1.05)" : isHovered ? "scale(1.1)" : "scale(1)",
|
|
113
|
+
backdropFilter: "blur(10px)",
|
|
114
|
+
pointerEvents: "auto",
|
|
115
|
+
isolation: "isolate"
|
|
116
|
+
},
|
|
117
|
+
title: hasApiKey ? "Open Developer Console (Drag to move)" : "Developer Console (API Key Required, Drag to move)",
|
|
118
|
+
children: [
|
|
119
|
+
/* @__PURE__ */ jsx(
|
|
120
|
+
"div",
|
|
121
|
+
{
|
|
122
|
+
style: {
|
|
123
|
+
width: "28px",
|
|
124
|
+
height: "28px",
|
|
125
|
+
display: "flex",
|
|
126
|
+
alignItems: "center",
|
|
127
|
+
justifyContent: "center",
|
|
128
|
+
filter: "drop-shadow(0 2px 4px rgba(0,0,0,0.2))"
|
|
129
|
+
},
|
|
130
|
+
children: /* @__PURE__ */ jsx(CopilotKitIcon, {})
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
!hasApiKey && /* @__PURE__ */ jsx(
|
|
134
|
+
"div",
|
|
135
|
+
{
|
|
136
|
+
style: {
|
|
137
|
+
position: "absolute",
|
|
138
|
+
top: "-2px",
|
|
139
|
+
right: "-2px",
|
|
140
|
+
width: "18px",
|
|
141
|
+
height: "18px",
|
|
142
|
+
background: "linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%)",
|
|
143
|
+
borderRadius: "50%",
|
|
144
|
+
display: "flex",
|
|
145
|
+
alignItems: "center",
|
|
146
|
+
justifyContent: "center",
|
|
147
|
+
boxShadow: "0 2px 8px rgba(255, 107, 107, 0.4)",
|
|
148
|
+
border: "2px solid white"
|
|
149
|
+
},
|
|
150
|
+
children: /* @__PURE__ */ jsx("span", { style: { fontSize: "10px", color: "white", fontWeight: "bold" }, children: "!" })
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
),
|
|
156
|
+
/* @__PURE__ */ jsx(
|
|
157
|
+
DeveloperConsoleModal,
|
|
158
|
+
{
|
|
159
|
+
isOpen: isModalOpen,
|
|
160
|
+
onClose: () => setIsModalOpen(false),
|
|
161
|
+
hasApiKey
|
|
162
|
+
}
|
|
163
|
+
)
|
|
164
|
+
] });
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export {
|
|
168
|
+
ConsoleTrigger
|
|
169
|
+
};
|
|
170
|
+
//# sourceMappingURL=chunk-3BASANUO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/dev-console/console-trigger.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { useState, useEffect, useRef } from \"react\";\nimport { useCopilotContext } from \"../../context/copilot-context\";\nimport { CopilotKitIcon } from \"./icons\";\nimport { DeveloperConsoleModal } from \"./developer-console-modal\";\n\ninterface ConsoleTriggerProps {\n position?: \"bottom-left\" | \"bottom-right\";\n}\n\nexport function ConsoleTrigger({ position = \"bottom-right\" }: ConsoleTriggerProps) {\n const context = useCopilotContext();\n const hasApiKey = Boolean(context.copilotApiConfig.publicApiKey);\n const [isModalOpen, setIsModalOpen] = useState(false);\n const [isHovered, setIsHovered] = useState(false);\n const [isDragging, setIsDragging] = useState(false);\n const [buttonPosition, setButtonPosition] = useState<{ x: number; y: number } | null>(null);\n const [mounted, setMounted] = useState(false);\n\n const dragRef = useRef<{\n startX: number;\n startY: number;\n buttonX: number;\n buttonY: number;\n } | null>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n\n // Initialize on client side only\n useEffect(() => {\n setMounted(true);\n if (typeof window !== \"undefined\" && !buttonPosition) {\n const buttonSize = 60;\n const margin = 24;\n\n const initialPosition = {\n x: margin,\n y: window.innerHeight - buttonSize - margin,\n };\n\n setButtonPosition(initialPosition);\n }\n }, [position]);\n\n const handleMouseDown = (e: React.MouseEvent) => {\n e.preventDefault();\n if (!buttonPosition) return;\n\n dragRef.current = {\n startX: e.clientX,\n startY: e.clientY,\n buttonX: buttonPosition.x,\n buttonY: buttonPosition.y,\n };\n setIsDragging(true);\n };\n\n useEffect(() => {\n if (!isDragging) return;\n\n const handleMouseMove = (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n\n if (!dragRef.current) return;\n\n const deltaX = e.clientX - dragRef.current.startX;\n const deltaY = e.clientY - dragRef.current.startY;\n\n // Calculate new position\n let newX = dragRef.current.buttonX + deltaX;\n let newY = dragRef.current.buttonY + deltaY;\n\n // Keep button within viewport bounds\n newX = Math.max(0, Math.min(newX, window.innerWidth - 60));\n newY = Math.max(0, Math.min(newY, window.innerHeight - 60));\n\n setButtonPosition({ x: newX, y: newY });\n };\n\n const handleMouseUp = (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n setIsDragging(false);\n dragRef.current = null;\n };\n\n // Use capture phase to intercept events before they reach other handlers\n document.addEventListener(\"mousemove\", handleMouseMove, { capture: true, passive: false });\n document.addEventListener(\"mouseup\", handleMouseUp, { capture: true, passive: false });\n\n return () => {\n document.removeEventListener(\"mousemove\", handleMouseMove, { capture: true });\n document.removeEventListener(\"mouseup\", handleMouseUp, { capture: true });\n };\n }, [isDragging]);\n\n // Don't render until mounted and position is initialized\n if (!mounted || !buttonPosition) {\n return null;\n }\n\n return (\n <>\n <button\n ref={buttonRef}\n onClick={() => {\n if (!isDragging) {\n setIsModalOpen(true);\n }\n }}\n onMouseDown={handleMouseDown}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n style={{\n position: \"fixed\",\n left: `${buttonPosition.x}px`,\n top: `${buttonPosition.y}px`,\n zIndex: 2147483647,\n width: \"60px\",\n height: \"60px\",\n background: isDragging ? \"#000000\" : isHovered ? \"#111111\" : \"#000000\",\n color: \"white\",\n borderRadius: \"50%\",\n boxShadow: isDragging\n ? \"0 8px 32px rgba(0, 0, 0, 0.6), 0 4px 16px rgba(0, 0, 0, 0.4)\"\n : isHovered\n ? \"0 12px 40px rgba(0, 0, 0, 0.7), 0 6px 20px rgba(0, 0, 0, 0.5)\"\n : \"0 6px 20px rgba(0, 0, 0, 0.5), 0 3px 10px rgba(0, 0, 0, 0.3)\",\n transition: isDragging ? \"none\" : \"all 0.3s cubic-bezier(0.4, 0, 0.2, 1)\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n border: \"none\",\n cursor: isDragging ? \"grabbing\" : \"grab\",\n opacity: 1,\n userSelect: \"none\",\n transform: isDragging ? \"scale(1.05)\" : isHovered ? \"scale(1.1)\" : \"scale(1)\",\n backdropFilter: \"blur(10px)\",\n pointerEvents: \"auto\",\n isolation: \"isolate\",\n }}\n title={\n hasApiKey\n ? \"Open Developer Console (Drag to move)\"\n : \"Developer Console (API Key Required, Drag to move)\"\n }\n >\n <div\n style={{\n width: \"28px\",\n height: \"28px\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n filter: \"drop-shadow(0 2px 4px rgba(0,0,0,0.2))\",\n }}\n >\n <CopilotKitIcon />\n </div>\n {!hasApiKey && (\n <div\n style={{\n position: \"absolute\",\n top: \"-2px\",\n right: \"-2px\",\n width: \"18px\",\n height: \"18px\",\n background: \"linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%)\",\n borderRadius: \"50%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n boxShadow: \"0 2px 8px rgba(255, 107, 107, 0.4)\",\n border: \"2px solid white\",\n }}\n >\n <span style={{ fontSize: \"10px\", color: \"white\", fontWeight: \"bold\" }}>!</span>\n </div>\n )}\n </button>\n\n <DeveloperConsoleModal\n isOpen={isModalOpen}\n onClose={() => setIsModalOpen(false)}\n hasApiKey={hasApiKey}\n />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;AAEA,SAAgB,UAAU,WAAW,cAAc;AAqG/C,mBAuDM,KAtDJ,YADF;AA5FG,SAAS,eAAe,EAAE,WAAW,eAAe,GAAwB;AACjF,QAAM,UAAU,kBAAkB;AAClC,QAAM,YAAY,QAAQ,QAAQ,iBAAiB,YAAY;AAC/D,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,KAAK;AACpD,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAClD,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAA0C,IAAI;AAC1F,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAE5C,QAAM,UAAU,OAKN,IAAI;AACd,QAAM,YAAY,OAA0B,IAAI;AAGhD,YAAU,MAAM;AACd,e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AA,gBAChB,QAAQ;AAAA,cACV;AAAA,cAEA,8BAAC,kBAAe;AAAA;AAAA,UAClB;AAAA,UACC,CAAC,aACA;AAAA,YAAC;AAAA;AAAA,cACC,OAAO;AAAA,gBACL,UAAU;AAAA,gBACV,KAAK;AAAA,gBACL,OAAO;AAAA,gBACP,OAAO;AAAA,gBACP,QAAQ;AAAA,gBACR,YAAY;AAAA,gBACZ,cAAc;AAAA,gBACd,SAAS;AAAA,gBACT,YAAY;AAAA,gBACZ,gBAAgB;AAAA,gBAChB,WAAW;AAAA,gBACX,QAAQ;AAAA,cACV;AAAA,cAEA,8BAAC,UAAK,OAAO,EAAE,UAAU,QAAQ,OAAO,SAAS,YAAY,OAAO,GAAG,eAAC;AAAA;AAAA,UAC1E;AAAA;AAAA;AAAA,IAEJ;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,QAAQ;AAAA,QACR,SAAS,MAAM,eAAe,KAAK;AAAA,QACnC;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CopilotErrorBoundary
|
|
3
|
+
} from "./chunk-N4VN2B5S.mjs";
|
|
1
4
|
import {
|
|
2
5
|
CopilotMessages,
|
|
3
6
|
MessagesTapProvider
|
|
4
7
|
} from "./chunk-MUDXTKXE.mjs";
|
|
5
8
|
import {
|
|
6
|
-
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import {
|
|
9
|
-
StatusChecker
|
|
10
|
-
} from "./chunk-PMAFHQ7P.mjs";
|
|
9
|
+
ConsoleTrigger
|
|
10
|
+
} from "./chunk-3BASANUO.mjs";
|
|
11
11
|
import {
|
|
12
12
|
use_flat_category_store_default
|
|
13
13
|
} from "./chunk-5FHSUKQL.mjs";
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
import {
|
|
27
27
|
UsageBanner,
|
|
28
28
|
getErrorActions
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-6ZLPNY7X.mjs";
|
|
30
30
|
import {
|
|
31
31
|
CopilotContext
|
|
32
32
|
} from "./chunk-TEMLWRRT.mjs";
|
|
@@ -198,11 +198,13 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
198
198
|
function CopilotKit(_a) {
|
|
199
199
|
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
200
200
|
const enabled = shouldShowDevConsole(props.showDevConsole);
|
|
201
|
-
|
|
201
|
+
const publicApiKey = props.publicApiKey || props.publicLicenseKey;
|
|
202
|
+
return /* @__PURE__ */ jsx(ToastProvider, { enabled, children: /* @__PURE__ */ jsx(CopilotErrorBoundary, { publicApiKey, showUsageBanner: enabled, children: /* @__PURE__ */ jsx(CopilotKitInternal, __spreadProps(__spreadValues({}, props), { children })) }) });
|
|
202
203
|
}
|
|
203
204
|
function CopilotKitInternal(cpkProps) {
|
|
204
205
|
const _a = cpkProps, { children } = _a, props = __objRest(_a, ["children"]);
|
|
205
206
|
validateProps(cpkProps);
|
|
207
|
+
const publicApiKey = props.publicLicenseKey || props.publicApiKey;
|
|
206
208
|
const chatApiEndpoint = props.runtimeUrl || COPILOT_CLOUD_CHAT_URL;
|
|
207
209
|
const [actions, setActions] = useState({});
|
|
208
210
|
const [coAgentStateRenders, setCoAgentStateRenders] = useState({});
|
|
@@ -221,8 +223,6 @@ function CopilotKitInternal(cpkProps) {
|
|
|
221
223
|
removeElement: removeDocument,
|
|
222
224
|
allElements: allDocuments
|
|
223
225
|
} = use_flat_category_store_default();
|
|
224
|
-
const statusChecker = useMemo(() => new StatusChecker(), []);
|
|
225
|
-
const [usageBannerStatus, setUsageBannerStatus] = useState(null);
|
|
226
226
|
const setAction = useCallback((id, action) => {
|
|
227
227
|
setActions((prevPoints) => {
|
|
228
228
|
return __spreadProps(__spreadValues({}, prevPoints), {
|
|
@@ -306,7 +306,7 @@ ${nonDocumentStrings}`;
|
|
|
306
306
|
const copilotApiConfig = useMemo(() => {
|
|
307
307
|
var _a2, _b;
|
|
308
308
|
let cloud = void 0;
|
|
309
|
-
if (
|
|
309
|
+
if (publicApiKey) {
|
|
310
310
|
cloud = {
|
|
311
311
|
guardrails: {
|
|
312
312
|
input: {
|
|
@@ -320,7 +320,7 @@ ${nonDocumentStrings}`;
|
|
|
320
320
|
};
|
|
321
321
|
}
|
|
322
322
|
return __spreadProps(__spreadValues({
|
|
323
|
-
publicApiKey
|
|
323
|
+
publicApiKey
|
|
324
324
|
}, cloud ? { cloud } : {}), {
|
|
325
325
|
chatApiEndpoint,
|
|
326
326
|
headers: props.headers || {},
|
|
@@ -330,7 +330,7 @@ ${nonDocumentStrings}`;
|
|
|
330
330
|
credentials: props.credentials
|
|
331
331
|
});
|
|
332
332
|
}, [
|
|
333
|
-
|
|
333
|
+
publicApiKey,
|
|
334
334
|
props.headers,
|
|
335
335
|
props.properties,
|
|
336
336
|
props.transcribeAudioUrl,
|
|
@@ -355,7 +355,7 @@ ${nonDocumentStrings}`;
|
|
|
355
355
|
}, [copilotApiConfig.headers, copilotApiConfig.publicApiKey, authStates]);
|
|
356
356
|
const runtimeClient = useCopilotRuntimeClient({
|
|
357
357
|
url: copilotApiConfig.chatApiEndpoint,
|
|
358
|
-
publicApiKey
|
|
358
|
+
publicApiKey,
|
|
359
359
|
headers,
|
|
360
360
|
credentials: copilotApiConfig.credentials,
|
|
361
361
|
showDevConsole: shouldShowDevConsole(props.showDevConsole),
|
|
@@ -550,7 +550,10 @@ ${nonDocumentStrings}`;
|
|
|
550
550
|
setBannerError
|
|
551
551
|
},
|
|
552
552
|
children: [
|
|
553
|
-
/* @__PURE__ */ jsx(MessagesTapProvider, { children: /* @__PURE__ */
|
|
553
|
+
/* @__PURE__ */ jsx(MessagesTapProvider, { children: /* @__PURE__ */ jsxs(CopilotMessages, { children: [
|
|
554
|
+
memoizedChildren,
|
|
555
|
+
showDevConsole && /* @__PURE__ */ jsx(ConsoleTrigger, {})
|
|
556
|
+
] }) }),
|
|
554
557
|
bannerError && showDevConsole && /* @__PURE__ */ jsx(
|
|
555
558
|
UsageBanner,
|
|
556
559
|
{
|
|
@@ -595,12 +598,15 @@ function formatFeatureName(featureName) {
|
|
|
595
598
|
}
|
|
596
599
|
function validateProps(props) {
|
|
597
600
|
const cloudFeatures = Object.keys(props).filter((key) => key.endsWith("_c"));
|
|
598
|
-
|
|
599
|
-
|
|
601
|
+
const hasApiKey = props.publicApiKey || props.publicLicenseKey;
|
|
602
|
+
if (!props.runtimeUrl && !hasApiKey) {
|
|
603
|
+
throw new ConfigurationError(
|
|
604
|
+
"Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'"
|
|
605
|
+
);
|
|
600
606
|
}
|
|
601
|
-
if (cloudFeatures.length > 0 && !
|
|
607
|
+
if (cloudFeatures.length > 0 && !hasApiKey) {
|
|
602
608
|
throw new MissingPublicApiKeyError(
|
|
603
|
-
`Missing required prop: 'publicApiKey' to use cloud features: ${cloudFeatures.map(formatFeatureName).join(", ")}`
|
|
609
|
+
`Missing required prop: 'publicApiKey' or 'publicLicenseKey' to use cloud features: ${cloudFeatures.map(formatFeatureName).join(", ")}`
|
|
604
610
|
);
|
|
605
611
|
}
|
|
606
612
|
}
|
|
@@ -747,4 +753,4 @@ export {
|
|
|
747
753
|
CopilotKitInternal,
|
|
748
754
|
defaultCopilotContextCategories
|
|
749
755
|
};
|
|
750
|
-
//# sourceMappingURL=chunk-
|
|
756
|
+
//# sourceMappingURL=chunk-5P46WS5M.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/extract.ts","../src/components/copilot-provider/copilotkit.tsx","../src/utils/suggestions.ts"],"sourcesContent":["import {\n Action,\n COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,\n MappedParameterTypes,\n Parameter,\n actionParametersToJsonSchema,\n} from \"@copilotkit/shared\";\nimport {\n ActionExecutionMessage,\n Message,\n Role,\n TextMessage,\n convertGqlOutputToMessages,\n CopilotRequestType,\n ForwardedParametersInput,\n} from \"@copilotkit/runtime-client-gql\";\nimport { CopilotContextParams, CopilotMessagesContextParams } from \"../context\";\nimport { defaultCopilotContextCategories } from \"../components\";\nimport { CopilotRuntimeClient } from \"@copilotkit/runtime-client-gql\";\nimport {\n convertMessagesToGqlInput,\n filterAgentStateMessages,\n} from \"@copilotkit/runtime-client-gql\";\n\ninterface InitialState<T extends Parameter[] | [] = []> {\n status: \"initial\";\n args: Partial<MappedParameterTypes<T>>;\n}\n\ninterface InProgressState<T extends Parameter[] | [] = []> {\n status: \"inProgress\";\n args: Partial<MappedParameterTypes<T>>;\n}\n\ninterface CompleteState<T extends Parameter[] | [] = []> {\n status: \"complete\";\n args: MappedParameterTypes<T>;\n}\n\ntype StreamHandlerArgs<T extends Parameter[] | [] = []> =\n | InitialState<T>\n | InProgressState<T>\n | CompleteState<T>;\n\ninterface ExtractOptions<T extends Parameter[]> {\n context: CopilotContextParams & CopilotMessagesContextParams;\n instructions: string;\n parameters: T;\n include?: IncludeOptions;\n data?: any;\n abortSignal?: AbortSignal;\n stream?: (args: StreamHandlerArgs<T>) => void;\n requestType?: CopilotRequestType;\n forwardedParameters?: ForwardedParametersInput;\n}\n\ninterface IncludeOptions {\n readable?: boolean;\n messages?: boolean;\n}\n\nexport async function extract<const T extends Parameter[]>({\n context,\n instructions,\n parameters,\n include,\n data,\n abortSignal,\n stream,\n requestType = CopilotRequestType.Task,\n forwardedParameters,\n}: ExtractOptions<T>): Promise<MappedParameterTypes<T>> {\n const { messages } = context;\n\n const action: Action<any> = {\n name: \"extract\",\n description: instructions,\n parameters,\n handler: (args: any) => {},\n };\n\n const includeReadable = include?.readable ?? false;\n const includeMessages = include?.messages ?? false;\n\n let contextString = \"\";\n\n if (data) {\n contextString = (typeof data === \"string\" ? data : JSON.stringify(data)) + \"\\n\\n\";\n }\n\n if (includeReadable) {\n contextString += context.getContextString([], defaultCopilotContextCategories);\n }\n\n const systemMessage: Message = new TextMessage({\n content: makeSystemMessage(contextString, instructions),\n role: Role.System,\n });\n\n const instructionsMessage: Message = new TextMessage({\n content: makeInstructionsMessage(instructions),\n role: Role.User,\n });\n\n const response = context.runtimeClient.asStream(\n context.runtimeClient.generateCopilotResponse({\n data: {\n frontend: {\n actions: [\n {\n name: action.name,\n description: action.description || \"\",\n jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters || [])),\n },\n ],\n url: window.location.href,\n },\n\n messages: convertMessagesToGqlInput(\n includeMessages\n ? [systemMessage, instructionsMessage, ...filterAgentStateMessages(messages)]\n : [systemMessage, instructionsMessage],\n ),\n metadata: {\n requestType: requestType,\n },\n forwardedParameters: {\n ...(forwardedParameters ?? {}),\n toolChoice: \"function\",\n toolChoiceFunctionName: action.name,\n },\n },\n properties: context.copilotApiConfig.properties,\n signal: abortSignal,\n }),\n );\n\n const reader = response.getReader();\n\n let isInitial = true;\n\n let actionExecutionMessage: ActionExecutionMessage | undefined = undefined;\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) {\n break;\n }\n\n if (abortSignal?.aborted) {\n throw new Error(\"Aborted\");\n }\n\n actionExecutionMessage = convertGqlOutputToMessages(\n value.generateCopilotResponse.messages,\n ).find((msg) => msg.isActionExecutionMessage()) as ActionExecutionMessage | undefined;\n\n if (!actionExecutionMessage) {\n continue;\n }\n\n stream?.({\n status: isInitial ? \"initial\" : \"inProgress\",\n args: actionExecutionMessage.arguments as Partial<MappedParameterTypes<T>>,\n });\n\n isInitial = false;\n }\n\n if (!actionExecutionMessage) {\n throw new Error(\"extract() failed: No function call occurred\");\n }\n\n stream?.({\n status: \"complete\",\n args: actionExecutionMessage.arguments as MappedParameterTypes<T>,\n });\n\n return actionExecutionMessage.arguments as MappedParameterTypes<T>;\n}\n\n// We need to put this in a user message since some LLMs need\n// at least one user message to function\nfunction makeInstructionsMessage(instructions: string): string {\n return `\nThe user has given you the following task to complete:\n\n\\`\\`\\`\n${instructions}\n\\`\\`\\`\n\nAny additional messages provided are for providing context only and should not be used to ask questions or engage in conversation.\n`;\n}\n\nfunction makeSystemMessage(contextString: string, instructions: string): string {\n return `\nPlease act as an efficient, competent, conscientious, and industrious professional assistant.\n\nHelp the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.\nAlways be polite and respectful, and prefer brevity over verbosity.\n\nThe user has provided you with the following context:\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThey have also provided you with a function called extract you MUST call to initiate actions on their behalf.\n\nPlease assist them as best you can.\n\nThis is not a conversation, so please do not ask questions. Just call the function without saying anything else.\n`;\n}\n","/**\n * This component will typically wrap your entire application (or a sub-tree of your application where you want to have a copilot). It provides the copilot context to all other components and hooks.\n *\n * ## Example\n *\n * You can find more information about self-hosting CopilotKit [here](/guides/self-hosting).\n *\n * ```tsx\n * import { CopilotKit } from \"@copilotkit/react-core\";\n *\n * <CopilotKit runtimeUrl=\"<your-runtime-url>\">\n * // ... your app ...\n * </CopilotKit>\n * ```\n */\n\nimport { useCallback, useEffect, useMemo, useRef, useState, SetStateAction } from \"react\";\nimport {\n CopilotContext,\n CopilotApiConfig,\n ChatComponentsCache,\n AgentSession,\n AuthState,\n} from \"../../context/copilot-context\";\nimport useTree from \"../../hooks/use-tree\";\nimport { CopilotChatSuggestionConfiguration, DocumentPointer } from \"../../types\";\nimport { flushSync } from \"react-dom\";\nimport {\n COPILOT_CLOUD_CHAT_URL,\n CopilotCloudConfig,\n FunctionCallHandler,\n COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,\n randomUUID,\n ConfigurationError,\n MissingPublicApiKeyError,\n CopilotKitError,\n} from \"@copilotkit/shared\";\nimport { FrontendAction } from \"../../types/frontend-action\";\nimport useFlatCategoryStore from \"../../hooks/use-flat-category-store\";\nimport { CopilotKitProps } from \"./copilotkit-props\";\nimport { CoAgentStateRender } from \"../../types/coagent-action\";\nimport { CoagentState } from \"../../types/coagent-state\";\nimport { CopilotMessages, MessagesTapProvider } from \"./copilot-messages\";\nimport { ToastProvider } from \"../toast/toast-provider\";\nimport { getErrorActions, UsageBanner } from \"../usage-banner\";\nimport { useCopilotRuntimeClient } from \"../../hooks/use-copilot-runtime-client\";\nimport { shouldShowDevConsole } from \"../../utils\";\nimport { CopilotErrorBoundary } from \"../error-boundary/error-boundary\";\nimport { Agent, ExtensionsInput } from \"@copilotkit/runtime-client-gql\";\nimport {\n LangGraphInterruptAction,\n LangGraphInterruptActionSetterArgs,\n} from \"../../types/interrupt-action\";\nimport { ConsoleTrigger } from \"../dev-console/console-trigger\";\n\nexport function CopilotKit({ children, ...props }: CopilotKitProps) {\n const enabled = shouldShowDevConsole(props.showDevConsole);\n\n // Use API key if provided, otherwise use the license key\n const publicApiKey = props.publicApiKey || props.publicLicenseKey;\n\n return (\n <ToastProvider enabled={enabled}>\n <CopilotErrorBoundary publicApiKey={publicApiKey} showUsageBanner={enabled}>\n <CopilotKitInternal {...props}>{children}</CopilotKitInternal>\n </CopilotErrorBoundary>\n </ToastProvider>\n );\n}\n\nexport function CopilotKitInternal(cpkProps: CopilotKitProps) {\n const { children, ...props } = cpkProps;\n\n /**\n * This will throw an error if the props are invalid.\n */\n validateProps(cpkProps);\n\n // Use license key as API key if provided, otherwise use the API key\n const publicApiKey = props.publicLicenseKey || props.publicApiKey;\n\n const chatApiEndpoint = props.runtimeUrl || COPILOT_CLOUD_CHAT_URL;\n\n const [actions, setActions] = useState<Record<string, FrontendAction<any>>>({});\n const [coAgentStateRenders, setCoAgentStateRenders] = useState<\n Record<string, CoAgentStateRender<any>>\n >({});\n\n const chatComponentsCache = useRef<ChatComponentsCache>({\n actions: {},\n coAgentStateRenders: {},\n });\n\n const { addElement, removeElement, printTree, getAllElements } = useTree();\n const [isLoading, setIsLoading] = useState(false);\n const [chatInstructions, setChatInstructions] = useState(\"\");\n const [authStates, setAuthStates] = useState<Record<string, AuthState>>({});\n const [extensions, setExtensions] = useState<ExtensionsInput>({});\n const [additionalInstructions, setAdditionalInstructions] = useState<string[]>([]);\n\n const {\n addElement: addDocument,\n removeElement: removeDocument,\n allElements: allDocuments,\n } = useFlatCategoryStore<DocumentPointer>();\n\n // Compute all the functions and properties that we need to pass\n const setAction = useCallback((id: string, action: FrontendAction<any>) => {\n setActions((prevPoints) => {\n return {\n ...prevPoints,\n [id]: action,\n };\n });\n }, []);\n\n const removeAction = useCallback((id: string) => {\n setActions((prevPoints) => {\n const newPoints = { ...prevPoints };\n delete newPoints[id];\n return newPoints;\n });\n }, []);\n\n const setCoAgentStateRender = useCallback((id: string, stateRender: CoAgentStateRender<any>) => {\n setCoAgentStateRenders((prevPoints) => {\n return {\n ...prevPoints,\n [id]: stateRender,\n };\n });\n }, []);\n\n const removeCoAgentStateRender = useCallback((id: string) => {\n setCoAgentStateRenders((prevPoints) => {\n const newPoints = { ...prevPoints };\n delete newPoints[id];\n return newPoints;\n });\n }, []);\n\n const getContextString = useCallback(\n (documents: DocumentPointer[], categories: string[]) => {\n const documentsString = documents\n .map((document) => {\n return `${document.name} (${document.sourceApplication}):\\n${document.getContents()}`;\n })\n .join(\"\\n\\n\");\n\n const nonDocumentStrings = printTree(categories);\n\n return `${documentsString}\\n\\n${nonDocumentStrings}`;\n },\n [printTree],\n );\n\n const addContext = useCallback(\n (\n context: string,\n parentId?: string,\n categories: string[] = defaultCopilotContextCategories,\n ) => {\n return addElement(context, categories, parentId);\n },\n [addElement],\n );\n\n const removeContext = useCallback(\n (id: string) => {\n removeElement(id);\n },\n [removeElement],\n );\n\n const getAllContext = useCallback(() => {\n return getAllElements();\n }, [getAllElements]);\n\n const getFunctionCallHandler = useCallback(\n (customEntryPoints?: Record<string, FrontendAction<any>>) => {\n return entryPointsToFunctionCallHandler(Object.values(customEntryPoints || actions));\n },\n [actions],\n );\n\n const getDocumentsContext = useCallback(\n (categories: string[]) => {\n return allDocuments(categories);\n },\n [allDocuments],\n );\n\n const addDocumentContext = useCallback(\n (documentPointer: DocumentPointer, categories: string[] = defaultCopilotContextCategories) => {\n return addDocument(documentPointer, categories);\n },\n [addDocument],\n );\n\n const removeDocumentContext = useCallback(\n (documentId: string) => {\n removeDocument(documentId);\n },\n [removeDocument],\n );\n\n // get the appropriate CopilotApiConfig from the props\n const copilotApiConfig: CopilotApiConfig = useMemo(() => {\n let cloud: CopilotCloudConfig | undefined = undefined;\n if (publicApiKey) {\n cloud = {\n guardrails: {\n input: {\n restrictToTopic: {\n enabled: Boolean(props.guardrails_c),\n validTopics: props.guardrails_c?.validTopics || [],\n invalidTopics: props.guardrails_c?.invalidTopics || [],\n },\n },\n },\n };\n }\n\n return {\n publicApiKey: publicApiKey,\n ...(cloud ? { cloud } : {}),\n chatApiEndpoint: chatApiEndpoint,\n headers: props.headers || {},\n properties: props.properties || {},\n transcribeAudioUrl: props.transcribeAudioUrl,\n textToSpeechUrl: props.textToSpeechUrl,\n credentials: props.credentials,\n };\n }, [\n publicApiKey,\n props.headers,\n props.properties,\n props.transcribeAudioUrl,\n props.textToSpeechUrl,\n props.credentials,\n props.cloudRestrictToTopic,\n props.guardrails_c,\n ]);\n\n const headers = useMemo(() => {\n const authHeaders = Object.values(authStates || {}).reduce((acc, state) => {\n if (state.status === \"authenticated\" && state.authHeaders) {\n return {\n ...acc,\n ...Object.entries(state.authHeaders).reduce(\n (headers, [key, value]) => ({\n ...headers,\n [key.startsWith(\"X-Custom-\") ? key : `X-Custom-${key}`]: value,\n }),\n {},\n ),\n };\n }\n return acc;\n }, {});\n\n return {\n ...(copilotApiConfig.headers || {}),\n ...(copilotApiConfig.publicApiKey\n ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey }\n : {}),\n ...authHeaders,\n };\n }, [copilotApiConfig.headers, copilotApiConfig.publicApiKey, authStates]);\n\n const runtimeClient = useCopilotRuntimeClient({\n url: copilotApiConfig.chatApiEndpoint,\n publicApiKey: publicApiKey,\n headers,\n credentials: copilotApiConfig.credentials,\n showDevConsole: shouldShowDevConsole(props.showDevConsole),\n onError: props.onError,\n });\n\n const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = useState<{\n [key: string]: CopilotChatSuggestionConfiguration;\n }>({});\n\n const addChatSuggestionConfiguration = useCallback(\n (id: string, suggestion: CopilotChatSuggestionConfiguration) => {\n setChatSuggestionConfiguration((prev) => ({ ...prev, [id]: suggestion }));\n },\n [setChatSuggestionConfiguration],\n );\n\n const removeChatSuggestionConfiguration = useCallback(\n (id: string) => {\n setChatSuggestionConfiguration((prev) => {\n const { [id]: _, ...rest } = prev;\n return rest;\n });\n },\n [setChatSuggestionConfiguration],\n );\n\n const [availableAgents, setAvailableAgents] = useState<Agent[]>([]);\n const [coagentStates, setCoagentStates] = useState<Record<string, CoagentState>>({});\n const coagentStatesRef = useRef<Record<string, CoagentState>>({});\n const setCoagentStatesWithRef = useCallback(\n (\n value:\n | Record<string, CoagentState>\n | ((prev: Record<string, CoagentState>) => Record<string, CoagentState>),\n ) => {\n const newValue = typeof value === \"function\" ? value(coagentStatesRef.current) : value;\n coagentStatesRef.current = newValue;\n setCoagentStates((prev) => {\n return newValue;\n });\n },\n [],\n );\n const hasLoadedAgents = useRef(false);\n\n useEffect(() => {\n if (hasLoadedAgents.current) return;\n\n const fetchData = async () => {\n const result = await runtimeClient.availableAgents();\n if (result.data?.availableAgents) {\n setAvailableAgents(result.data.availableAgents.agents);\n }\n hasLoadedAgents.current = true;\n };\n void fetchData();\n }, []);\n\n let initialAgentSession: AgentSession | null = null;\n if (props.agent) {\n initialAgentSession = {\n agentName: props.agent,\n };\n }\n\n const [agentSession, setAgentSession] = useState<AgentSession | null>(initialAgentSession);\n\n // Update agentSession when props.agent changes\n useEffect(() => {\n if (props.agent) {\n setAgentSession({\n agentName: props.agent,\n });\n } else {\n setAgentSession(null);\n }\n }, [props.agent]);\n\n const [internalThreadId, setInternalThreadId] = useState<string>(props.threadId || randomUUID());\n const setThreadId = useCallback(\n (value: SetStateAction<string>) => {\n if (props.threadId) {\n throw new Error(\"Cannot call setThreadId() when threadId is provided via props.\");\n }\n setInternalThreadId(value);\n },\n [props.threadId],\n );\n\n // update the internal threadId if the props.threadId changes\n useEffect(() => {\n if (props.threadId !== undefined) {\n setInternalThreadId(props.threadId);\n }\n }, [props.threadId]);\n\n const [runId, setRunId] = useState<string | null>(null);\n\n const chatAbortControllerRef = useRef<AbortController | null>(null);\n\n const showDevConsole = shouldShowDevConsole(props.showDevConsole);\n\n const [langGraphInterruptAction, _setLangGraphInterruptAction] =\n useState<LangGraphInterruptAction | null>(null);\n const setLangGraphInterruptAction = useCallback((action: LangGraphInterruptActionSetterArgs) => {\n _setLangGraphInterruptAction((prev) => {\n if (prev == null) return action as LangGraphInterruptAction;\n if (action == null) return null;\n let event = prev.event;\n if (action.event) {\n // @ts-ignore\n event = { ...prev.event, ...action.event };\n }\n return { ...prev, ...action, event };\n });\n }, []);\n const removeLangGraphInterruptAction = useCallback((): void => {\n setLangGraphInterruptAction(null);\n }, []);\n\n const memoizedChildren = useMemo(() => children, [children]);\n const [bannerError, setBannerError] = useState<CopilotKitError | null>(null);\n\n const agentLock = useMemo(() => props.agent ?? null, [props.agent]);\n\n const forwardedParameters = useMemo(\n () => props.forwardedParameters ?? {},\n [props.forwardedParameters],\n );\n\n const updateExtensions = useCallback(\n (newExtensions: SetStateAction<ExtensionsInput>) => {\n setExtensions((prev: ExtensionsInput) => {\n const resolved = typeof newExtensions === \"function\" ? newExtensions(prev) : newExtensions;\n const isSameLength = Object.keys(resolved).length === Object.keys(prev).length;\n const isEqual =\n isSameLength &&\n // @ts-ignore\n Object.entries(resolved).every(([key, value]) => prev[key] === value);\n\n return isEqual ? prev : resolved;\n });\n },\n [setExtensions],\n );\n\n const updateAuthStates = useCallback(\n (newAuthStates: SetStateAction<Record<string, AuthState>>) => {\n setAuthStates((prev) => {\n const resolved = typeof newAuthStates === \"function\" ? newAuthStates(prev) : newAuthStates;\n const isSameLength = Object.keys(resolved).length === Object.keys(prev).length;\n const isEqual =\n isSameLength &&\n // @ts-ignore\n Object.entries(resolved).every(([key, value]) => prev[key] === value);\n\n return isEqual ? prev : resolved;\n });\n },\n [setAuthStates],\n );\n\n return (\n <CopilotContext.Provider\n value={{\n actions,\n chatComponentsCache,\n getFunctionCallHandler,\n setAction,\n removeAction,\n coAgentStateRenders,\n setCoAgentStateRender,\n removeCoAgentStateRender,\n getContextString,\n addContext,\n removeContext,\n getAllContext,\n getDocumentsContext,\n addDocumentContext,\n removeDocumentContext,\n copilotApiConfig: copilotApiConfig,\n isLoading,\n setIsLoading,\n chatSuggestionConfiguration,\n addChatSuggestionConfiguration,\n removeChatSuggestionConfiguration,\n chatInstructions,\n setChatInstructions,\n additionalInstructions,\n setAdditionalInstructions,\n showDevConsole,\n coagentStates,\n setCoagentStates,\n coagentStatesRef,\n setCoagentStatesWithRef,\n agentSession,\n setAgentSession,\n runtimeClient,\n forwardedParameters,\n agentLock,\n threadId: internalThreadId,\n setThreadId,\n runId,\n setRunId,\n chatAbortControllerRef,\n availableAgents,\n authConfig_c: props.authConfig_c,\n authStates_c: authStates,\n setAuthStates_c: updateAuthStates,\n extensions,\n setExtensions: updateExtensions,\n langGraphInterruptAction,\n setLangGraphInterruptAction,\n removeLangGraphInterruptAction,\n onError: props.onError,\n bannerError,\n setBannerError,\n }}\n >\n <MessagesTapProvider>\n <CopilotMessages>\n {memoizedChildren}\n {showDevConsole && <ConsoleTrigger />}\n </CopilotMessages>\n </MessagesTapProvider>\n {bannerError && showDevConsole && (\n <UsageBanner\n severity={bannerError.severity}\n message={bannerError.message}\n onClose={() => setBannerError(null)}\n actions={getErrorActions(bannerError)}\n />\n )}\n </CopilotContext.Provider>\n );\n}\n\nexport const defaultCopilotContextCategories = [\"global\"];\n\nfunction entryPointsToFunctionCallHandler(actions: FrontendAction<any>[]): FunctionCallHandler {\n return async ({ name, args }: { name: string; args: Record<string, any> }) => {\n let actionsByFunctionName: Record<string, FrontendAction<any>> = {};\n for (let action of actions) {\n actionsByFunctionName[action.name] = action;\n }\n\n const action = actionsByFunctionName[name];\n let result: any = undefined;\n if (action) {\n await new Promise<void>((resolve, reject) => {\n flushSync(async () => {\n try {\n result = await action.handler?.(args);\n resolve();\n } catch (error) {\n reject(error);\n }\n });\n });\n await new Promise((resolve) => setTimeout(resolve, 20));\n }\n return result;\n };\n}\n\nfunction formatFeatureName(featureName: string): string {\n return featureName\n .replace(/_c$/, \"\")\n .split(\"_\")\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(\" \");\n}\n\nfunction validateProps(props: CopilotKitProps): never | void {\n const cloudFeatures = Object.keys(props).filter((key) => key.endsWith(\"_c\"));\n\n // Check if we have either a runtimeUrl or one of the API keys\n const hasApiKey = props.publicApiKey || props.publicLicenseKey;\n\n if (!props.runtimeUrl && !hasApiKey) {\n throw new ConfigurationError(\n \"Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'\",\n );\n }\n\n if (cloudFeatures.length > 0 && !hasApiKey) {\n throw new MissingPublicApiKeyError(\n `Missing required prop: 'publicApiKey' or 'publicLicenseKey' to use cloud features: ${cloudFeatures\n .map(formatFeatureName)\n .join(\", \")}`,\n );\n }\n}\n","/**\n * Suggestions utility functions for CopilotKit\n *\n * This module handles the generation of chat suggestions with optimized error handling\n * and streaming validation to prevent infinite retry loops and console spam.\n */\n\nimport { extract } from \"./extract\";\nimport { actionParametersToJsonSchema } from \"@copilotkit/shared\";\nimport { CopilotRequestType } from \"@copilotkit/runtime-client-gql\";\nimport { CopilotContextParams, CopilotMessagesContextParams } from \"../context\";\nimport { CopilotChatSuggestionConfiguration } from \"../types\";\n\nexport interface SuggestionItem {\n title: string;\n message: string;\n partial?: boolean;\n className?: string;\n}\n\nexport const reloadSuggestions = async (\n context: CopilotContextParams & CopilotMessagesContextParams,\n chatSuggestionConfiguration: { [key: string]: CopilotChatSuggestionConfiguration },\n setCurrentSuggestions: (suggestions: SuggestionItem[]) => void,\n abortControllerRef: React.MutableRefObject<AbortController | null>,\n): Promise<void> => {\n const abortController = abortControllerRef.current;\n\n // Early abort check\n if (abortController?.signal.aborted) {\n return;\n }\n\n // Abort-aware suggestion setter with safety checks to prevent race conditions\n const setSuggestionsIfNotAborted = (suggestions: SuggestionItem[]) => {\n if (!abortController?.signal.aborted && abortControllerRef.current === abortController) {\n setCurrentSuggestions(suggestions);\n }\n };\n\n try {\n const tools = JSON.stringify(\n Object.values(context.actions).map((action) => ({\n name: action.name,\n description: action.description,\n jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters)),\n })),\n );\n\n const allSuggestions: SuggestionItem[] = [];\n let hasSuccessfulSuggestions = false;\n let hasErrors = false; // Track if any errors occurred\n let lastError: Error | null = null; // Track the last error for better error reporting\n\n // Get enabled configurations\n const enabledConfigs = Object.values(chatSuggestionConfiguration).filter(\n (config) => config.instructions && config.instructions.trim().length > 0,\n );\n\n if (enabledConfigs.length === 0) {\n return;\n }\n\n // Clear existing suggestions\n setSuggestionsIfNotAborted([]);\n\n // Generate suggestions for each configuration\n for (const config of enabledConfigs) {\n // Check if aborted before each configuration\n if (abortController?.signal.aborted) {\n setSuggestionsIfNotAborted([]);\n return;\n }\n\n try {\n const result = await extract({\n context,\n instructions:\n \"Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. \",\n data: `${config.instructions}\\n\\nAvailable tools: ${tools}\\n\\n`,\n requestType: CopilotRequestType.Task,\n parameters: [\n {\n name: \"suggestions\",\n type: \"object[]\",\n attributes: [\n {\n name: \"title\",\n description:\n \"The title of the suggestion. This is shown as a button and should be short.\",\n type: \"string\",\n },\n {\n name: \"message\",\n description:\n \"The message to send when the suggestion is clicked. This should be a clear, complete sentence and will be sent as an instruction to the AI.\",\n type: \"string\",\n },\n ],\n },\n ],\n include: {\n messages: true,\n readable: true,\n },\n abortSignal: abortController?.signal,\n stream: ({ status, args }: { status: string; args: any }) => {\n // Check abort status in stream callback\n if (abortController?.signal.aborted) {\n return;\n }\n\n const suggestions = args.suggestions || [];\n const newSuggestions: SuggestionItem[] = [];\n\n for (let i = 0; i < suggestions.length; i++) {\n // Respect max suggestions limit\n if (config.maxSuggestions !== undefined && i >= config.maxSuggestions) {\n break;\n }\n\n const suggestion = suggestions[i];\n\n // Skip completely empty or invalid objects during streaming\n if (!suggestion || typeof suggestion !== \"object\") {\n continue;\n }\n\n const { title, message } = suggestion;\n\n // During streaming, be permissive but require at least a meaningful title\n const hasValidTitle = title && typeof title === \"string\" && title.trim().length > 0;\n const hasValidMessage =\n message && typeof message === \"string\" && message.trim().length > 0;\n\n // During streaming, we need at least a title to show something useful\n if (!hasValidTitle) {\n continue;\n }\n\n // Mark as partial if this is the last suggestion and streaming isn't complete\n const partial = i === suggestions.length - 1 && status !== \"complete\";\n\n newSuggestions.push({\n title: title.trim(),\n message: hasValidMessage ? message.trim() : \"\", // Use title as fallback\n partial,\n className: config.className,\n });\n }\n\n // Update suggestions with current batch\n setSuggestionsIfNotAborted([...allSuggestions, ...newSuggestions]);\n },\n });\n\n // Process final results with strict validation\n if (result?.suggestions && Array.isArray(result.suggestions)) {\n const validSuggestions = result.suggestions\n .filter(\n (suggestion: any) =>\n suggestion &&\n typeof suggestion.title === \"string\" &&\n suggestion.title.trim().length > 0,\n )\n .map((suggestion: any) => ({\n title: suggestion.title.trim(),\n message:\n suggestion.message &&\n typeof suggestion.message === \"string\" &&\n suggestion.message.trim()\n ? suggestion.message.trim()\n : suggestion.title.trim(),\n }));\n\n if (validSuggestions.length > 0) {\n allSuggestions.push(...validSuggestions);\n hasSuccessfulSuggestions = true;\n }\n }\n } catch (error) {\n // Simple error handling - just continue with next config, don't log here\n hasErrors = true;\n lastError = error instanceof Error ? error : new Error(String(error));\n }\n }\n\n // Display any successful suggestions we got\n if (hasSuccessfulSuggestions && allSuggestions.length > 0) {\n // Remove duplicates based on message content\n const uniqueSuggestions = allSuggestions.filter(\n (suggestion, index, self) =>\n index === self.findIndex((s) => s.message === suggestion.message),\n );\n\n setSuggestionsIfNotAborted(uniqueSuggestions);\n } else if (hasErrors) {\n // If we had errors but no successful suggestions, throw an error with details\n const errorMessage = lastError\n ? lastError.message\n : \"Failed to generate suggestions due to API errors\";\n throw new Error(errorMessage);\n }\n } catch (error) {\n // Top-level error handler - re-throw to allow caller to handle\n throw error;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EAKE,gCAAAA;AAAA,OACK;AACP;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA,sBAAAC;AAAA,OAEK;;;ACCP,SAAS,aAAa,WAAW,SAAS,QAAQ,gBAAgC;AAUlF,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;AC5BP,SAAS,oCAAoC;AAC7C,SAAS,0BAA0B;AAW5B,IAAM,oBAAoB,CAC/B,SACA,6BACA,uBACA,uBACkB;AAClB,QAAM,kBAAkB,mBAAmB;AAG3C,MAAI,mDAAiB,OAAO,SAAS;AACnC;AAAA,EACF;AAGA,QAAM,6BAA6B,CAAC,gBAAkC;AACpE,QAAI,EAAC,mDAAiB,OAAO,YAAW,mBAAmB,YAAY,iBAAiB;AACtF,4BAAsB,WAAW;AAAA,IACnC;AAAA,EACF;AAEA,MAAI;AACF,UAAM,QAAQ,KAAK;AAAA,MACjB,OAAO,OAAO,QAAQ,OAAO,EAAE,IAAI,CAAC,YAAY;AAAA,QAC9C,MAAM,OAAO;AAAA,QACb,aAAa,OAAO;AAAA,QACpB,YAAY,KAAK,UAAU,6BAA6B,OAAO,UAAU,CAAC;AAAA,MAC5E,EAAE;AAAA,IACJ;AAEA,UAAM,iBAAmC,CAAC;AAC1C,QAAI,2BAA2B;AAC/B,QAAI,YAAY;AAChB,QAAI,YAA0B;AAG9B,UAAM,iBAAiB,OAAO,OAAO,2BAA2B,EAAE;AAAA,MAChE,CAAC,WAAW,OAAO,gBAAgB,OAAO,aAAa,KAAK,EAAE,SAAS;AAAA,IACzE;AAEA,QAAI,eAAe,WAAW,GAAG;AAC/B;AAAA,IACF;AAGA,+B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MACF;AAEA,UAAI,2CAAa,SAAS;AACxB,cAAM,IAAI,MAAM,SAAS;AAAA,MAC3B;AAEA,+BAAyB;AAAA,QACvB,MAAM,wBAAwB;AAAA,MAChC,EAAE,KAAK,CAAC,QAAQ,IAAI,yBAAyB,CAAC;AAE9C,UAAI,CAAC,wBAAwB;AAC3B;AAAA,MACF;AAEA,uCAAS;AAAA,QACP,QAAQ,YAAY,YAAY;AAAA,QAChC,MAAM,uBAAuB;AAAA,MAC/B;AAEA,kBAAY;AAAA,IACd;AAEA,QAAI,CAAC,wBAAwB;AAC3B,YAAM,IAAI,MAAM,6CAA6C;AAAA,IAC/D;AAEA,qCAAS;AAAA,MACP,QAAQ;AAAA,MACR,MAAM,uBAAuB;AAAA,IAC/B;AAEA,WAAO,uBAAuB;AAAA,EAChC;AAAA;AAIA,SAAS,wBAAwB,cAA8B;AAC7D,SAAO;AAAA;AAAA;AAAA;AAAA,EAIP;AAAA;AAAA;AAAA;AAAA;AAKF;AAEA,SAAS,kBAAkB,eAAuB,cAA8B;AAC9E,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASF;","names":["actionParametersToJsonSchema","CopilotRequestType","_a","headers","action","CopilotRequestType","actionParametersToJsonSchema"]}
|
|
@@ -183,8 +183,12 @@ var getErrorActions = (error) => {
|
|
|
183
183
|
case CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR:
|
|
184
184
|
return {
|
|
185
185
|
primary: {
|
|
186
|
-
label: "
|
|
187
|
-
onClick: () => window.open(
|
|
186
|
+
label: "Show me how",
|
|
187
|
+
onClick: () => window.open(
|
|
188
|
+
"https://docs.copilotkit.ai/premium#how-do-i-get-access-to-premium-features",
|
|
189
|
+
"_blank",
|
|
190
|
+
"noopener,noreferrer"
|
|
191
|
+
)
|
|
188
192
|
}
|
|
189
193
|
};
|
|
190
194
|
case CopilotKitErrorCode.UPGRADE_REQUIRED_ERROR:
|
|
@@ -218,4 +222,4 @@ export {
|
|
|
218
222
|
getErrorActions,
|
|
219
223
|
renderCopilotKitUsage
|
|
220
224
|
};
|
|
221
|
-
//# sourceMappingURL=chunk-
|
|
225
|
+
//# sourceMappingURL=chunk-6ZLPNY7X.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/usage-banner.tsx"],"sourcesContent":["import {\n Severity,\n CopilotKitError,\n ErrorVisibility,\n CopilotKitErrorCode,\n} from \"@copilotkit/shared\";\nimport React from \"react\";\n\ninterface UsageBannerProps {\n severity?: Severity;\n message?: string | React.ReactNode;\n onClose?: () => void;\n actions?: {\n primary?: {\n label: string;\n onClick: () => void;\n };\n secondary?: {\n label: string;\n onClick: () => void;\n };\n };\n}\n\nexport function UsageBanner({\n severity = Severity.CRITICAL,\n message = \"\",\n onClose,\n actions,\n}: UsageBannerProps) {\n if (!message || !severity) {\n return null;\n }\n\n const themes = {\n [Severity.INFO]: {\n bg: \"#f8fafc\",\n border: \"#e2e8f0\",\n text: \"#475569\",\n accent: \"#3b82f6\",\n },\n [Severity.WARNING]: {\n bg: \"#fffbeb\",\n border: \"#fbbf24\",\n text: \"#92400e\",\n accent: \"#f59e0b\",\n },\n [Severity.CRITICAL]: {\n bg: \"#fef2f2\",\n border: \"#fecaca\",\n text: \"#dc2626\",\n accent: \"#ef4444\",\n },\n };\n\n const theme = themes[severity];\n\n return (\n <>\n <style>\n {`\n @keyframes slideUp {\n from { opacity: 0; transform: translateX(-50%) translateY(8px); }\n to { opacity: 1; transform: translateX(-50%) translateY(0); }\n }\n \n .usage-banner {\n position: fixed;\n bottom: 24px;\n left: 50%;\n transform: translateX(-50%);\n width: min(600px, calc(100vw - 32px));\n z-index: 10000;\n animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);\n }\n \n .banner-content {\n background: linear-gradient(135deg, ${theme.bg} 0%, ${theme.bg}f5 100%);\n border: 1px solid ${theme.border};\n border-radius: 12px;\n padding: 18px 20px;\n box-shadow: \n 0 4px 24px rgba(0, 0, 0, 0.08),\n 0 2px 8px rgba(0, 0, 0, 0.04),\n inset 0 1px 0 rgba(255, 255, 255, 0.7);\n display: flex;\n align-items: center;\n gap: 16px;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;\n backdrop-filter: blur(12px);\n position: relative;\n overflow: hidden;\n }\n \n .banner-content::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n height: 1px;\n background: linear-gradient(90deg, transparent, ${theme.accent}40, transparent);\n }\n \n .banner-message {\n color: ${theme.text};\n font-size: 14px;\n line-height: 1.5;\n font-weight: 500;\n flex: 1;\n letter-spacing: -0.01em;\n }\n \n .close-btn {\n background: rgba(0, 0, 0, 0.05);\n border: none;\n color: ${theme.text};\n cursor: pointer;\n padding: 0;\n border-radius: 6px;\n opacity: 0.6;\n transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);\n font-size: 14px;\n line-height: 1;\n flex-shrink: 0;\n width: 24px;\n height: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n \n .close-btn:hover {\n opacity: 1;\n background: rgba(0, 0, 0, 0.08);\n transform: scale(1.05);\n }\n \n .btn-primary {\n background: linear-gradient(135deg, ${theme.accent} 0%, ${theme.accent}e6 100%);\n color: white;\n border: none;\n border-radius: 8px;\n padding: 10px 18px;\n font-size: 13px;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);\n font-family: inherit;\n flex-shrink: 0;\n box-shadow: \n 0 2px 8px ${theme.accent}30,\n inset 0 1px 0 rgba(255, 255, 255, 0.2);\n letter-spacing: -0.01em;\n }\n \n .btn-primary:hover {\n transform: translateY(-1px) scale(1.02);\n box-shadow: \n 0 4px 12px ${theme.accent}40,\n inset 0 1px 0 rgba(255, 255, 255, 0.25);\n }\n \n .btn-primary:active {\n transform: translateY(0) scale(0.98);\n transition: all 0.08s cubic-bezier(0.16, 1, 0.3, 1);\n }\n \n @media (max-width: 640px) {\n .usage-banner {\n width: calc(100vw - 24px);\n }\n \n .banner-content {\n padding: 16px;\n gap: 12px;\n }\n \n .banner-message {\n font-size: 13px;\n line-height: 1.45;\n }\n \n .btn-primary {\n padding: 8px 14px;\n font-size: 12px;\n }\n \n .close-btn {\n width: 22px;\n height: 22px;\n font-size: 12px;\n }\n }\n `}\n </style>\n\n <div className=\"usage-banner\">\n <div className=\"banner-content\">\n <div className=\"banner-message\">{message}</div>\n {actions?.primary && (\n <button className=\"btn-primary\" onClick={actions.primary.onClick}>\n {actions.primary.label}\n </button>\n )}\n {onClose && (\n <button className=\"close-btn\" onClick={onClose} title=\"Close\">\n ×\n </button>\n )}\n </div>\n </div>\n </>\n );\n}\n\n// Get action button based on error type\nexport const getErrorActions = (error: CopilotKitError) => {\n switch (error.code) {\n case CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR:\n return {\n primary: {\n label: \"Show me how\",\n onClick: () =>\n window.open(\n \"https://docs.copilotkit.ai/premium#how-do-i-get-access-to-premium-features\",\n \"_blank\",\n \"noopener,noreferrer\",\n ),\n },\n };\n case CopilotKitErrorCode.UPGRADE_REQUIRED_ERROR:\n return {\n primary: {\n label: \"Upgrade\",\n onClick: () =>\n window.open(\"https://cloud.copilotkit.ai\", \"_blank\", \"noopener,noreferrer\"),\n },\n };\n default:\n return undefined;\n }\n};\n\nexport function renderCopilotKitUsage(error: CopilotKitError, onClose?: () => void) {\n // Route based on error visibility level\n if (error.visibility !== ErrorVisibility.BANNER) {\n return null;\n }\n\n return (\n <UsageBanner\n severity={error.severity || Severity.CRITICAL}\n message={error.message}\n onClose={onClose}\n actions={getErrorActions(error)}\n />\n );\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AAqDH,mBACE,KA2IE,YA5IJ;AAlCG,SAAS,YAAY;AAAA,EAC1B,WAAW,SAAS;AAAA,EACpB,UA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AA,EAChC;AAEJ;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCopilotChat
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JY3STRON.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useMessagesTap
|
|
6
6
|
} from "./chunk-MUDXTKXE.mjs";
|
|
@@ -45,7 +45,7 @@ function useCoAgent(options) {
|
|
|
45
45
|
}, [availableAgents]);
|
|
46
46
|
const { getMessagesFromTap } = useMessagesTap();
|
|
47
47
|
const { coagentStates, coagentStatesRef, setCoagentStatesWithRef, threadId, copilotApiConfig } = context;
|
|
48
|
-
const {
|
|
48
|
+
const { sendMessage, runChatCompletion } = useCopilotChat();
|
|
49
49
|
const headers = __spreadValues({}, copilotApiConfig.headers || {});
|
|
50
50
|
const runtimeClient = useCopilotRuntimeClient({
|
|
51
51
|
url: copilotApiConfig.chatApiEndpoint,
|
|
@@ -129,9 +129,9 @@ function useCoAgent(options) {
|
|
|
129
129
|
}, [JSON.stringify(options.config), JSON.stringify(options.configurable)]);
|
|
130
130
|
const runAgentCallback = useAsyncCallback(
|
|
131
131
|
(hint) => __async(this, null, function* () {
|
|
132
|
-
yield runAgent(name, context, getMessagesFromTap(),
|
|
132
|
+
yield runAgent(name, context, getMessagesFromTap(), sendMessage, runChatCompletion, hint);
|
|
133
133
|
}),
|
|
134
|
-
[name, context,
|
|
134
|
+
[name, context, sendMessage, runChatCompletion]
|
|
135
135
|
);
|
|
136
136
|
return useMemo(() => {
|
|
137
137
|
const coagentState = getCoagentState({ coagentStates, name, options });
|
|
@@ -173,7 +173,7 @@ function stopAgent(name, context) {
|
|
|
173
173
|
console.warn(`No agent session found for ${name}`);
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
function runAgent(name, context, messages,
|
|
176
|
+
function runAgent(name, context, messages, sendMessage, runChatCompletion, hint) {
|
|
177
177
|
return __async(this, null, function* () {
|
|
178
178
|
var _a, _b;
|
|
179
179
|
const { agentSession, setAgentSession } = context;
|
|
@@ -193,7 +193,7 @@ function runAgent(name, context, messages, appendMessage, runChatCompletion, hin
|
|
|
193
193
|
if (hint) {
|
|
194
194
|
const hintMessage = hint({ previousState, currentState: state });
|
|
195
195
|
if (hintMessage) {
|
|
196
|
-
yield
|
|
196
|
+
yield sendMessage(hintMessage);
|
|
197
197
|
} else {
|
|
198
198
|
yield runChatCompletion();
|
|
199
199
|
}
|
|
@@ -235,4 +235,4 @@ export {
|
|
|
235
235
|
stopAgent,
|
|
236
236
|
runAgent
|
|
237
237
|
};
|
|
238
|
-
//# sourceMappingURL=chunk-
|
|
238
|
+
//# sourceMappingURL=chunk-BEFEBKKI.mjs.map
|