@uipath/apollo-wind 2.68.0 → 2.70.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/dist/components/custom/chat-first-experience.cjs +3 -3
- package/dist/components/custom/chat-first-experience.js +3 -3
- package/dist/components/custom/demo-composer.cjs +80 -0
- package/dist/components/custom/demo-composer.d.ts +11 -0
- package/dist/components/custom/demo-composer.js +46 -0
- package/dist/components/custom/panel-flow.cjs +2 -2
- package/dist/components/custom/panel-flow.js +2 -2
- package/dist/components/ui/chat-composer.cjs +429 -0
- package/dist/components/ui/chat-composer.d.ts +157 -0
- package/dist/components/ui/chat-composer.js +359 -0
- package/dist/components/ui/citation.cjs +188 -0
- package/dist/components/ui/citation.d.ts +42 -0
- package/dist/components/ui/citation.js +148 -0
- package/dist/components/ui/code-block.cjs +375 -0
- package/dist/components/ui/code-block.d.ts +38 -0
- package/dist/components/ui/code-block.js +307 -0
- package/dist/components/ui/dropzone-overlay.cjs +142 -0
- package/dist/components/ui/dropzone-overlay.d.ts +27 -0
- package/dist/components/ui/dropzone-overlay.js +105 -0
- package/dist/components/ui/file-upload.cjs +5 -29
- package/dist/components/ui/file-upload.js +2 -26
- package/dist/components/ui/file-validation.cjs +91 -0
- package/dist/components/ui/file-validation.d.ts +24 -0
- package/dist/components/ui/file-validation.js +51 -0
- package/dist/components/ui/hover-card.cjs +15 -8
- package/dist/components/ui/hover-card.d.ts +4 -1
- package/dist/components/ui/hover-card.js +16 -9
- package/dist/components/ui/index.cjs +330 -198
- package/dist/components/ui/index.d.ts +12 -0
- package/dist/components/ui/index.js +12 -0
- package/dist/components/ui/input-group.cjs +1 -1
- package/dist/components/ui/input-group.d.ts +2 -1
- package/dist/components/ui/input-group.js +1 -1
- package/dist/components/ui/json-tree-view/JsonTree.cjs +2 -2
- package/dist/components/ui/json-tree-view/JsonTree.js +1 -1
- package/dist/components/ui/json-tree-view/index.cjs +26 -23
- package/dist/components/ui/json-tree-view/index.d.ts +2 -2
- package/dist/components/ui/json-tree-view/index.js +2 -2
- package/dist/components/ui/live-region.cjs +106 -0
- package/dist/components/ui/live-region.d.ts +31 -0
- package/dist/components/ui/live-region.js +72 -0
- package/dist/components/ui/loading-dots.cjs +95 -0
- package/dist/components/ui/loading-dots.d.ts +21 -0
- package/dist/components/ui/loading-dots.js +55 -0
- package/dist/components/ui/markdown.cjs +428 -0
- package/dist/components/ui/markdown.d.ts +55 -0
- package/dist/components/ui/markdown.js +378 -0
- package/dist/components/ui/message-actions.cjs +302 -0
- package/dist/components/ui/message-actions.d.ts +102 -0
- package/dist/components/ui/message-actions.js +241 -0
- package/dist/components/ui/message.cjs +1 -1
- package/dist/components/ui/message.d.ts +2 -0
- package/dist/components/ui/message.js +1 -1
- package/dist/components/ui/sources.cjs +175 -0
- package/dist/components/ui/sources.d.ts +44 -0
- package/dist/components/ui/sources.js +132 -0
- package/dist/components/ui/thinking-indicator.cjs +146 -0
- package/dist/components/ui/thinking-indicator.d.ts +38 -0
- package/dist/components/ui/thinking-indicator.js +106 -0
- package/dist/components/ui/tool-call.cjs +359 -0
- package/dist/components/ui/tool-call.d.ts +75 -0
- package/dist/components/ui/tool-call.js +301 -0
- package/dist/index.cjs +433 -253
- package/dist/index.d.ts +24 -0
- package/dist/index.js +13 -1
- package/dist/lib/index.cjs +8 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +2 -1
- package/dist/lib/url.cjs +54 -0
- package/dist/lib/url.d.ts +8 -0
- package/dist/lib/url.js +17 -0
- package/dist/styles.css +363 -35
- package/dist/tailwind.utilities.css +21 -0
- package/package.json +7 -1
- package/dist/components/custom/chat-composer.cjs +0 -134
- package/dist/components/custom/chat-composer.d.ts +0 -14
- package/dist/components/custom/chat-composer.js +0 -100
- /package/dist/{components/ui/json-tree-view → lib}/clipboard.cjs +0 -0
- /package/dist/{components/ui/json-tree-view → lib}/clipboard.d.ts +0 -0
- /package/dist/{components/ui/json-tree-view → lib}/clipboard.js +0 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
import { ChevronDown, ChevronRight, CircleCheck, CircleX, Clock, Loader2 } from "lucide-react";
|
|
4
|
+
import { createContext, forwardRef, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useState } from "react";
|
|
5
|
+
import { cn } from "../../lib/index.js";
|
|
6
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "./collapsible.js";
|
|
7
|
+
import { JsonTreeView, buildJsonTree, collectContainerPaths } from "./json-tree-view/index.js";
|
|
8
|
+
const DEFAULT_TOOL_CALL_STRINGS = {
|
|
9
|
+
pending: 'Pending',
|
|
10
|
+
executing: 'Running',
|
|
11
|
+
completed: 'Completed',
|
|
12
|
+
failed: 'Failed',
|
|
13
|
+
running: (name)=>`Running '${name}'`,
|
|
14
|
+
ran: (name, duration)=>duration ? `Ran '${name}' for ${duration}` : `Ran '${name}'`,
|
|
15
|
+
input: 'Input',
|
|
16
|
+
output: 'Output',
|
|
17
|
+
errors: 'Errors'
|
|
18
|
+
};
|
|
19
|
+
const ToolCallContext = /*#__PURE__*/ createContext(null);
|
|
20
|
+
function useToolCallContext(component) {
|
|
21
|
+
const context = useContext(ToolCallContext);
|
|
22
|
+
if (!context) throw new Error(`${component} must be used within a ToolCall`);
|
|
23
|
+
return context;
|
|
24
|
+
}
|
|
25
|
+
function mergeStrings(overrides) {
|
|
26
|
+
const merged = {
|
|
27
|
+
...DEFAULT_TOOL_CALL_STRINGS
|
|
28
|
+
};
|
|
29
|
+
if (!overrides) return merged;
|
|
30
|
+
for (const key of Object.keys(overrides)){
|
|
31
|
+
const value = overrides[key];
|
|
32
|
+
if (void 0 !== value) merged[key] = value;
|
|
33
|
+
}
|
|
34
|
+
return merged;
|
|
35
|
+
}
|
|
36
|
+
const useIsomorphicLayoutEffect = "u" < typeof window ? useEffect : useLayoutEffect;
|
|
37
|
+
const TOGGLE_CLASSES = 'flex w-full min-w-0 items-center gap-2 rounded p-1 text-left transition-colors hover:text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring motion-reduce:transition-none';
|
|
38
|
+
const toolCallVariants = cva('group/tool-call flex w-full min-w-0 flex-col text-muted-foreground', {
|
|
39
|
+
variants: {
|
|
40
|
+
size: {
|
|
41
|
+
sm: 'p-2 text-xs',
|
|
42
|
+
md: 'p-3 text-sm'
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
defaultVariants: {
|
|
46
|
+
size: 'md'
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const ToolCall = /*#__PURE__*/ forwardRef(({ className, status, size = 'md', open, defaultOpen, onOpenChange, strings, jsonTreeStrings, ...props }, ref)=>{
|
|
50
|
+
const [contentCount, setContentCount] = useState(0);
|
|
51
|
+
const registerContent = useCallback(()=>{
|
|
52
|
+
setContentCount((count)=>count + 1);
|
|
53
|
+
return ()=>setContentCount((count)=>count - 1);
|
|
54
|
+
}, []);
|
|
55
|
+
const context = useMemo(()=>({
|
|
56
|
+
status,
|
|
57
|
+
strings: mergeStrings(strings),
|
|
58
|
+
jsonTreeStrings,
|
|
59
|
+
hasContent: contentCount > 0,
|
|
60
|
+
registerContent
|
|
61
|
+
}), [
|
|
62
|
+
status,
|
|
63
|
+
strings,
|
|
64
|
+
jsonTreeStrings,
|
|
65
|
+
contentCount,
|
|
66
|
+
registerContent
|
|
67
|
+
]);
|
|
68
|
+
return /*#__PURE__*/ jsx(ToolCallContext.Provider, {
|
|
69
|
+
value: context,
|
|
70
|
+
children: /*#__PURE__*/ jsx(Collapsible, {
|
|
71
|
+
asChild: true,
|
|
72
|
+
open: open,
|
|
73
|
+
defaultOpen: defaultOpen,
|
|
74
|
+
onOpenChange: onOpenChange,
|
|
75
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
76
|
+
ref: ref,
|
|
77
|
+
"data-slot": "tool-call",
|
|
78
|
+
"data-status": status,
|
|
79
|
+
"data-size": size,
|
|
80
|
+
className: cn(toolCallVariants({
|
|
81
|
+
size
|
|
82
|
+
}), className),
|
|
83
|
+
...props
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
ToolCall.displayName = 'ToolCall';
|
|
89
|
+
const STATUS_ICONS = {
|
|
90
|
+
pending: Clock,
|
|
91
|
+
executing: Loader2,
|
|
92
|
+
completed: CircleCheck,
|
|
93
|
+
failed: CircleX
|
|
94
|
+
};
|
|
95
|
+
const toolCallStatusIconVariants = cva('size-5 shrink-0 group-data-[size=sm]/tool-call:size-4', {
|
|
96
|
+
variants: {
|
|
97
|
+
status: {
|
|
98
|
+
pending: 'text-muted-foreground',
|
|
99
|
+
executing: 'animate-spin text-primary motion-reduce:animate-none',
|
|
100
|
+
completed: 'text-success',
|
|
101
|
+
failed: 'text-destructive'
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
const ToolCallHeader = /*#__PURE__*/ forwardRef(({ className, name, duration, ...props }, ref)=>{
|
|
106
|
+
const { status, strings, hasContent } = useToolCallContext('ToolCallHeader');
|
|
107
|
+
const StatusIcon = STATUS_ICONS[status];
|
|
108
|
+
const finished = 'completed' === status || 'failed' === status;
|
|
109
|
+
const line = /*#__PURE__*/ jsxs(Fragment, {
|
|
110
|
+
children: [
|
|
111
|
+
/*#__PURE__*/ jsx(StatusIcon, {
|
|
112
|
+
"data-slot": "tool-call-status-icon",
|
|
113
|
+
"aria-hidden": "true",
|
|
114
|
+
className: toolCallStatusIconVariants({
|
|
115
|
+
status
|
|
116
|
+
})
|
|
117
|
+
}),
|
|
118
|
+
/*#__PURE__*/ jsx("span", {
|
|
119
|
+
"data-slot": "tool-call-status",
|
|
120
|
+
className: "sr-only",
|
|
121
|
+
children: strings[status]
|
|
122
|
+
}),
|
|
123
|
+
' ',
|
|
124
|
+
/*#__PURE__*/ jsx("span", {
|
|
125
|
+
"data-slot": "tool-call-label",
|
|
126
|
+
className: "min-w-0 wrap-break-word",
|
|
127
|
+
children: finished ? strings.ran(name, duration) : strings.running(name)
|
|
128
|
+
})
|
|
129
|
+
]
|
|
130
|
+
});
|
|
131
|
+
return /*#__PURE__*/ jsx("div", {
|
|
132
|
+
ref: ref,
|
|
133
|
+
"data-slot": "tool-call-header",
|
|
134
|
+
className: cn('flex min-w-0', className),
|
|
135
|
+
...props,
|
|
136
|
+
children: hasContent ? /*#__PURE__*/ jsxs(CollapsibleTrigger, {
|
|
137
|
+
"data-slot": "tool-call-toggle",
|
|
138
|
+
className: cn('group/tool-call-toggle', TOGGLE_CLASSES),
|
|
139
|
+
children: [
|
|
140
|
+
line,
|
|
141
|
+
/*#__PURE__*/ jsx(ChevronDown, {
|
|
142
|
+
"aria-hidden": "true",
|
|
143
|
+
className: "size-4 shrink-0 transition-transform motion-reduce:transition-none group-data-[state=open]/tool-call-toggle:rotate-180"
|
|
144
|
+
})
|
|
145
|
+
]
|
|
146
|
+
}) : /*#__PURE__*/ jsx("div", {
|
|
147
|
+
className: "flex min-w-0 items-center gap-2 p-1",
|
|
148
|
+
children: line
|
|
149
|
+
})
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
ToolCallHeader.displayName = 'ToolCallHeader';
|
|
153
|
+
const ToolCallContent = /*#__PURE__*/ forwardRef(({ className, ...props }, ref)=>{
|
|
154
|
+
const { registerContent } = useToolCallContext('ToolCallContent');
|
|
155
|
+
useIsomorphicLayoutEffect(()=>registerContent(), [
|
|
156
|
+
registerContent
|
|
157
|
+
]);
|
|
158
|
+
return /*#__PURE__*/ jsx(CollapsibleContent, {
|
|
159
|
+
ref: ref,
|
|
160
|
+
"data-slot": "tool-call-content",
|
|
161
|
+
className: cn('mt-2 ml-3 flex min-w-0 flex-col border-l pl-3 group-data-[size=sm]/tool-call:ml-2 group-data-[size=sm]/tool-call:pl-2', className),
|
|
162
|
+
...props
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
ToolCallContent.displayName = 'ToolCallContent';
|
|
166
|
+
const ToolCallSection = /*#__PURE__*/ forwardRef(({ className, title, open, defaultOpen = false, onOpenChange, children, ...props }, ref)=>{
|
|
167
|
+
useToolCallContext('ToolCallSection');
|
|
168
|
+
return /*#__PURE__*/ jsx(Collapsible, {
|
|
169
|
+
asChild: true,
|
|
170
|
+
open: open,
|
|
171
|
+
defaultOpen: defaultOpen,
|
|
172
|
+
onOpenChange: onOpenChange,
|
|
173
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
174
|
+
ref: ref,
|
|
175
|
+
"data-slot": "tool-call-section",
|
|
176
|
+
className: cn('flex min-w-0 flex-col', className),
|
|
177
|
+
...props,
|
|
178
|
+
children: [
|
|
179
|
+
/*#__PURE__*/ jsxs(CollapsibleTrigger, {
|
|
180
|
+
"data-slot": "tool-call-section-toggle",
|
|
181
|
+
className: cn('group/tool-call-section-toggle', TOGGLE_CLASSES),
|
|
182
|
+
children: [
|
|
183
|
+
/*#__PURE__*/ jsx(ChevronRight, {
|
|
184
|
+
"aria-hidden": "true",
|
|
185
|
+
className: "size-4 shrink-0 transition-transform motion-reduce:transition-none group-data-[state=open]/tool-call-section-toggle:rotate-90"
|
|
186
|
+
}),
|
|
187
|
+
title
|
|
188
|
+
]
|
|
189
|
+
}),
|
|
190
|
+
/*#__PURE__*/ jsx(CollapsibleContent, {
|
|
191
|
+
"data-slot": "tool-call-section-content",
|
|
192
|
+
className: "ml-7 min-w-0",
|
|
193
|
+
children: children
|
|
194
|
+
})
|
|
195
|
+
]
|
|
196
|
+
})
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
ToolCallSection.displayName = 'ToolCallSection';
|
|
200
|
+
function isJsonContainer(value) {
|
|
201
|
+
if (Array.isArray(value)) return true;
|
|
202
|
+
if ('object' != typeof value || null === value) return false;
|
|
203
|
+
const prototype = Object.getPrototypeOf(value);
|
|
204
|
+
return prototype === Object.prototype || null === prototype;
|
|
205
|
+
}
|
|
206
|
+
const VIRTUALIZE_NODE_COUNT = 200;
|
|
207
|
+
function countNodes(nodes) {
|
|
208
|
+
let count = 0;
|
|
209
|
+
const stack = [
|
|
210
|
+
...nodes
|
|
211
|
+
];
|
|
212
|
+
while(stack.length > 0){
|
|
213
|
+
const node = stack.pop();
|
|
214
|
+
count += 1;
|
|
215
|
+
if (node.children) stack.push(...node.children);
|
|
216
|
+
}
|
|
217
|
+
return count;
|
|
218
|
+
}
|
|
219
|
+
function ToolCallJsonValue({ value }) {
|
|
220
|
+
const { jsonTreeStrings } = useToolCallContext('ToolCallJsonValue');
|
|
221
|
+
const nodes = useMemo(()=>buildJsonTree({
|
|
222
|
+
value
|
|
223
|
+
}), [
|
|
224
|
+
value
|
|
225
|
+
]);
|
|
226
|
+
const [opened, setOpened] = useState({});
|
|
227
|
+
const collapsed = useMemo(()=>Object.fromEntries(collectContainerPaths(nodes).map(({ path })=>[
|
|
228
|
+
path,
|
|
229
|
+
!opened[path]
|
|
230
|
+
])), [
|
|
231
|
+
nodes,
|
|
232
|
+
opened
|
|
233
|
+
]);
|
|
234
|
+
const toggle = useCallback((path)=>setOpened((prev)=>({
|
|
235
|
+
...prev,
|
|
236
|
+
[path]: !prev[path]
|
|
237
|
+
})), []);
|
|
238
|
+
const virtualized = useMemo(()=>countNodes(nodes) > VIRTUALIZE_NODE_COUNT, [
|
|
239
|
+
nodes
|
|
240
|
+
]);
|
|
241
|
+
const [scrollElement, setScrollElement] = useState(null);
|
|
242
|
+
return /*#__PURE__*/ jsx("div", {
|
|
243
|
+
ref: setScrollElement,
|
|
244
|
+
"data-slot": "tool-call-value",
|
|
245
|
+
className: "my-2 max-h-80 overflow-auto rounded-md border bg-background",
|
|
246
|
+
children: /*#__PURE__*/ jsx(JsonTreeView, {
|
|
247
|
+
nodes: nodes,
|
|
248
|
+
collapsed: collapsed,
|
|
249
|
+
onToggleCollapsed: toggle,
|
|
250
|
+
readOnly: true,
|
|
251
|
+
strings: jsonTreeStrings,
|
|
252
|
+
virtualized: virtualized,
|
|
253
|
+
scrollElement: virtualized ? scrollElement : void 0
|
|
254
|
+
})
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function ToolCallTextValue({ value }) {
|
|
258
|
+
return /*#__PURE__*/ jsx("div", {
|
|
259
|
+
tabIndex: 0,
|
|
260
|
+
"data-slot": "tool-call-value",
|
|
261
|
+
className: "my-2 max-h-45 overflow-y-auto rounded bg-muted px-3 py-2 text-xs wrap-break-word whitespace-pre-wrap outline-hidden focus-visible:ring-2 focus-visible:ring-ring",
|
|
262
|
+
children: String(value)
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
function ToolCallValue({ value, renderValue }) {
|
|
266
|
+
const custom = renderValue?.(value);
|
|
267
|
+
if (void 0 !== custom) return /*#__PURE__*/ jsx(Fragment, {
|
|
268
|
+
children: custom
|
|
269
|
+
});
|
|
270
|
+
if (!isJsonContainer(value)) return /*#__PURE__*/ jsx(ToolCallTextValue, {
|
|
271
|
+
value: value
|
|
272
|
+
});
|
|
273
|
+
if (0 === Object.keys(value).length) return /*#__PURE__*/ jsx(ToolCallTextValue, {
|
|
274
|
+
value: Array.isArray(value) ? '[]' : '{}'
|
|
275
|
+
});
|
|
276
|
+
return /*#__PURE__*/ jsx(ToolCallJsonValue, {
|
|
277
|
+
value: value
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
function createValueSection(slot, titleKey, displayName) {
|
|
281
|
+
const Section = /*#__PURE__*/ forwardRef(({ value, renderValue, ...props }, ref)=>{
|
|
282
|
+
const { strings } = useToolCallContext(displayName);
|
|
283
|
+
if (null == value) return null;
|
|
284
|
+
return /*#__PURE__*/ jsx(ToolCallSection, {
|
|
285
|
+
ref: ref,
|
|
286
|
+
"data-slot": `tool-call-${slot}`,
|
|
287
|
+
title: strings[titleKey],
|
|
288
|
+
...props,
|
|
289
|
+
children: /*#__PURE__*/ jsx(ToolCallValue, {
|
|
290
|
+
value: value,
|
|
291
|
+
renderValue: renderValue
|
|
292
|
+
})
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
Section.displayName = displayName;
|
|
296
|
+
return Section;
|
|
297
|
+
}
|
|
298
|
+
const ToolCallInput = createValueSection('input', 'input', 'ToolCallInput');
|
|
299
|
+
const ToolCallOutput = createValueSection('output', 'output', 'ToolCallOutput');
|
|
300
|
+
const ToolCallError = createValueSection('error', 'errors', 'ToolCallError');
|
|
301
|
+
export { DEFAULT_TOOL_CALL_STRINGS, ToolCall, ToolCallContent, ToolCallError, ToolCallHeader, ToolCallInput, ToolCallOutput, ToolCallSection, toolCallVariants };
|