@copilotkit/react-ui 1.7.2-next.1 → 1.7.2-next.2
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 +9 -0
- package/dist/{chunk-AZU4QOV5.mjs → chunk-AELKLZSG.mjs} +5 -5
- package/dist/{chunk-3PJA5MFR.mjs → chunk-DLG7BZTA.mjs} +2 -2
- package/dist/chunk-EJG6RRSX.mjs +138 -0
- package/dist/chunk-EJG6RRSX.mjs.map +1 -0
- package/dist/chunk-MCO235PS.mjs +164 -0
- package/dist/chunk-MCO235PS.mjs.map +1 -0
- package/dist/chunk-MWC5OV7Z.mjs +1 -0
- package/dist/chunk-N7LTE54T.mjs +1 -0
- package/dist/chunk-N7LTE54T.mjs.map +1 -0
- package/dist/{chunk-2C3ANQCY.mjs → chunk-QXQDIFOC.mjs} +9 -9
- package/dist/{chunk-ADTTDBLB.mjs → chunk-R2O33F44.mjs} +2 -2
- package/dist/chunk-UCVCAGU7.mjs +1 -0
- package/dist/chunk-UCVCAGU7.mjs.map +1 -0
- package/dist/{chunk-22K5DDPF.mjs → chunk-ZIF5JJCH.mjs} +8 -8
- package/dist/components/chat/Chat.mjs +7 -7
- package/dist/components/chat/Modal.mjs +8 -8
- package/dist/components/chat/Popup.mjs +9 -9
- package/dist/components/chat/Sidebar.mjs +9 -9
- package/dist/components/chat/index.mjs +12 -12
- package/dist/components/crew/DefaultResponseRenderer.d.ts +110 -0
- package/dist/components/crew/DefaultResponseRenderer.js +175 -0
- package/dist/components/crew/DefaultResponseRenderer.js.map +1 -0
- package/dist/components/crew/DefaultResponseRenderer.mjs +10 -0
- package/dist/components/crew/DefaultResponseRenderer.mjs.map +1 -0
- package/dist/components/crew/DefaultStateRenderer.d.ts +88 -0
- package/dist/components/crew/DefaultStateRenderer.js +198 -0
- package/dist/components/crew/DefaultStateRenderer.js.map +1 -0
- package/dist/components/crew/DefaultStateRenderer.mjs +8 -0
- package/dist/components/crew/DefaultStateRenderer.mjs.map +1 -0
- package/dist/components/crew/index.d.ts +4 -0
- package/dist/components/crew/index.js +335 -0
- package/dist/components/crew/index.js.map +1 -0
- package/dist/components/crew/index.mjs +16 -0
- package/dist/components/crew/index.mjs.map +1 -0
- package/dist/components/crew/types.d.ts +340 -0
- package/dist/components/crew/types.js +19 -0
- package/dist/components/crew/types.js.map +1 -0
- package/dist/components/crew/types.mjs +2 -0
- package/dist/components/crew/types.mjs.map +1 -0
- package/dist/components/dev-console/console.mjs +3 -3
- package/dist/components/dev-console/index.mjs +4 -4
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +290 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +26 -14
- package/dist/index.css +227 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +292 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -14
- package/package.json +4 -4
- package/src/components/crew/DefaultResponseRenderer.tsx +298 -0
- package/src/components/crew/DefaultStateRenderer.tsx +326 -0
- package/src/components/crew/index.ts +3 -0
- package/src/components/crew/types.ts +398 -0
- package/src/components/index.ts +1 -0
- package/src/css/crew.css +277 -0
- package/src/styles.css +1 -0
- package/dist/chunk-MMVDU6DF.mjs +0 -1
- /package/dist/{chunk-AZU4QOV5.mjs.map → chunk-AELKLZSG.mjs.map} +0 -0
- /package/dist/{chunk-3PJA5MFR.mjs.map → chunk-DLG7BZTA.mjs.map} +0 -0
- /package/dist/{chunk-MMVDU6DF.mjs.map → chunk-MWC5OV7Z.mjs.map} +0 -0
- /package/dist/{chunk-2C3ANQCY.mjs.map → chunk-QXQDIFOC.mjs.map} +0 -0
- /package/dist/{chunk-ADTTDBLB.mjs.map → chunk-R2O33F44.mjs.map} +0 -0
- /package/dist/{chunk-22K5DDPF.mjs.map → chunk-ZIF5JJCH.mjs.map} +0 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <br/>
|
|
3
|
+
* A state renderer component for the CopilotKit framework. This component displays
|
|
4
|
+
* the internal state of an agent, such as the steps it has taken and the tasks it has performed.
|
|
5
|
+
* It provides a collapsible UI that shows the agent's thought process and actions.
|
|
6
|
+
*
|
|
7
|
+
* ## Install Dependencies
|
|
8
|
+
*
|
|
9
|
+
* This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.
|
|
10
|
+
*
|
|
11
|
+
* ```shell npm2yarn \"@copilotkit/react-ui"\
|
|
12
|
+
* npm install @copilotkit/react-core @copilotkit/react-ui
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* ## Usage
|
|
16
|
+
*
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { DefaultStateRenderer } from "@copilotkit/react-ui";
|
|
19
|
+
* import "@copilotkit/react-ui/styles.css";
|
|
20
|
+
*
|
|
21
|
+
* // Basic usage
|
|
22
|
+
* <DefaultStateRenderer
|
|
23
|
+
* state={agentState}
|
|
24
|
+
* status="inProgress"
|
|
25
|
+
* />
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* ## Customization
|
|
29
|
+
*
|
|
30
|
+
* You can customize the appearance and behavior of the component:
|
|
31
|
+
*
|
|
32
|
+
* ```tsx
|
|
33
|
+
* // Custom labels and styling
|
|
34
|
+
* <DefaultStateRenderer
|
|
35
|
+
* state={agentState}
|
|
36
|
+
* status="inProgress"
|
|
37
|
+
* labels={{
|
|
38
|
+
* inProgressLabel: "Thinking...",
|
|
39
|
+
* completeLabel: "Finished processing",
|
|
40
|
+
* emptyLabel: "Nothing to show"
|
|
41
|
+
* }}
|
|
42
|
+
* className="my-custom-state"
|
|
43
|
+
* contentClassName="my-custom-content"
|
|
44
|
+
* itemClassName="my-custom-item"
|
|
45
|
+
* maxHeight="300px"
|
|
46
|
+
* defaultCollapsed={false}
|
|
47
|
+
* />
|
|
48
|
+
*
|
|
49
|
+
* // Custom renderers
|
|
50
|
+
* <DefaultStateRenderer
|
|
51
|
+
* state={agentState}
|
|
52
|
+
* status="inProgress"
|
|
53
|
+
* StateItemRenderer={({ item, isNewest, className }) => (
|
|
54
|
+
* <MyCustomItemRenderer item={item} isNewest={isNewest} className={className} />
|
|
55
|
+
* )}
|
|
56
|
+
* SkeletonLoader={({ className }) => (
|
|
57
|
+
* <MyCustomSkeletonLoader className={className} />
|
|
58
|
+
* )}
|
|
59
|
+
* />
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* ### Look & Feel
|
|
63
|
+
*
|
|
64
|
+
* By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:
|
|
65
|
+
* ```tsx title="YourRootComponent.tsx"
|
|
66
|
+
* ...
|
|
67
|
+
* import "@copilotkit/react-ui/styles.css"; // [!code highlight]
|
|
68
|
+
*
|
|
69
|
+
* export function YourRootComponent() {
|
|
70
|
+
* return (
|
|
71
|
+
* <CopilotKit>
|
|
72
|
+
* ...
|
|
73
|
+
* </CopilotKit>
|
|
74
|
+
* );
|
|
75
|
+
* }
|
|
76
|
+
* ```
|
|
77
|
+
* 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.
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
import React, { useState, useRef, useEffect, useMemo } from "react";
|
|
81
|
+
import {
|
|
82
|
+
AgentState,
|
|
83
|
+
StateRendererProps,
|
|
84
|
+
StateItemRendererProps,
|
|
85
|
+
SkeletonLoaderProps,
|
|
86
|
+
ToolStateItem,
|
|
87
|
+
TaskStateItem,
|
|
88
|
+
ResponseRendererIconProps,
|
|
89
|
+
} from "./types";
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Default expand icon component
|
|
93
|
+
*/
|
|
94
|
+
const DefaultExpandIcon: React.FC<ResponseRendererIconProps> = ({ className }) => (
|
|
95
|
+
<svg
|
|
96
|
+
className={className}
|
|
97
|
+
width="16"
|
|
98
|
+
height="16"
|
|
99
|
+
viewBox="0 0 24 24"
|
|
100
|
+
fill="none"
|
|
101
|
+
stroke="currentColor"
|
|
102
|
+
strokeWidth="2"
|
|
103
|
+
strokeLinecap="round"
|
|
104
|
+
strokeLinejoin="round"
|
|
105
|
+
>
|
|
106
|
+
<polyline points="6 9 12 15 18 9"></polyline>
|
|
107
|
+
</svg>
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Default collapse icon component
|
|
112
|
+
*/
|
|
113
|
+
const DefaultCollapseIcon: React.FC<ResponseRendererIconProps> = ({ className }) => (
|
|
114
|
+
<svg
|
|
115
|
+
className={className}
|
|
116
|
+
width="16"
|
|
117
|
+
height="16"
|
|
118
|
+
viewBox="0 0 24 24"
|
|
119
|
+
fill="none"
|
|
120
|
+
stroke="currentColor"
|
|
121
|
+
strokeWidth="2"
|
|
122
|
+
strokeLinecap="round"
|
|
123
|
+
strokeLinejoin="round"
|
|
124
|
+
>
|
|
125
|
+
<polyline points="18 15 12 9 6 15"></polyline>
|
|
126
|
+
</svg>
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Default loader icon component
|
|
131
|
+
*/
|
|
132
|
+
const DefaultLoaderIcon: React.FC<ResponseRendererIconProps> = ({ className }) => (
|
|
133
|
+
<svg
|
|
134
|
+
className={`${className} copilotkit-spinner`}
|
|
135
|
+
width="16"
|
|
136
|
+
height="16"
|
|
137
|
+
viewBox="0 0 24 24"
|
|
138
|
+
fill="none"
|
|
139
|
+
stroke="currentColor"
|
|
140
|
+
strokeWidth="2"
|
|
141
|
+
strokeLinecap="round"
|
|
142
|
+
strokeLinejoin="round"
|
|
143
|
+
>
|
|
144
|
+
<path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
|
|
145
|
+
</svg>
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Helper to safely format content
|
|
150
|
+
*/
|
|
151
|
+
const formatContent = (result: unknown): string => {
|
|
152
|
+
if (result === null || result === undefined) return "";
|
|
153
|
+
return typeof result === "string" ? result : JSON.stringify(result, null, 2);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Default skeleton loader component
|
|
158
|
+
*/
|
|
159
|
+
const DefaultSkeletonLoader: React.FC<SkeletonLoaderProps> = ({ className }) => (
|
|
160
|
+
<div className={className || "copilotkit-skeleton"}>
|
|
161
|
+
<div className="copilotkit-skeleton-header">
|
|
162
|
+
<div className="copilotkit-skeleton-title"></div>
|
|
163
|
+
<div className="copilotkit-skeleton-subtitle"></div>
|
|
164
|
+
</div>
|
|
165
|
+
<div className="copilotkit-skeleton-content"></div>
|
|
166
|
+
</div>
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Default state item renderer component
|
|
171
|
+
*/
|
|
172
|
+
const DefaultStateItemRenderer: React.FC<StateItemRendererProps> = ({
|
|
173
|
+
item,
|
|
174
|
+
isNewest,
|
|
175
|
+
className,
|
|
176
|
+
}) => (
|
|
177
|
+
<div
|
|
178
|
+
className={`${className || "copilotkit-state-item"} ${isNewest ? "copilotkit-state-item-newest" : ""}`}
|
|
179
|
+
>
|
|
180
|
+
<div className="copilotkit-state-item-header">{"tool" in item ? item.tool : item.name}</div>
|
|
181
|
+
|
|
182
|
+
{"thought" in item && item.thought && (
|
|
183
|
+
<div className="copilotkit-state-item-thought">{item.thought}</div>
|
|
184
|
+
)}
|
|
185
|
+
|
|
186
|
+
{"result" in item && item.result !== undefined && item.result !== null && (
|
|
187
|
+
<div className="copilotkit-state-item-result">{formatContent(item.result)}</div>
|
|
188
|
+
)}
|
|
189
|
+
|
|
190
|
+
{"description" in item && item.description && (
|
|
191
|
+
<div className="copilotkit-state-item-description">{item.description}</div>
|
|
192
|
+
)}
|
|
193
|
+
</div>
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Default state renderer component
|
|
198
|
+
*/
|
|
199
|
+
export const DefaultStateRenderer: React.FC<StateRendererProps> = ({
|
|
200
|
+
state,
|
|
201
|
+
status,
|
|
202
|
+
StateItemRenderer = DefaultStateItemRenderer,
|
|
203
|
+
SkeletonLoader = DefaultSkeletonLoader,
|
|
204
|
+
labels,
|
|
205
|
+
icons,
|
|
206
|
+
className = "copilotkit-state",
|
|
207
|
+
contentClassName = "copilotkit-state-content",
|
|
208
|
+
itemClassName = "copilotkit-state-item",
|
|
209
|
+
maxHeight = "250px",
|
|
210
|
+
defaultCollapsed = true,
|
|
211
|
+
}) => {
|
|
212
|
+
const [isCollapsed, setIsCollapsed] = useState(defaultCollapsed);
|
|
213
|
+
const contentRef = useRef<HTMLDivElement>(null);
|
|
214
|
+
const prevItemsLengthRef = useRef<number>(0);
|
|
215
|
+
const [newestItemId, setNewestItemId] = useState<string | null>(null);
|
|
216
|
+
|
|
217
|
+
// Default label values
|
|
218
|
+
const defaultLabels = {
|
|
219
|
+
inProgressLabel: "Analyzing",
|
|
220
|
+
completeLabel: "Analyzed",
|
|
221
|
+
emptyLabel: "No activity",
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
// Merge provided labels with defaults
|
|
225
|
+
const mergedLabels = { ...defaultLabels, ...labels };
|
|
226
|
+
|
|
227
|
+
// Decide which icon to display
|
|
228
|
+
const ExpandIcon = icons?.expand || DefaultExpandIcon;
|
|
229
|
+
const CollapseIcon = icons?.collapse || DefaultCollapseIcon;
|
|
230
|
+
|
|
231
|
+
// Safely compute derived values using useMemo
|
|
232
|
+
const items = useMemo(() => {
|
|
233
|
+
return state
|
|
234
|
+
? [...(state.steps?.filter((s) => s.tool) || []), ...(state.tasks || [])].sort(
|
|
235
|
+
(a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime(),
|
|
236
|
+
)
|
|
237
|
+
: [];
|
|
238
|
+
}, [state]);
|
|
239
|
+
|
|
240
|
+
// Determine if we should show skeleton UI (thinking but no items yet)
|
|
241
|
+
const isThinking = status === "inProgress" && items.length === 0;
|
|
242
|
+
|
|
243
|
+
// Track newest item and auto-scroll
|
|
244
|
+
useEffect(() => {
|
|
245
|
+
if (!state) return; // Skip effect if no state
|
|
246
|
+
|
|
247
|
+
// If new items were added
|
|
248
|
+
if (items.length > prevItemsLengthRef.current) {
|
|
249
|
+
// Get the newest item
|
|
250
|
+
if (items.length > 0) {
|
|
251
|
+
const newest = items[items.length - 1];
|
|
252
|
+
setNewestItemId(newest.id);
|
|
253
|
+
|
|
254
|
+
// Clear the animation after 1.5 seconds
|
|
255
|
+
setTimeout(() => {
|
|
256
|
+
setNewestItemId(null);
|
|
257
|
+
}, 1500);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Auto-scroll to bottom
|
|
261
|
+
if (contentRef.current && !isCollapsed) {
|
|
262
|
+
contentRef.current.scrollTop = contentRef.current.scrollHeight;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
prevItemsLengthRef.current = items.length;
|
|
267
|
+
}, [items, isCollapsed, state]);
|
|
268
|
+
|
|
269
|
+
// Early return for loading state with no state
|
|
270
|
+
if (!state) {
|
|
271
|
+
return (
|
|
272
|
+
<div className={className}>
|
|
273
|
+
<DefaultLoaderIcon className="copilotkit-loader" />
|
|
274
|
+
</div>
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Don't render anything if collapsed and empty and not thinking
|
|
279
|
+
if (isCollapsed && items.length === 0 && !isThinking) return null;
|
|
280
|
+
|
|
281
|
+
return (
|
|
282
|
+
<div className={className}>
|
|
283
|
+
{/* Header with toggle */}
|
|
284
|
+
<div className="copilotkit-state-header" onClick={() => setIsCollapsed(!isCollapsed)}>
|
|
285
|
+
{isCollapsed ? (
|
|
286
|
+
<ExpandIcon className="copilotkit-icon" />
|
|
287
|
+
) : (
|
|
288
|
+
<CollapseIcon className="copilotkit-icon" />
|
|
289
|
+
)}
|
|
290
|
+
<div className="copilotkit-state-label">
|
|
291
|
+
{status === "inProgress" ? (
|
|
292
|
+
<span className="copilotkit-state-label-loading">{mergedLabels.inProgressLabel}</span>
|
|
293
|
+
) : (
|
|
294
|
+
mergedLabels.completeLabel
|
|
295
|
+
)}
|
|
296
|
+
</div>
|
|
297
|
+
</div>
|
|
298
|
+
|
|
299
|
+
{/* Content area */}
|
|
300
|
+
{!isCollapsed && (
|
|
301
|
+
<div ref={contentRef} className={contentClassName} style={{ maxHeight }}>
|
|
302
|
+
{/* Render items if available */}
|
|
303
|
+
{items.length > 0 ? (
|
|
304
|
+
items.map((item) => (
|
|
305
|
+
<StateItemRenderer
|
|
306
|
+
key={item.id}
|
|
307
|
+
item={item}
|
|
308
|
+
isNewest={item.id === newestItemId}
|
|
309
|
+
className={itemClassName}
|
|
310
|
+
/>
|
|
311
|
+
))
|
|
312
|
+
) : isThinking ? (
|
|
313
|
+
// Show skeleton loader while thinking
|
|
314
|
+
<>
|
|
315
|
+
<SkeletonLoader />
|
|
316
|
+
<SkeletonLoader />
|
|
317
|
+
</>
|
|
318
|
+
) : (
|
|
319
|
+
// Empty state
|
|
320
|
+
<div className="copilotkit-state-empty">{mergedLabels.emptyLabel}</div>
|
|
321
|
+
)}
|
|
322
|
+
</div>
|
|
323
|
+
)}
|
|
324
|
+
</div>
|
|
325
|
+
);
|
|
326
|
+
};
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Status of a response or action that requires user input
|
|
5
|
+
*/
|
|
6
|
+
export type ResponseStatus = "inProgress" | "complete" | "executing";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Response data structure for the ResponseRenderer
|
|
10
|
+
*/
|
|
11
|
+
export interface Response {
|
|
12
|
+
/**
|
|
13
|
+
* Unique identifier for the response
|
|
14
|
+
*/
|
|
15
|
+
id: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The content of the response to display
|
|
19
|
+
*/
|
|
20
|
+
content: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Optional metadata for the response
|
|
24
|
+
*/
|
|
25
|
+
metadata?: Record<string, any>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Optional cache for storing user feedback
|
|
30
|
+
*/
|
|
31
|
+
export interface ResponseCache<T extends { id: string }> {
|
|
32
|
+
/**
|
|
33
|
+
* Get feedback for a specific ID
|
|
34
|
+
*/
|
|
35
|
+
getResponse: (id: string) => T | undefined;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Set feedback for a specific ID
|
|
39
|
+
*/
|
|
40
|
+
setResponse: (id: string, response: T) => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Props for custom icon components
|
|
45
|
+
*/
|
|
46
|
+
export interface ResponseRendererIconProps {
|
|
47
|
+
className?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Icons for the ResponseRenderer component
|
|
52
|
+
*/
|
|
53
|
+
export interface ResponseRendererIcons {
|
|
54
|
+
/**
|
|
55
|
+
* Icon for expanding content
|
|
56
|
+
*/
|
|
57
|
+
expand?: React.ComponentType<ResponseRendererIconProps>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Icon for collapsing content
|
|
61
|
+
*/
|
|
62
|
+
collapse?: React.ComponentType<ResponseRendererIconProps>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Labels for the ResponseRenderer component
|
|
67
|
+
*/
|
|
68
|
+
export interface ResponseRendererLabels {
|
|
69
|
+
/**
|
|
70
|
+
* Label for the response section
|
|
71
|
+
*/
|
|
72
|
+
responseLabel?: string;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Label for the approve button
|
|
76
|
+
*/
|
|
77
|
+
approveLabel?: string;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Label for the reject button
|
|
81
|
+
*/
|
|
82
|
+
rejectLabel?: string;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Message shown when approved
|
|
86
|
+
*/
|
|
87
|
+
approvedMessage?: string;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Message shown when rejected
|
|
91
|
+
*/
|
|
92
|
+
rejectedMessage?: string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Message shown when feedback is submitted
|
|
96
|
+
*/
|
|
97
|
+
feedbackSubmittedMessage?: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Props for the content renderer component
|
|
102
|
+
*/
|
|
103
|
+
export interface ContentRendererProps {
|
|
104
|
+
/**
|
|
105
|
+
* Content to render
|
|
106
|
+
*/
|
|
107
|
+
content: string;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* CSS class name for styling
|
|
111
|
+
*/
|
|
112
|
+
className?: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Props for the feedback button component
|
|
117
|
+
*/
|
|
118
|
+
export interface FeedbackButtonProps {
|
|
119
|
+
/**
|
|
120
|
+
* The text to display on the button
|
|
121
|
+
*/
|
|
122
|
+
label: string;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Function to call when the button is clicked
|
|
126
|
+
*/
|
|
127
|
+
onClick: () => void;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* CSS class name for styling
|
|
131
|
+
*/
|
|
132
|
+
className?: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Props for the completed feedback display component
|
|
137
|
+
*/
|
|
138
|
+
export interface CompletedFeedbackProps {
|
|
139
|
+
/**
|
|
140
|
+
* The message to display
|
|
141
|
+
*/
|
|
142
|
+
message: string;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* CSS class name for styling
|
|
146
|
+
*/
|
|
147
|
+
className?: string;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Props for the ResponseRenderer component
|
|
152
|
+
*/
|
|
153
|
+
export interface ResponseRendererProps {
|
|
154
|
+
/**
|
|
155
|
+
* The response data to render
|
|
156
|
+
*/
|
|
157
|
+
response: Response;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The current status of the response
|
|
161
|
+
*/
|
|
162
|
+
status: ResponseStatus;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Function to call when a response is given
|
|
166
|
+
*/
|
|
167
|
+
onRespond?: (input: string) => void;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Custom icons for the component
|
|
171
|
+
*/
|
|
172
|
+
icons?: ResponseRendererIcons;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Custom labels for the component
|
|
176
|
+
*/
|
|
177
|
+
labels?: ResponseRendererLabels;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Custom component for rendering content
|
|
181
|
+
*/
|
|
182
|
+
ContentRenderer?: React.ComponentType<ContentRendererProps>;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Custom component for rendering feedback buttons
|
|
186
|
+
*/
|
|
187
|
+
FeedbackButton?: React.ComponentType<FeedbackButtonProps>;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Custom component for rendering completed feedback
|
|
191
|
+
*/
|
|
192
|
+
CompletedFeedback?: React.ComponentType<CompletedFeedbackProps>;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* CSS class for the root element
|
|
196
|
+
*/
|
|
197
|
+
className?: string;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* CSS class for the content element
|
|
201
|
+
*/
|
|
202
|
+
contentClassName?: string;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* CSS class for the actions container
|
|
206
|
+
*/
|
|
207
|
+
actionsClassName?: string;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* CSS class for feedback buttons
|
|
211
|
+
*/
|
|
212
|
+
buttonClassName?: string;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* CSS class for completed feedback
|
|
216
|
+
*/
|
|
217
|
+
completedFeedbackClassName?: string;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Children nodes
|
|
221
|
+
*/
|
|
222
|
+
children?: ReactNode;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Base state item interface for agent state items
|
|
227
|
+
*/
|
|
228
|
+
export interface StateItem {
|
|
229
|
+
/**
|
|
230
|
+
* Unique identifier for the item
|
|
231
|
+
*/
|
|
232
|
+
id: string;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Timestamp when the item was created
|
|
236
|
+
*/
|
|
237
|
+
timestamp: string;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Tool execution state item
|
|
242
|
+
*/
|
|
243
|
+
export interface ToolStateItem extends StateItem {
|
|
244
|
+
/**
|
|
245
|
+
* Name of the tool that was executed
|
|
246
|
+
*/
|
|
247
|
+
tool: string;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Optional thought process for the tool execution
|
|
251
|
+
*/
|
|
252
|
+
thought?: string;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Result of the tool execution
|
|
256
|
+
*/
|
|
257
|
+
result?: any;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Task state item
|
|
262
|
+
*/
|
|
263
|
+
export interface TaskStateItem extends StateItem {
|
|
264
|
+
/**
|
|
265
|
+
* Name of the task
|
|
266
|
+
*/
|
|
267
|
+
name: string;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Description of the task
|
|
271
|
+
*/
|
|
272
|
+
description?: string;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* AgentState containing information about steps and tasks
|
|
277
|
+
*/
|
|
278
|
+
export interface AgentState {
|
|
279
|
+
/**
|
|
280
|
+
* Array of tool execution steps
|
|
281
|
+
*/
|
|
282
|
+
steps?: ToolStateItem[];
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Array of tasks
|
|
286
|
+
*/
|
|
287
|
+
tasks?: TaskStateItem[];
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Props for the item renderer component
|
|
292
|
+
*/
|
|
293
|
+
export interface StateItemRendererProps {
|
|
294
|
+
/**
|
|
295
|
+
* The item to render
|
|
296
|
+
*/
|
|
297
|
+
item: ToolStateItem | TaskStateItem;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Whether the item is the newest
|
|
301
|
+
*/
|
|
302
|
+
isNewest: boolean;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* CSS class for the item container
|
|
306
|
+
*/
|
|
307
|
+
className?: string;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Props for the skeleton loader component
|
|
312
|
+
*/
|
|
313
|
+
export interface SkeletonLoaderProps {
|
|
314
|
+
/**
|
|
315
|
+
* CSS class for the skeleton
|
|
316
|
+
*/
|
|
317
|
+
className?: string;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Props for the DefaultStateRenderer component
|
|
322
|
+
*/
|
|
323
|
+
export interface StateRendererProps {
|
|
324
|
+
/**
|
|
325
|
+
* The state to render
|
|
326
|
+
*/
|
|
327
|
+
state?: AgentState;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* The current status
|
|
331
|
+
*/
|
|
332
|
+
status: ResponseStatus;
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Custom component for rendering individual state items
|
|
336
|
+
*/
|
|
337
|
+
StateItemRenderer?: React.ComponentType<StateItemRendererProps>;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Custom component for showing a loading skeleton
|
|
341
|
+
*/
|
|
342
|
+
SkeletonLoader?: React.ComponentType<SkeletonLoaderProps>;
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Custom labels for the component
|
|
346
|
+
*/
|
|
347
|
+
labels?: {
|
|
348
|
+
/**
|
|
349
|
+
* Label shown when in progress
|
|
350
|
+
*/
|
|
351
|
+
inProgressLabel?: string;
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Label shown when complete
|
|
355
|
+
*/
|
|
356
|
+
completeLabel?: string;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Label shown when no items are present
|
|
360
|
+
*/
|
|
361
|
+
emptyLabel?: string;
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Custom icons for the component
|
|
366
|
+
*/
|
|
367
|
+
icons?: ResponseRendererIcons;
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* CSS class for the root element
|
|
371
|
+
*/
|
|
372
|
+
className?: string;
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* CSS class for the content container
|
|
376
|
+
*/
|
|
377
|
+
contentClassName?: string;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* CSS class for state items
|
|
381
|
+
*/
|
|
382
|
+
itemClassName?: string;
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Maximum height for the content area
|
|
386
|
+
*/
|
|
387
|
+
maxHeight?: string;
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Initial collapsed state
|
|
391
|
+
*/
|
|
392
|
+
defaultCollapsed?: boolean;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Children nodes
|
|
396
|
+
*/
|
|
397
|
+
children?: ReactNode;
|
|
398
|
+
}
|