@copilotkit/react-ui 1.8.0-next.4 → 1.8.0-next.6
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 +18 -0
- package/dist/{chunk-TFIQA2P5.mjs → chunk-6H7IQRIU.mjs} +2 -2
- package/dist/{chunk-AIR3MXUU.mjs → chunk-DFHFPZQD.mjs} +8 -8
- package/dist/{chunk-CZUP2N4J.mjs → chunk-FFNESJSG.mjs} +2 -2
- package/dist/{chunk-QQ4FBIGN.mjs → chunk-GBXUOB6L.mjs} +6 -6
- package/dist/chunk-MMVDU6DF.mjs +1 -0
- package/dist/{chunk-GIPO7UB2.mjs → chunk-QS7UFQFD.mjs} +4 -4
- package/dist/{chunk-H24B7QWO.mjs → chunk-Z6YOBQUJ.mjs} +9 -9
- package/dist/components/chat/Chat.mjs +5 -5
- package/dist/components/chat/Header.mjs +5 -5
- package/dist/components/chat/Modal.mjs +14 -14
- package/dist/components/chat/Popup.mjs +15 -15
- package/dist/components/chat/Sidebar.mjs +15 -15
- package/dist/components/chat/index.mjs +18 -18
- package/dist/components/chat/messages/AssistantMessage.mjs +1 -1
- package/dist/components/dev-console/console.mjs +3 -3
- package/dist/components/dev-console/index.mjs +5 -5
- package/dist/components/index.d.ts +0 -3
- package/dist/components/index.js +0 -290
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +21 -33
- package/dist/index.css +19 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +2 -292
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -34
- package/dist/types/css.js.map +1 -1
- package/package.json +4 -4
- package/src/components/index.ts +0 -1
- package/src/css/colors.css +31 -0
- package/src/css/panel.css +1 -1
- package/dist/chunk-EJG6RRSX.mjs +0 -138
- package/dist/chunk-EJG6RRSX.mjs.map +0 -1
- package/dist/chunk-MCO235PS.mjs +0 -164
- package/dist/chunk-MCO235PS.mjs.map +0 -1
- package/dist/chunk-MWC5OV7Z.mjs +0 -1
- package/dist/chunk-N7LTE54T.mjs +0 -1
- package/dist/chunk-N7LTE54T.mjs.map +0 -1
- package/dist/chunk-UCVCAGU7.mjs +0 -1
- package/dist/chunk-UCVCAGU7.mjs.map +0 -1
- package/dist/components/crew/DefaultResponseRenderer.d.ts +0 -110
- package/dist/components/crew/DefaultResponseRenderer.js +0 -175
- package/dist/components/crew/DefaultResponseRenderer.js.map +0 -1
- package/dist/components/crew/DefaultResponseRenderer.mjs +0 -10
- package/dist/components/crew/DefaultResponseRenderer.mjs.map +0 -1
- package/dist/components/crew/DefaultStateRenderer.d.ts +0 -88
- package/dist/components/crew/DefaultStateRenderer.js +0 -198
- package/dist/components/crew/DefaultStateRenderer.js.map +0 -1
- package/dist/components/crew/DefaultStateRenderer.mjs +0 -8
- package/dist/components/crew/DefaultStateRenderer.mjs.map +0 -1
- package/dist/components/crew/index.d.ts +0 -4
- package/dist/components/crew/index.js +0 -335
- package/dist/components/crew/index.js.map +0 -1
- package/dist/components/crew/index.mjs +0 -16
- package/dist/components/crew/index.mjs.map +0 -1
- package/dist/components/crew/types.d.ts +0 -340
- package/dist/components/crew/types.js +0 -19
- package/dist/components/crew/types.js.map +0 -1
- package/dist/components/crew/types.mjs +0 -2
- package/dist/components/crew/types.mjs.map +0 -1
- package/src/components/crew/DefaultResponseRenderer.tsx +0 -298
- package/src/components/crew/DefaultStateRenderer.tsx +0 -326
- package/src/components/crew/index.ts +0 -3
- package/src/components/crew/types.ts +0 -398
- /package/dist/{chunk-TFIQA2P5.mjs.map → chunk-6H7IQRIU.mjs.map} +0 -0
- /package/dist/{chunk-AIR3MXUU.mjs.map → chunk-DFHFPZQD.mjs.map} +0 -0
- /package/dist/{chunk-CZUP2N4J.mjs.map → chunk-FFNESJSG.mjs.map} +0 -0
- /package/dist/{chunk-QQ4FBIGN.mjs.map → chunk-GBXUOB6L.mjs.map} +0 -0
- /package/dist/{chunk-MWC5OV7Z.mjs.map → chunk-MMVDU6DF.mjs.map} +0 -0
- /package/dist/{chunk-GIPO7UB2.mjs.map → chunk-QS7UFQFD.mjs.map} +0 -0
- /package/dist/{chunk-H24B7QWO.mjs.map → chunk-Z6YOBQUJ.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,65 +1,56 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "./chunk-EFZPSZWO.mjs";
|
|
3
|
-
import "./chunk-
|
|
3
|
+
import "./chunk-IU3WTXLQ.mjs";
|
|
4
|
+
import "./chunk-MMVDU6DF.mjs";
|
|
4
5
|
import "./chunk-SQMEPWVT.mjs";
|
|
5
6
|
import {
|
|
6
7
|
CopilotSidebar
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-FFNESJSG.mjs";
|
|
8
9
|
import "./chunk-WB3YULQ4.mjs";
|
|
9
10
|
import {
|
|
10
11
|
CopilotPopup
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-6H7IQRIU.mjs";
|
|
13
|
+
import "./chunk-DFHFPZQD.mjs";
|
|
13
14
|
import "./chunk-CGVOCLHN.mjs";
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-QS7UFQFD.mjs";
|
|
16
|
+
import "./chunk-V7W6IM2V.mjs";
|
|
16
17
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} from "./chunk-EJG6RRSX.mjs";
|
|
18
|
+
CopilotDevConsole
|
|
19
|
+
} from "./chunk-GBXUOB6L.mjs";
|
|
20
20
|
import {
|
|
21
|
-
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
21
|
+
shouldShowDevConsole
|
|
22
|
+
} from "./chunk-6TCUJ3B7.mjs";
|
|
23
|
+
import "./chunk-KXE2JCUH.mjs";
|
|
24
|
+
import "./chunk-YC4NBUGE.mjs";
|
|
25
|
+
import "./chunk-BH6PCAAL.mjs";
|
|
26
|
+
import "./chunk-OTPAZXVR.mjs";
|
|
24
27
|
import "./chunk-VC4NO5QZ.mjs";
|
|
25
28
|
import {
|
|
26
29
|
CopilotChat
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import {
|
|
29
|
-
AssistantMessage
|
|
30
|
-
} from "./chunk-FBYETUFL.mjs";
|
|
31
|
-
import "./chunk-XB6QCUPB.mjs";
|
|
30
|
+
} from "./chunk-Z6YOBQUJ.mjs";
|
|
32
31
|
import "./chunk-UWWMAJ7R.mjs";
|
|
33
32
|
import "./chunk-WEYDZBT7.mjs";
|
|
34
33
|
import "./chunk-7RIBDD4K.mjs";
|
|
35
34
|
import {
|
|
36
35
|
UserMessage
|
|
37
36
|
} from "./chunk-HEIDCT7I.mjs";
|
|
38
|
-
import
|
|
37
|
+
import {
|
|
38
|
+
AssistantMessage
|
|
39
|
+
} from "./chunk-FBYETUFL.mjs";
|
|
40
|
+
import "./chunk-XB6QCUPB.mjs";
|
|
39
41
|
import "./chunk-TOQ7P4DO.mjs";
|
|
40
42
|
import "./chunk-LYHZXHTJ.mjs";
|
|
41
43
|
import "./chunk-YQFVRDNC.mjs";
|
|
42
44
|
import {
|
|
43
45
|
Markdown
|
|
44
46
|
} from "./chunk-XNQO5AZZ.mjs";
|
|
45
|
-
import "./chunk-PCTCOQK2.mjs";
|
|
46
47
|
import "./chunk-GJME6MK4.mjs";
|
|
48
|
+
import "./chunk-UZTZXMYS.mjs";
|
|
47
49
|
import {
|
|
48
50
|
useChatContext
|
|
49
51
|
} from "./chunk-5JY5QJ2W.mjs";
|
|
50
|
-
import "./chunk-
|
|
51
|
-
import {
|
|
52
|
-
CopilotDevConsole
|
|
53
|
-
} from "./chunk-QQ4FBIGN.mjs";
|
|
54
|
-
import "./chunk-KXE2JCUH.mjs";
|
|
55
|
-
import "./chunk-YC4NBUGE.mjs";
|
|
56
|
-
import "./chunk-BH6PCAAL.mjs";
|
|
57
|
-
import {
|
|
58
|
-
shouldShowDevConsole
|
|
59
|
-
} from "./chunk-6TCUJ3B7.mjs";
|
|
52
|
+
import "./chunk-PCTCOQK2.mjs";
|
|
60
53
|
import "./chunk-ORSMX3SE.mjs";
|
|
61
|
-
import "./chunk-OTPAZXVR.mjs";
|
|
62
|
-
import "./chunk-IU3WTXLQ.mjs";
|
|
63
54
|
import "./chunk-T26KLXLH.mjs";
|
|
64
55
|
import {
|
|
65
56
|
useCopilotChatSuggestions
|
|
@@ -73,11 +64,8 @@ export {
|
|
|
73
64
|
CopilotDevConsole,
|
|
74
65
|
CopilotPopup,
|
|
75
66
|
CopilotSidebar,
|
|
76
|
-
DefaultResponseRenderer,
|
|
77
|
-
DefaultStateRenderer,
|
|
78
67
|
Markdown,
|
|
79
68
|
UserMessage,
|
|
80
|
-
createResponseCache,
|
|
81
69
|
shouldShowDevConsole,
|
|
82
70
|
useChatContext,
|
|
83
71
|
useCopilotChatSuggestions
|
package/dist/types/css.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/css.ts"],"sourcesContent":["// autogenerated (see postcss.config.js) - do not edit\nimport { CSSProperties } from \"react\";\n\nexport interface CopilotKitCSSProperties extends CSSProperties {\n \"--copilot-kit-primary-color\"?: string;\n \"--copilot-kit-contrast-color\"?: string;\n \"--copilot-kit-
|
|
1
|
+
{"version":3,"sources":["../../src/types/css.ts"],"sourcesContent":["// autogenerated (see postcss.config.js) - do not edit\nimport { CSSProperties } from \"react\";\n\nexport interface CopilotKitCSSProperties extends CSSProperties {\n \"--copilot-kit-primary-color\"?: string;\n \"--copilot-kit-contrast-color\"?: string;\n \"--copilot-kit-background-color\"?: string;\n \"--copilot-kit-input-background-color\"?: string;\n \"--copilot-kit-secondary-color\"?: string;\n \"--copilot-kit-secondary-contrast-color\"?: string;\n \"--copilot-kit-separator-color\"?: string;\n \"--copilot-kit-muted-color\"?: string;\n \"--copilot-kit-shadow-sm\"?: string;\n \"--copilot-kit-shadow-md\"?: string;\n \"--copilot-kit-shadow-lg\"?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.8.0-next.
|
|
12
|
+
"version": "1.8.0-next.6",
|
|
13
13
|
"sideEffects": [
|
|
14
14
|
"**/*.css"
|
|
15
15
|
],
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"react-syntax-highlighter": "^15.5.0",
|
|
51
51
|
"remark-gfm": "^3.0.1",
|
|
52
52
|
"remark-math": "^5.1.1",
|
|
53
|
-
"@copilotkit/react-core": "1.8.0-next.
|
|
54
|
-
"@copilotkit/runtime-client-gql": "1.8.0-next.
|
|
55
|
-
"@copilotkit/shared": "1.8.0-next.
|
|
53
|
+
"@copilotkit/react-core": "1.8.0-next.6",
|
|
54
|
+
"@copilotkit/runtime-client-gql": "1.8.0-next.6",
|
|
55
|
+
"@copilotkit/shared": "1.8.0-next.6"
|
|
56
56
|
},
|
|
57
57
|
"keywords": [
|
|
58
58
|
"copilotkit",
|
package/src/components/index.ts
CHANGED
package/src/css/colors.css
CHANGED
|
@@ -56,3 +56,34 @@
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
.dark,
|
|
60
|
+
html.dark,
|
|
61
|
+
body.dark,
|
|
62
|
+
[data-theme="dark"],
|
|
63
|
+
html[style*="color-scheme: dark"],
|
|
64
|
+
body[style*="color-scheme: dark"] :root {
|
|
65
|
+
/* Main brand/action color - used for buttons, interactive elements */
|
|
66
|
+
--copilot-kit-primary-color: rgb(255, 255, 255);
|
|
67
|
+
/* Color that contrasts with primary - used for text on primary elements */
|
|
68
|
+
--copilot-kit-contrast-color: rgb(28, 28, 28);
|
|
69
|
+
/* Main page/container background color */
|
|
70
|
+
--copilot-kit-background-color: rgb(17, 17, 17);
|
|
71
|
+
/* Input box background color */
|
|
72
|
+
--copilot-kit-input-background-color: #2c2c2c;
|
|
73
|
+
/* Secondary background - used for cards, panels, elevated surfaces */
|
|
74
|
+
--copilot-kit-secondary-color: rgb(28, 28, 28);
|
|
75
|
+
/* Primary text color for main content */
|
|
76
|
+
--copilot-kit-secondary-contrast-color: rgb(255, 255, 255);
|
|
77
|
+
/* Border color for dividers and containers */
|
|
78
|
+
--copilot-kit-separator-color: rgb(45, 45, 45);
|
|
79
|
+
/* Muted color for disabled/inactive states */
|
|
80
|
+
--copilot-kit-muted-color: rgb(45, 45, 45);
|
|
81
|
+
|
|
82
|
+
/* Small shadow for subtle elevation */
|
|
83
|
+
--copilot-kit-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
|
|
84
|
+
/* Medium shadow for cards */
|
|
85
|
+
--copilot-kit-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
|
|
86
|
+
/* Large shadow for modals */
|
|
87
|
+
--copilot-kit-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
|
|
88
|
+
}
|
|
89
|
+
|
package/src/css/panel.css
CHANGED
package/dist/chunk-EJG6RRSX.mjs
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__spreadProps,
|
|
3
|
-
__spreadValues
|
|
4
|
-
} from "./chunk-MRXNTQOX.mjs";
|
|
5
|
-
|
|
6
|
-
// src/components/crew/DefaultResponseRenderer.tsx
|
|
7
|
-
import { useState } from "react";
|
|
8
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
var createResponseCache = () => {
|
|
10
|
-
const responseCache = /* @__PURE__ */ new Map();
|
|
11
|
-
return {
|
|
12
|
-
getResponse: (id) => responseCache.get(id),
|
|
13
|
-
setResponse: (id, response) => responseCache.set(id, response)
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
var useResponseCache = createResponseCache();
|
|
17
|
-
var DefaultExpandIcon = ({ className }) => /* @__PURE__ */ jsx(
|
|
18
|
-
"svg",
|
|
19
|
-
{
|
|
20
|
-
className,
|
|
21
|
-
width: "12",
|
|
22
|
-
height: "12",
|
|
23
|
-
viewBox: "0 0 24 24",
|
|
24
|
-
fill: "none",
|
|
25
|
-
stroke: "currentColor",
|
|
26
|
-
strokeWidth: "2",
|
|
27
|
-
strokeLinecap: "round",
|
|
28
|
-
strokeLinejoin: "round",
|
|
29
|
-
children: /* @__PURE__ */ jsx("polyline", { points: "6 9 12 15 18 9" })
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
var DefaultCollapseIcon = ({ className }) => /* @__PURE__ */ jsx(
|
|
33
|
-
"svg",
|
|
34
|
-
{
|
|
35
|
-
className,
|
|
36
|
-
width: "12",
|
|
37
|
-
height: "12",
|
|
38
|
-
viewBox: "0 0 24 24",
|
|
39
|
-
fill: "none",
|
|
40
|
-
stroke: "currentColor",
|
|
41
|
-
strokeWidth: "2",
|
|
42
|
-
strokeLinecap: "round",
|
|
43
|
-
strokeLinejoin: "round",
|
|
44
|
-
children: /* @__PURE__ */ jsx("polyline", { points: "18 15 12 9 6 15" })
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
var DefaultContentRenderer = ({ content, className }) => /* @__PURE__ */ jsx("div", { className, children: content });
|
|
48
|
-
var DefaultFeedbackButton = ({ label, onClick, className }) => /* @__PURE__ */ jsx("button", { onClick, className, children: label });
|
|
49
|
-
var DefaultCompletedFeedback = ({ message, className }) => /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx("span", { children: message }) });
|
|
50
|
-
var DefaultResponseRenderer = ({
|
|
51
|
-
response,
|
|
52
|
-
status,
|
|
53
|
-
onRespond,
|
|
54
|
-
icons,
|
|
55
|
-
labels,
|
|
56
|
-
ContentRenderer = DefaultContentRenderer,
|
|
57
|
-
FeedbackButton = DefaultFeedbackButton,
|
|
58
|
-
CompletedFeedback = DefaultCompletedFeedback,
|
|
59
|
-
className = "copilotkit-response",
|
|
60
|
-
contentClassName = "copilotkit-response-content",
|
|
61
|
-
actionsClassName = "copilotkit-response-actions",
|
|
62
|
-
buttonClassName = "copilotkit-response-button",
|
|
63
|
-
completedFeedbackClassName = "copilotkit-response-completed-feedback"
|
|
64
|
-
}) => {
|
|
65
|
-
const [isExpanded, setIsExpanded] = useState(true);
|
|
66
|
-
const defaultLabels = {
|
|
67
|
-
responseLabel: "Response",
|
|
68
|
-
approveLabel: "Approve",
|
|
69
|
-
rejectLabel: "Reject",
|
|
70
|
-
approvedMessage: "Approved",
|
|
71
|
-
rejectedMessage: "Rejected",
|
|
72
|
-
feedbackSubmittedMessage: "Feedback submitted"
|
|
73
|
-
};
|
|
74
|
-
const mergedLabels = __spreadValues(__spreadValues({}, defaultLabels), labels);
|
|
75
|
-
const renderFeedback = () => {
|
|
76
|
-
if (status === "complete") {
|
|
77
|
-
const cachedResponse = useResponseCache.getResponse(response.id);
|
|
78
|
-
return /* @__PURE__ */ jsx(
|
|
79
|
-
CompletedFeedback,
|
|
80
|
-
{
|
|
81
|
-
message: (cachedResponse == null ? void 0 : cachedResponse.__feedback__) ? cachedResponse.__feedback__ === mergedLabels.approvedMessage ? mergedLabels.approvedMessage : mergedLabels.rejectedMessage : mergedLabels.feedbackSubmittedMessage,
|
|
82
|
-
className: completedFeedbackClassName
|
|
83
|
-
}
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
if (status === "inProgress" || status === "executing") {
|
|
87
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
88
|
-
/* @__PURE__ */ jsx(
|
|
89
|
-
FeedbackButton,
|
|
90
|
-
{
|
|
91
|
-
label: mergedLabels.approveLabel,
|
|
92
|
-
onClick: () => {
|
|
93
|
-
setIsExpanded(false);
|
|
94
|
-
onRespond == null ? void 0 : onRespond(mergedLabels.approveLabel);
|
|
95
|
-
useResponseCache.setResponse(response.id, __spreadProps(__spreadValues({}, response), {
|
|
96
|
-
__feedback__: mergedLabels.approvedMessage
|
|
97
|
-
}));
|
|
98
|
-
},
|
|
99
|
-
className: buttonClassName
|
|
100
|
-
}
|
|
101
|
-
),
|
|
102
|
-
/* @__PURE__ */ jsx(
|
|
103
|
-
FeedbackButton,
|
|
104
|
-
{
|
|
105
|
-
label: mergedLabels.rejectLabel,
|
|
106
|
-
onClick: () => {
|
|
107
|
-
setIsExpanded(false);
|
|
108
|
-
useResponseCache.setResponse(response.id, __spreadProps(__spreadValues({}, response), {
|
|
109
|
-
__feedback__: mergedLabels.rejectedMessage
|
|
110
|
-
}));
|
|
111
|
-
onRespond == null ? void 0 : onRespond(mergedLabels.rejectLabel);
|
|
112
|
-
},
|
|
113
|
-
className: buttonClassName
|
|
114
|
-
}
|
|
115
|
-
)
|
|
116
|
-
] });
|
|
117
|
-
}
|
|
118
|
-
return null;
|
|
119
|
-
};
|
|
120
|
-
const ExpandIcon = (icons == null ? void 0 : icons.expand) || DefaultExpandIcon;
|
|
121
|
-
const CollapseIcon = (icons == null ? void 0 : icons.collapse) || DefaultCollapseIcon;
|
|
122
|
-
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
123
|
-
isExpanded && /* @__PURE__ */ jsx(ContentRenderer, { content: response.content, className: contentClassName }),
|
|
124
|
-
/* @__PURE__ */ jsxs("div", { className: actionsClassName, children: [
|
|
125
|
-
/* @__PURE__ */ jsxs("div", { className: "copilotkit-response-label", children: [
|
|
126
|
-
/* @__PURE__ */ jsx("button", { onClick: () => setIsExpanded(!isExpanded), className: "copilotkit-toggle-button", children: isExpanded ? /* @__PURE__ */ jsx(CollapseIcon, { className: "copilotkit-icon" }) : /* @__PURE__ */ jsx(ExpandIcon, { className: "copilotkit-icon" }) }),
|
|
127
|
-
/* @__PURE__ */ jsx("span", { children: mergedLabels.responseLabel })
|
|
128
|
-
] }),
|
|
129
|
-
/* @__PURE__ */ jsx("div", { className: "copilotkit-response-buttons", children: renderFeedback() })
|
|
130
|
-
] })
|
|
131
|
-
] });
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
export {
|
|
135
|
-
createResponseCache,
|
|
136
|
-
DefaultResponseRenderer
|
|
137
|
-
};
|
|
138
|
-
//# sourceMappingURL=chunk-EJG6RRSX.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/crew/DefaultResponseRenderer.tsx"],"sourcesContent":["/**\n * <br/>\n * A response renderer component for the CopilotKit framework. This component displays\n * a response that may require user feedback, such as approving or rejecting a suggestion.\n * It provides a flexible, customizable interface for rendering responses with user interaction.\n *\n * ## Install Dependencies\n *\n * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.\n *\n * ```shell npm2yarn \\\"@copilotkit/react-ui\"\\\n * npm install @copilotkit/react-core @copilotkit/react-ui\n * ```\n *\n * ## Usage\n *\n * ```tsx\n * import { DefaultResponseRenderer } from \"@copilotkit/react-ui\";\n * import \"@copilotkit/react-ui/styles.css\";\n *\n * // Basic usage\n * <DefaultResponseRenderer\n * response={{\n * id: \"response-1\",\n * content: \"I've analyzed your data and found these insights...\"\n * }}\n * status=\"inProgress\"\n * onRespond={(input) => console.log(`User responded: ${input}`)}\n * />\n * ```\n *\n * ## Customization\n *\n * You can customize the appearance and behavior of the component:\n *\n * ```tsx\n * // Custom labels and styling\n * <DefaultResponseRenderer\n * response={{\n * id: \"task-123\",\n * content: \"Would you like to proceed with this recommendation?\"\n * }}\n * status=\"inProgress\"\n * onRespond={handleResponse}\n * labels={{\n * responseLabel: \"AI Recommendation\",\n * approveLabel: \"Yes, proceed\",\n * rejectLabel: \"No, cancel\",\n * approvedMessage: \"Proceeding with recommendation\",\n * rejectedMessage: \"Recommendation cancelled\"\n * }}\n * className=\"my-custom-response\"\n * contentClassName=\"my-custom-content\"\n * buttonClassName=\"my-custom-button\"\n * />\n *\n * // Custom components\n * <DefaultResponseRenderer\n * response={{\n * id: \"task-456\",\n * content: \"# Important Decision\\nThis requires your approval\"\n * }}\n * status=\"inProgress\"\n * onRespond={handleResponse}\n * ContentRenderer={({ content, className }) => (\n * <MyMarkdownRenderer content={content} className={className} />\n * )}\n * FeedbackButton={({ label, onClick, className }) => (\n * <MyCustomButton label={label} onClick={onClick} className={className} />\n * )}\n * />\n * ```\n *\n * ### Look & Feel\n *\n * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:\n * ```tsx title=\"YourRootComponent.tsx\"\n * ...\n * import \"@copilotkit/react-ui/styles.css\"; // [!code highlight]\n *\n * export function YourRootComponent() {\n * return (\n * <CopilotKit>\n * ...\n * </CopilotKit>\n * );\n * }\n * ```\n * For more information about how to customize the styles, check out the [Customize Look & Feel](/guides/custom-look-and-feel/customize-built-in-ui-components) guide.\n */\n\nimport React, { useState } from \"react\";\nimport {\n Response,\n ResponseRendererProps,\n ContentRendererProps,\n FeedbackButtonProps,\n CompletedFeedbackProps,\n ResponseRendererIconProps,\n} from \"./types\";\n\n/**\n * Creates a cache for storing response feedback\n */\nconst createResponseCache = <T extends { id: string }>() => {\n const responseCache = new Map<string, T>();\n\n return {\n getResponse: (id: string) => responseCache.get(id),\n setResponse: (id: string, response: T) => responseCache.set(id, response),\n };\n};\n\n/**\n * Default global response cache instance\n */\nconst useResponseCache = createResponseCache<Response & { __feedback__?: string }>();\n\n/**\n * Default expand icon component\n */\nconst DefaultExpandIcon: React.FC<ResponseRendererIconProps> = ({ className }) => (\n <svg\n className={className}\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"6 9 12 15 18 9\"></polyline>\n </svg>\n);\n\n/**\n * Default collapse icon component\n */\nconst DefaultCollapseIcon: React.FC<ResponseRendererIconProps> = ({ className }) => (\n <svg\n className={className}\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"18 15 12 9 6 15\"></polyline>\n </svg>\n);\n\n/**\n * Default content renderer that simply displays text\n */\nconst DefaultContentRenderer: React.FC<ContentRendererProps> = ({ content, className }) => (\n <div className={className}>{content}</div>\n);\n\n/**\n * Default feedback button component\n */\nconst DefaultFeedbackButton: React.FC<FeedbackButtonProps> = ({ label, onClick, className }) => (\n <button onClick={onClick} className={className}>\n {label}\n </button>\n);\n\n/**\n * Default completed feedback component\n */\nconst DefaultCompletedFeedback: React.FC<CompletedFeedbackProps> = ({ message, className }) => (\n <div className={className}>\n <span>{message}</span>\n </div>\n);\n\n/**\n * Default response renderer component that handles rendering responses\n * and collecting user feedback\n */\nexport const DefaultResponseRenderer: React.FC<ResponseRendererProps> = ({\n response,\n status,\n onRespond,\n icons,\n labels,\n ContentRenderer = DefaultContentRenderer,\n FeedbackButton = DefaultFeedbackButton,\n CompletedFeedback = DefaultCompletedFeedback,\n className = \"copilotkit-response\",\n contentClassName = \"copilotkit-response-content\",\n actionsClassName = \"copilotkit-response-actions\",\n buttonClassName = \"copilotkit-response-button\",\n completedFeedbackClassName = \"copilotkit-response-completed-feedback\",\n}) => {\n const [isExpanded, setIsExpanded] = useState(true);\n\n // Default label values\n const defaultLabels = {\n responseLabel: \"Response\",\n approveLabel: \"Approve\",\n rejectLabel: \"Reject\",\n approvedMessage: \"Approved\",\n rejectedMessage: \"Rejected\",\n feedbackSubmittedMessage: \"Feedback submitted\",\n };\n\n // Merge provided labels with defaults\n const mergedLabels = { ...defaultLabels, ...labels };\n\n // Function to render feedback UI based on status\n const renderFeedback = () => {\n if (status === \"complete\") {\n const cachedResponse = useResponseCache.getResponse(response.id);\n return (\n <CompletedFeedback\n message={\n cachedResponse?.__feedback__\n ? cachedResponse.__feedback__ === mergedLabels.approvedMessage\n ? mergedLabels.approvedMessage\n : mergedLabels.rejectedMessage\n : mergedLabels.feedbackSubmittedMessage\n }\n className={completedFeedbackClassName}\n />\n );\n }\n\n if (status === \"inProgress\" || status === \"executing\") {\n return (\n <>\n <FeedbackButton\n label={mergedLabels.approveLabel}\n onClick={() => {\n setIsExpanded(false);\n onRespond?.(mergedLabels.approveLabel);\n useResponseCache.setResponse(response.id, {\n ...response,\n __feedback__: mergedLabels.approvedMessage,\n });\n }}\n className={buttonClassName}\n />\n <FeedbackButton\n label={mergedLabels.rejectLabel}\n onClick={() => {\n setIsExpanded(false);\n useResponseCache.setResponse(response.id, {\n ...response,\n __feedback__: mergedLabels.rejectedMessage,\n });\n onRespond?.(mergedLabels.rejectLabel);\n }}\n className={buttonClassName}\n />\n </>\n );\n }\n\n return null;\n };\n\n // Decide which icon to display\n const ExpandIcon = icons?.expand || DefaultExpandIcon;\n const CollapseIcon = icons?.collapse || DefaultCollapseIcon;\n\n return (\n <div className={className}>\n {/* Response content - conditionally expanded */}\n {isExpanded && <ContentRenderer content={response.content} className={contentClassName} />}\n\n <div className={actionsClassName}>\n <div className=\"copilotkit-response-label\">\n <button onClick={() => setIsExpanded(!isExpanded)} className=\"copilotkit-toggle-button\">\n {isExpanded ? (\n <CollapseIcon className=\"copilotkit-icon\" />\n ) : (\n <ExpandIcon className=\"copilotkit-icon\" />\n )}\n </button>\n <span>{mergedLabels.responseLabel}</span>\n </div>\n\n <div className=\"copilotkit-response-buttons\">{renderFeedback()}</div>\n </div>\n </div>\n );\n};\n\n/**\n * Export the response cache for reuse\n */\nexport { createResponseCache };\n"],"mappings":";;;;;;AA2FA,SAAgB,gBAAgB;AA0C5B,SAsGI,UAtGJ,KAsGI,YAtGJ;AA7BJ,IAAM,sBAAsB,MAAgC;AAC1D,QAAM,gBAAgB,oBAAI,IAAe;AAEzC,SAAO;AAAA,IACL,aAAa,CAAC,OAAe,cAAc,IAAI,EAAE;AAAA,IACjD,aAAa,CAAC,IAAY,aAAgB,cAAc,IAAI,IAAI,QAAQ;AAAA,EAC1E;AACF;AAKA,IAAM,mBAAmB,oBAA0D;AAKnF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B,IAE1C,oBAAC,cAAW,WAAU,mBAAkB,GAE5C;AAAA,QACA,oBAAC,UAAM,uBAAa,eAAc;AAAA,SACpC;AAAA,MAEA,oBAAC,SAAI,WAAU,+BAA+B,yBAAe,GAAE;AAAA,OACjE;AAAA,KACF;AAEJ;","names":[]}
|
package/dist/chunk-MCO235PS.mjs
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__spreadValues
|
|
3
|
-
} from "./chunk-MRXNTQOX.mjs";
|
|
4
|
-
|
|
5
|
-
// src/components/crew/DefaultStateRenderer.tsx
|
|
6
|
-
import { useState, useRef, useEffect, useMemo } from "react";
|
|
7
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
var DefaultExpandIcon = ({ className }) => /* @__PURE__ */ jsx(
|
|
9
|
-
"svg",
|
|
10
|
-
{
|
|
11
|
-
className,
|
|
12
|
-
width: "16",
|
|
13
|
-
height: "16",
|
|
14
|
-
viewBox: "0 0 24 24",
|
|
15
|
-
fill: "none",
|
|
16
|
-
stroke: "currentColor",
|
|
17
|
-
strokeWidth: "2",
|
|
18
|
-
strokeLinecap: "round",
|
|
19
|
-
strokeLinejoin: "round",
|
|
20
|
-
children: /* @__PURE__ */ jsx("polyline", { points: "6 9 12 15 18 9" })
|
|
21
|
-
}
|
|
22
|
-
);
|
|
23
|
-
var DefaultCollapseIcon = ({ className }) => /* @__PURE__ */ jsx(
|
|
24
|
-
"svg",
|
|
25
|
-
{
|
|
26
|
-
className,
|
|
27
|
-
width: "16",
|
|
28
|
-
height: "16",
|
|
29
|
-
viewBox: "0 0 24 24",
|
|
30
|
-
fill: "none",
|
|
31
|
-
stroke: "currentColor",
|
|
32
|
-
strokeWidth: "2",
|
|
33
|
-
strokeLinecap: "round",
|
|
34
|
-
strokeLinejoin: "round",
|
|
35
|
-
children: /* @__PURE__ */ jsx("polyline", { points: "18 15 12 9 6 15" })
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
-
var DefaultLoaderIcon = ({ className }) => /* @__PURE__ */ jsx(
|
|
39
|
-
"svg",
|
|
40
|
-
{
|
|
41
|
-
className: `${className} copilotkit-spinner`,
|
|
42
|
-
width: "16",
|
|
43
|
-
height: "16",
|
|
44
|
-
viewBox: "0 0 24 24",
|
|
45
|
-
fill: "none",
|
|
46
|
-
stroke: "currentColor",
|
|
47
|
-
strokeWidth: "2",
|
|
48
|
-
strokeLinecap: "round",
|
|
49
|
-
strokeLinejoin: "round",
|
|
50
|
-
children: /* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" })
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
var formatContent = (result) => {
|
|
54
|
-
if (result === null || result === void 0)
|
|
55
|
-
return "";
|
|
56
|
-
return typeof result === "string" ? result : JSON.stringify(result, null, 2);
|
|
57
|
-
};
|
|
58
|
-
var DefaultSkeletonLoader = ({ className }) => /* @__PURE__ */ jsxs("div", { className: className || "copilotkit-skeleton", children: [
|
|
59
|
-
/* @__PURE__ */ jsxs("div", { className: "copilotkit-skeleton-header", children: [
|
|
60
|
-
/* @__PURE__ */ jsx("div", { className: "copilotkit-skeleton-title" }),
|
|
61
|
-
/* @__PURE__ */ jsx("div", { className: "copilotkit-skeleton-subtitle" })
|
|
62
|
-
] }),
|
|
63
|
-
/* @__PURE__ */ jsx("div", { className: "copilotkit-skeleton-content" })
|
|
64
|
-
] });
|
|
65
|
-
var DefaultStateItemRenderer = ({
|
|
66
|
-
item,
|
|
67
|
-
isNewest,
|
|
68
|
-
className
|
|
69
|
-
}) => /* @__PURE__ */ jsxs(
|
|
70
|
-
"div",
|
|
71
|
-
{
|
|
72
|
-
className: `${className || "copilotkit-state-item"} ${isNewest ? "copilotkit-state-item-newest" : ""}`,
|
|
73
|
-
children: [
|
|
74
|
-
/* @__PURE__ */ jsx("div", { className: "copilotkit-state-item-header", children: "tool" in item ? item.tool : item.name }),
|
|
75
|
-
"thought" in item && item.thought && /* @__PURE__ */ jsx("div", { className: "copilotkit-state-item-thought", children: item.thought }),
|
|
76
|
-
"result" in item && item.result !== void 0 && item.result !== null && /* @__PURE__ */ jsx("div", { className: "copilotkit-state-item-result", children: formatContent(item.result) }),
|
|
77
|
-
"description" in item && item.description && /* @__PURE__ */ jsx("div", { className: "copilotkit-state-item-description", children: item.description })
|
|
78
|
-
]
|
|
79
|
-
}
|
|
80
|
-
);
|
|
81
|
-
var DefaultStateRenderer = ({
|
|
82
|
-
state,
|
|
83
|
-
status,
|
|
84
|
-
StateItemRenderer = DefaultStateItemRenderer,
|
|
85
|
-
SkeletonLoader = DefaultSkeletonLoader,
|
|
86
|
-
labels,
|
|
87
|
-
icons,
|
|
88
|
-
className = "copilotkit-state",
|
|
89
|
-
contentClassName = "copilotkit-state-content",
|
|
90
|
-
itemClassName = "copilotkit-state-item",
|
|
91
|
-
maxHeight = "250px",
|
|
92
|
-
defaultCollapsed = true
|
|
93
|
-
}) => {
|
|
94
|
-
const [isCollapsed, setIsCollapsed] = useState(defaultCollapsed);
|
|
95
|
-
const contentRef = useRef(null);
|
|
96
|
-
const prevItemsLengthRef = useRef(0);
|
|
97
|
-
const [newestItemId, setNewestItemId] = useState(null);
|
|
98
|
-
const defaultLabels = {
|
|
99
|
-
inProgressLabel: "Analyzing",
|
|
100
|
-
completeLabel: "Analyzed",
|
|
101
|
-
emptyLabel: "No activity"
|
|
102
|
-
};
|
|
103
|
-
const mergedLabels = __spreadValues(__spreadValues({}, defaultLabels), labels);
|
|
104
|
-
const ExpandIcon = (icons == null ? void 0 : icons.expand) || DefaultExpandIcon;
|
|
105
|
-
const CollapseIcon = (icons == null ? void 0 : icons.collapse) || DefaultCollapseIcon;
|
|
106
|
-
const items = useMemo(() => {
|
|
107
|
-
var _a;
|
|
108
|
-
return state ? [...((_a = state.steps) == null ? void 0 : _a.filter((s) => s.tool)) || [], ...state.tasks || []].sort(
|
|
109
|
-
(a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime()
|
|
110
|
-
) : [];
|
|
111
|
-
}, [state]);
|
|
112
|
-
const isThinking = status === "inProgress" && items.length === 0;
|
|
113
|
-
useEffect(() => {
|
|
114
|
-
if (!state)
|
|
115
|
-
return;
|
|
116
|
-
if (items.length > prevItemsLengthRef.current) {
|
|
117
|
-
if (items.length > 0) {
|
|
118
|
-
const newest = items[items.length - 1];
|
|
119
|
-
setNewestItemId(newest.id);
|
|
120
|
-
setTimeout(() => {
|
|
121
|
-
setNewestItemId(null);
|
|
122
|
-
}, 1500);
|
|
123
|
-
}
|
|
124
|
-
if (contentRef.current && !isCollapsed) {
|
|
125
|
-
contentRef.current.scrollTop = contentRef.current.scrollHeight;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
prevItemsLengthRef.current = items.length;
|
|
129
|
-
}, [items, isCollapsed, state]);
|
|
130
|
-
if (!state) {
|
|
131
|
-
return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(DefaultLoaderIcon, { className: "copilotkit-loader" }) });
|
|
132
|
-
}
|
|
133
|
-
if (isCollapsed && items.length === 0 && !isThinking)
|
|
134
|
-
return null;
|
|
135
|
-
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
136
|
-
/* @__PURE__ */ jsxs("div", { className: "copilotkit-state-header", onClick: () => setIsCollapsed(!isCollapsed), children: [
|
|
137
|
-
isCollapsed ? /* @__PURE__ */ jsx(ExpandIcon, { className: "copilotkit-icon" }) : /* @__PURE__ */ jsx(CollapseIcon, { className: "copilotkit-icon" }),
|
|
138
|
-
/* @__PURE__ */ jsx("div", { className: "copilotkit-state-label", children: status === "inProgress" ? /* @__PURE__ */ jsx("span", { className: "copilotkit-state-label-loading", children: mergedLabels.inProgressLabel }) : mergedLabels.completeLabel })
|
|
139
|
-
] }),
|
|
140
|
-
!isCollapsed && /* @__PURE__ */ jsx("div", { ref: contentRef, className: contentClassName, style: { maxHeight }, children: items.length > 0 ? items.map((item) => /* @__PURE__ */ jsx(
|
|
141
|
-
StateItemRenderer,
|
|
142
|
-
{
|
|
143
|
-
item,
|
|
144
|
-
isNewest: item.id === newestItemId,
|
|
145
|
-
className: itemClassName
|
|
146
|
-
},
|
|
147
|
-
item.id
|
|
148
|
-
)) : isThinking ? (
|
|
149
|
-
// Show skeleton loader while thinking
|
|
150
|
-
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
151
|
-
/* @__PURE__ */ jsx(SkeletonLoader, {}),
|
|
152
|
-
/* @__PURE__ */ jsx(SkeletonLoader, {})
|
|
153
|
-
] })
|
|
154
|
-
) : (
|
|
155
|
-
// Empty state
|
|
156
|
-
/* @__PURE__ */ jsx("div", { className: "copilotkit-state-empty", children: mergedLabels.emptyLabel })
|
|
157
|
-
) })
|
|
158
|
-
] });
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
export {
|
|
162
|
-
DefaultStateRenderer
|
|
163
|
-
};
|
|
164
|
-
//# sourceMappingURL=chunk-MCO235PS.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/crew/DefaultStateRenderer.tsx"],"sourcesContent":["/**\n * <br/>\n * A state renderer component for the CopilotKit framework. This component displays\n * the internal state of an agent, such as the steps it has taken and the tasks it has performed.\n * It provides a collapsible UI that shows the agent's thought process and actions.\n *\n * ## Install Dependencies\n *\n * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.\n *\n * ```shell npm2yarn \\\"@copilotkit/react-ui\"\\\n * npm install @copilotkit/react-core @copilotkit/react-ui\n * ```\n *\n * ## Usage\n *\n * ```tsx\n * import { DefaultStateRenderer } from \"@copilotkit/react-ui\";\n * import \"@copilotkit/react-ui/styles.css\";\n *\n * // Basic usage\n * <DefaultStateRenderer\n * state={agentState}\n * status=\"inProgress\"\n * />\n * ```\n *\n * ## Customization\n *\n * You can customize the appearance and behavior of the component:\n *\n * ```tsx\n * // Custom labels and styling\n * <DefaultStateRenderer\n * state={agentState}\n * status=\"inProgress\"\n * labels={{\n * inProgressLabel: \"Thinking...\",\n * completeLabel: \"Finished processing\",\n * emptyLabel: \"Nothing to show\"\n * }}\n * className=\"my-custom-state\"\n * contentClassName=\"my-custom-content\"\n * itemClassName=\"my-custom-item\"\n * maxHeight=\"300px\"\n * defaultCollapsed={false}\n * />\n *\n * // Custom renderers\n * <DefaultStateRenderer\n * state={agentState}\n * status=\"inProgress\"\n * StateItemRenderer={({ item, isNewest, className }) => (\n * <MyCustomItemRenderer item={item} isNewest={isNewest} className={className} />\n * )}\n * SkeletonLoader={({ className }) => (\n * <MyCustomSkeletonLoader className={className} />\n * )}\n * />\n * ```\n *\n * ### Look & Feel\n *\n * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:\n * ```tsx title=\"YourRootComponent.tsx\"\n * ...\n * import \"@copilotkit/react-ui/styles.css\"; // [!code highlight]\n *\n * export function YourRootComponent() {\n * return (\n * <CopilotKit>\n * ...\n * </CopilotKit>\n * );\n * }\n * ```\n * For more information about how to customize the styles, check out the [Customize Look & Feel](/guides/custom-look-and-feel/customize-built-in-ui-components) guide.\n */\n\nimport React, { useState, useRef, useEffect, useMemo } from \"react\";\nimport {\n AgentState,\n StateRendererProps,\n StateItemRendererProps,\n SkeletonLoaderProps,\n ToolStateItem,\n TaskStateItem,\n ResponseRendererIconProps,\n} from \"./types\";\n\n/**\n * Default expand icon component\n */\nconst DefaultExpandIcon: React.FC<ResponseRendererIconProps> = ({ className }) => (\n <svg\n className={className}\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"6 9 12 15 18 9\"></polyline>\n </svg>\n);\n\n/**\n * Default collapse icon component\n */\nconst DefaultCollapseIcon: React.FC<ResponseRendererIconProps> = ({ className }) => (\n <svg\n className={className}\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"18 15 12 9 6 15\"></polyline>\n </svg>\n);\n\n/**\n * Default loader icon component\n */\nconst DefaultLoaderIcon: React.FC<ResponseRendererIconProps> = ({ className }) => (\n <svg\n className={`${className} copilotkit-spinner`}\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M21 12a9 9 0 1 1-6.219-8.56\"></path>\n </svg>\n);\n\n/**\n * Helper to safely format content\n */\nconst formatContent = (result: unknown): string => {\n if (result === null || result === undefined) return \"\";\n return typeof result === \"string\" ? result : JSON.stringify(result, null, 2);\n};\n\n/**\n * Default skeleton loader component\n */\nconst DefaultSkeletonLoader: React.FC<SkeletonLoaderProps> = ({ className }) => (\n <div className={className || \"copilotkit-skeleton\"}>\n <div className=\"copilotkit-skeleton-header\">\n <div className=\"copilotkit-skeleton-title\"></div>\n <div className=\"copilotkit-skeleton-subtitle\"></div>\n </div>\n <div className=\"copilotkit-skeleton-content\"></div>\n </div>\n);\n\n/**\n * Default state item renderer component\n */\nconst DefaultStateItemRenderer: React.FC<StateItemRendererProps> = ({\n item,\n isNewest,\n className,\n}) => (\n <div\n className={`${className || \"copilotkit-state-item\"} ${isNewest ? \"copilotkit-state-item-newest\" : \"\"}`}\n >\n <div className=\"copilotkit-state-item-header\">{\"tool\" in item ? item.tool : item.name}</div>\n\n {\"thought\" in item && item.thought && (\n <div className=\"copilotkit-state-item-thought\">{item.thought}</div>\n )}\n\n {\"result\" in item && item.result !== undefined && item.result !== null && (\n <div className=\"copilotkit-state-item-result\">{formatContent(item.result)}</div>\n )}\n\n {\"description\" in item && item.description && (\n <div className=\"copilotkit-state-item-description\">{item.description}</div>\n )}\n </div>\n);\n\n/**\n * Default state renderer component\n */\nexport const DefaultStateRenderer: React.FC<StateRendererProps> = ({\n state,\n status,\n StateItemRenderer = DefaultStateItemRenderer,\n SkeletonLoader = DefaultSkeletonLoader,\n labels,\n icons,\n className = \"copilotkit-state\",\n contentClassName = \"copilotkit-state-content\",\n itemClassName = \"copilotkit-state-item\",\n maxHeight = \"250px\",\n defaultCollapsed = true,\n}) => {\n const [isCollapsed, setIsCollapsed] = useState(defaultCollapsed);\n const contentRef = useRef<HTMLDivElement>(null);\n const prevItemsLengthRef = useRef<number>(0);\n const [newestItemId, setNewestItemId] = useState<string | null>(null);\n\n // Default label values\n const defaultLabels = {\n inProgressLabel: \"Analyzing\",\n completeLabel: \"Analyzed\",\n emptyLabel: \"No activity\",\n };\n\n // Merge provided labels with defaults\n const mergedLabels = { ...defaultLabels, ...labels };\n\n // Decide which icon to display\n const ExpandIcon = icons?.expand || DefaultExpandIcon;\n const CollapseIcon = icons?.collapse || DefaultCollapseIcon;\n\n // Safely compute derived values using useMemo\n const items = useMemo(() => {\n return state\n ? [...(state.steps?.filter((s) => s.tool) || []), ...(state.tasks || [])].sort(\n (a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime(),\n )\n : [];\n }, [state]);\n\n // Determine if we should show skeleton UI (thinking but no items yet)\n const isThinking = status === \"inProgress\" && items.length === 0;\n\n // Track newest item and auto-scroll\n useEffect(() => {\n if (!state) return; // Skip effect if no state\n\n // If new items were added\n if (items.length > prevItemsLengthRef.current) {\n // Get the newest item\n if (items.length > 0) {\n const newest = items[items.length - 1];\n setNewestItemId(newest.id);\n\n // Clear the animation after 1.5 seconds\n setTimeout(() => {\n setNewestItemId(null);\n }, 1500);\n }\n\n // Auto-scroll to bottom\n if (contentRef.current && !isCollapsed) {\n contentRef.current.scrollTop = contentRef.current.scrollHeight;\n }\n }\n\n prevItemsLengthRef.current = items.length;\n }, [items, isCollapsed, state]);\n\n // Early return for loading state with no state\n if (!state) {\n return (\n <div className={className}>\n <DefaultLoaderIcon className=\"copilotkit-loader\" />\n </div>\n );\n }\n\n // Don't render anything if collapsed and empty and not thinking\n if (isCollapsed && items.length === 0 && !isThinking) return null;\n\n return (\n <div className={className}>\n {/* Header with toggle */}\n <div className=\"copilotkit-state-header\" onClick={() => setIsCollapsed(!isCollapsed)}>\n {isCollapsed ? (\n <ExpandIcon className=\"copilotkit-icon\" />\n ) : (\n <CollapseIcon className=\"copilotkit-icon\" />\n )}\n <div className=\"copilotkit-state-label\">\n {status === \"inProgress\" ? (\n <span className=\"copilotkit-state-label-loading\">{mergedLabels.inProgressLabel}</span>\n ) : (\n mergedLabels.completeLabel\n )}\n </div>\n </div>\n\n {/* Content area */}\n {!isCollapsed && (\n <div ref={contentRef} className={contentClassName} style={{ maxHeight }}>\n {/* Render items if available */}\n {items.length > 0 ? (\n items.map((item) => (\n <StateItemRenderer\n key={item.id}\n item={item}\n isNewest={item.id === newestItemId}\n className={itemClassName}\n />\n ))\n ) : isThinking ? (\n // Show skeleton loader while thinking\n <>\n <SkeletonLoader />\n <SkeletonLoader />\n </>\n ) : (\n // Empty state\n <div className=\"copilotkit-state-empty\">{mergedLabels.emptyLabel}</div>\n )}\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;AA+EA,SAAgB,UAAU,QAAQ,WAAW,eAAe;AA0BxD,SAgNQ,UAhNR,KAuDA,YAvDA;AAZJ,IAAM,oBAAyD,CAAC,EAAE,UAAU,MAC1E;AAAA,EAAC;AAAA;AAAA,IACC;AAAA,IACA,OAAM;AAAA,IACN,QAAO;AAAA,IACP,SAAQ;AAAA,IACR,MAAK;AAAA,IACL,QAAO;AAAA,IACP,aAAY;AAAA,IACZ,eAAc;AAAA,IACd,gBAAe;AAAA,IAEf,8BAAC,cAAS,QAAO,kBAAiB;AAAA;AACpC;AAMF,IAAM,sBAA2D,CAAC,EAAE,UAAU,MAC5E;AAAA,EAAC;AAAA;AAAA,IACC;AAAA,IACA,OAAM;AAAA,IACN,QAAO;AAAA,IACP,SAAQ;AAAA,IACR,MAAK;AAAA,IACL,QAAO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package/dist/chunk-N7LTE54T.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-N7LTE54T.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/chunk-UCVCAGU7.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-UCVCAGU7.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|