@plaisolutions/react 0.2.0 → 0.3.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.
@@ -1,14 +1,591 @@
1
- import { useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
1
+ import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { Bot, CheckCircle2, Database, File, FileText, Globe, LoaderCircle, MessageSquare, Minus, Plug, Plus, Workflow, XCircle } from "lucide-react";
3
4
 
4
5
  //#region src/components/internal/join-classes.ts
5
6
  function joinClasses(...classes) {
6
7
  return classes.filter(Boolean).join(" ");
7
8
  }
8
9
 
10
+ //#endregion
11
+ //#region src/components/datasource-tool-result-card.tsx
12
+ function DatasourceIcon() {
13
+ return /* @__PURE__ */ jsxs("svg", {
14
+ xmlns: "http://www.w3.org/2000/svg",
15
+ width: "20",
16
+ height: "20",
17
+ viewBox: "0 0 20 20",
18
+ fill: "none",
19
+ stroke: "currentColor",
20
+ strokeWidth: "1.5",
21
+ strokeLinecap: "round",
22
+ strokeLinejoin: "round",
23
+ "aria-hidden": "true",
24
+ children: [
25
+ /* @__PURE__ */ jsx("rect", {
26
+ x: "2.75",
27
+ y: "3.25",
28
+ width: "13",
29
+ height: "11",
30
+ rx: "1.5"
31
+ }),
32
+ /* @__PURE__ */ jsx("path", { d: "M2.75 7h13" }),
33
+ /* @__PURE__ */ jsx("rect", {
34
+ x: "10.25",
35
+ y: "10.25",
36
+ width: "7",
37
+ height: "6.5",
38
+ rx: "1.25",
39
+ fill: "#f5f5f5"
40
+ }),
41
+ /* @__PURE__ */ jsx("path", { d: "M10.25 13.25h7" })
42
+ ]
43
+ });
44
+ }
45
+ function DatasourceToolResultCardContent({ title, description, type, resourceCount }) {
46
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
47
+ /* @__PURE__ */ jsxs("header", {
48
+ className: "flex items-center gap-3",
49
+ children: [/* @__PURE__ */ jsx(DatasourceIcon, {}), /* @__PURE__ */ jsx("p", {
50
+ className: "min-w-0 truncate text-base leading-5",
51
+ children: type
52
+ })]
53
+ }),
54
+ /* @__PURE__ */ jsx("h3", {
55
+ className: "mt-3 line-clamp-2 text-sm font-normal leading-5",
56
+ children: title
57
+ }),
58
+ /* @__PURE__ */ jsx("p", {
59
+ className: "mt-2 line-clamp-2 text-xs leading-4",
60
+ children: description
61
+ }),
62
+ resourceCount === void 0 ? null : /* @__PURE__ */ jsxs("p", {
63
+ className: "mt-2 text-xs leading-4 text-neutral-600",
64
+ children: [
65
+ resourceCount,
66
+ " ",
67
+ resourceCount === 1 ? "Recurso" : "Recursos"
68
+ ]
69
+ })
70
+ ] });
71
+ }
72
+ function DatasourceToolResultCard(props) {
73
+ return /* @__PURE__ */ jsx("article", {
74
+ "aria-label": `${props.type}: ${props.title}`,
75
+ className: "w-[186px] rounded-lg bg-neutral-100 p-4 text-neutral-950",
76
+ children: /* @__PURE__ */ jsx(DatasourceToolResultCardContent, { ...props })
77
+ });
78
+ }
79
+
80
+ //#endregion
81
+ //#region src/components/resource-card.tsx
82
+ function ResourceCardContent({ icon, title, description }) {
83
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("header", {
84
+ className: "flex min-w-0 items-center gap-3",
85
+ children: [icon ? /* @__PURE__ */ jsx("img", {
86
+ src: icon,
87
+ alt: "",
88
+ width: "20",
89
+ height: "20",
90
+ className: "h-5 w-5 shrink-0 object-contain"
91
+ }) : /* @__PURE__ */ jsx(File, {
92
+ className: "h-5 w-5 shrink-0",
93
+ "aria-hidden": "true"
94
+ }), /* @__PURE__ */ jsx("p", {
95
+ className: "min-w-0 truncate text-base leading-5",
96
+ children: title
97
+ })]
98
+ }), /* @__PURE__ */ jsx("p", {
99
+ className: "mt-2 line-clamp-2 text-sm leading-5",
100
+ children: description
101
+ })] });
102
+ }
103
+ function ResourceCard(props) {
104
+ const className = "block w-full rounded-lg bg-neutral-100 p-4 text-left text-neutral-950";
105
+ if (!props.url) return /* @__PURE__ */ jsx("article", {
106
+ "aria-label": `${props.title}: ${props.description}`,
107
+ className,
108
+ children: /* @__PURE__ */ jsx(ResourceCardContent, { ...props })
109
+ });
110
+ return /* @__PURE__ */ jsx("a", {
111
+ href: props.url,
112
+ target: "_blank",
113
+ rel: "noreferrer noopener",
114
+ className: `${className} transition-colors hover:bg-neutral-200 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950`,
115
+ children: /* @__PURE__ */ jsx(ResourceCardContent, { ...props })
116
+ });
117
+ }
118
+
119
+ //#endregion
120
+ //#region src/components/icons/arrow.tsx
121
+ function ArrowUp(props) {
122
+ return /* @__PURE__ */ jsxs("svg", {
123
+ ...props,
124
+ xmlns: "http://www.w3.org/2000/svg",
125
+ width: "24",
126
+ height: "24",
127
+ viewBox: "0 0 24 24",
128
+ fill: "none",
129
+ stroke: "currentColor",
130
+ strokeWidth: "2",
131
+ strokeLinecap: "round",
132
+ strokeLinejoin: "round",
133
+ "aria-hidden": "true",
134
+ children: [/* @__PURE__ */ jsx("path", { d: "m5 12 7-7 7 7" }), /* @__PURE__ */ jsx("path", { d: "M12 19V5" })]
135
+ });
136
+ }
137
+
138
+ //#endregion
139
+ //#region src/components/icons/loader.tsx
140
+ function Loader(props) {
141
+ return /* @__PURE__ */ jsx("svg", {
142
+ ...props,
143
+ xmlns: "http://www.w3.org/2000/svg",
144
+ width: "24",
145
+ height: "24",
146
+ viewBox: "0 0 24 24",
147
+ fill: "none",
148
+ stroke: "currentColor",
149
+ strokeWidth: "2",
150
+ strokeLinecap: "round",
151
+ strokeLinejoin: "round",
152
+ "aria-hidden": "true",
153
+ children: /* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" })
154
+ });
155
+ }
156
+
157
+ //#endregion
158
+ //#region src/components/icons/microphone.tsx
159
+ function Microphone(props) {
160
+ return /* @__PURE__ */ jsxs("svg", {
161
+ ...props,
162
+ xmlns: "http://www.w3.org/2000/svg",
163
+ width: "24",
164
+ height: "24",
165
+ viewBox: "0 0 24 24",
166
+ fill: "none",
167
+ stroke: "currentColor",
168
+ strokeWidth: "2",
169
+ strokeLinecap: "round",
170
+ strokeLinejoin: "round",
171
+ "aria-hidden": "true",
172
+ children: [
173
+ /* @__PURE__ */ jsx("path", { d: "M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z" }),
174
+ /* @__PURE__ */ jsx("path", { d: "M19 10v2a7 7 0 0 1-14 0v-2" }),
175
+ /* @__PURE__ */ jsx("path", { d: "M12 19v3" })
176
+ ]
177
+ });
178
+ }
179
+
180
+ //#endregion
181
+ //#region src/components/icons/paperclip.tsx
182
+ function Paperclip(props) {
183
+ return /* @__PURE__ */ jsx("svg", {
184
+ ...props,
185
+ xmlns: "http://www.w3.org/2000/svg",
186
+ width: "24",
187
+ height: "24",
188
+ viewBox: "0 0 24 24",
189
+ fill: "none",
190
+ stroke: "currentColor",
191
+ strokeWidth: "2",
192
+ strokeLinecap: "round",
193
+ strokeLinejoin: "round",
194
+ "aria-hidden": "true",
195
+ children: /* @__PURE__ */ jsx("path", { d: "m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48" })
196
+ });
197
+ }
198
+
199
+ //#endregion
200
+ //#region src/components/icons/stop.tsx
201
+ function Stop(props) {
202
+ return /* @__PURE__ */ jsx("svg", {
203
+ ...props,
204
+ xmlns: "http://www.w3.org/2000/svg",
205
+ width: "24",
206
+ height: "24",
207
+ viewBox: "0 0 24 24",
208
+ fill: "none",
209
+ stroke: "currentColor",
210
+ strokeWidth: "2",
211
+ strokeLinecap: "round",
212
+ strokeLinejoin: "round",
213
+ "aria-hidden": "true",
214
+ children: /* @__PURE__ */ jsx("rect", {
215
+ x: "6",
216
+ y: "6",
217
+ width: "12",
218
+ height: "12",
219
+ rx: "1"
220
+ })
221
+ });
222
+ }
223
+
224
+ //#endregion
225
+ //#region src/components/icons/x.tsx
226
+ function X(props) {
227
+ return /* @__PURE__ */ jsxs("svg", {
228
+ ...props,
229
+ xmlns: "http://www.w3.org/2000/svg",
230
+ width: "24",
231
+ height: "24",
232
+ viewBox: "0 0 24 24",
233
+ fill: "none",
234
+ stroke: "currentColor",
235
+ strokeWidth: "2",
236
+ strokeLinecap: "round",
237
+ strokeLinejoin: "round",
238
+ "aria-hidden": "true",
239
+ children: [/* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }), /* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })]
240
+ });
241
+ }
242
+
243
+ //#endregion
244
+ //#region src/components/sheet/sheet.tsx
245
+ const SheetContext = createContext(null);
246
+ let bodyScrollLockCount = 0;
247
+ let bodyOverflowBeforeLock = "";
248
+ function lockBodyScroll() {
249
+ if (bodyScrollLockCount === 0) {
250
+ bodyOverflowBeforeLock = document.body.style.overflow;
251
+ document.body.style.overflow = "hidden";
252
+ }
253
+ bodyScrollLockCount += 1;
254
+ }
255
+ function unlockBodyScroll() {
256
+ bodyScrollLockCount = Math.max(0, bodyScrollLockCount - 1);
257
+ if (bodyScrollLockCount === 0) document.body.style.overflow = bodyOverflowBeforeLock;
258
+ }
259
+ function useSheetContext(componentName) {
260
+ const context = useContext(SheetContext);
261
+ if (!context) throw new Error(`${componentName} must be used within Sheet.`);
262
+ return context;
263
+ }
264
+ function assignRef(ref, value) {
265
+ if (typeof ref === "function") ref(value);
266
+ else if (ref) ref.current = value;
267
+ }
268
+ function Sheet({ children, open: controlledOpen, defaultOpen = false, onOpenChange }) {
269
+ const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
270
+ const [labelledBy, setLabelledBy] = useState();
271
+ const [describedBy, setDescribedBy] = useState();
272
+ const triggerRef = useRef(null);
273
+ const contentId = useId();
274
+ const titleId = useId();
275
+ const descriptionId = useId();
276
+ const open = controlledOpen ?? uncontrolledOpen;
277
+ const setOpen = useCallback((nextOpen) => {
278
+ if (controlledOpen === void 0) setUncontrolledOpen(nextOpen);
279
+ onOpenChange?.(nextOpen);
280
+ }, [controlledOpen, onOpenChange]);
281
+ const context = useMemo(() => ({
282
+ open,
283
+ setOpen,
284
+ triggerRef,
285
+ contentId,
286
+ titleId,
287
+ descriptionId,
288
+ labelledBy,
289
+ describedBy,
290
+ setLabelledBy,
291
+ setDescribedBy
292
+ }), [
293
+ open,
294
+ setOpen,
295
+ contentId,
296
+ titleId,
297
+ descriptionId,
298
+ labelledBy,
299
+ describedBy
300
+ ]);
301
+ return /* @__PURE__ */ jsx(SheetContext.Provider, {
302
+ value: context,
303
+ children
304
+ });
305
+ }
306
+ const SheetTrigger = forwardRef(function SheetTrigger$1({ onClick, type = "button",...props }, forwardedRef) {
307
+ const { open, setOpen, triggerRef, contentId } = useSheetContext("SheetTrigger");
308
+ const setTriggerRef = useCallback((element) => {
309
+ triggerRef.current = element;
310
+ assignRef(forwardedRef, element);
311
+ }, [forwardedRef, triggerRef]);
312
+ return /* @__PURE__ */ jsx("button", {
313
+ ...props,
314
+ ref: setTriggerRef,
315
+ type,
316
+ "data-slot": "sheet-trigger",
317
+ "aria-haspopup": "dialog",
318
+ "aria-expanded": open,
319
+ "aria-controls": contentId,
320
+ onClick: (event) => {
321
+ onClick?.(event);
322
+ if (!event.defaultPrevented) setOpen(true);
323
+ }
324
+ });
325
+ });
326
+ const SheetClose = forwardRef(function SheetClose$1({ onClick, type = "button",...props }, forwardedRef) {
327
+ const { setOpen } = useSheetContext("SheetClose");
328
+ return /* @__PURE__ */ jsx("button", {
329
+ ...props,
330
+ ref: forwardedRef,
331
+ type,
332
+ "data-slot": "sheet-close",
333
+ onClick: (event) => {
334
+ onClick?.(event);
335
+ if (!event.defaultPrevented) setOpen(false);
336
+ }
337
+ });
338
+ });
339
+ function getSideClasses(side) {
340
+ if (side === "left") return "inset-y-0 left-0 h-full w-full max-w-lg border-r";
341
+ if (side === "top") return "inset-x-0 top-0 max-h-[85vh] w-full border-b";
342
+ if (side === "bottom") return "inset-x-0 bottom-0 max-h-[85vh] w-full border-t";
343
+ return "inset-y-0 right-0 h-full w-full max-w-lg border-l";
344
+ }
345
+ const SheetContent = forwardRef(function SheetContent$1({ children, className, side = "right", showCloseButton = true, closeLabel = "Close", onCancel, onClick, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy,...props }, forwardedRef) {
346
+ const { open, setOpen, triggerRef, contentId, labelledBy, describedBy } = useSheetContext("SheetContent");
347
+ const [present, setPresent] = useState(open);
348
+ const dialogRef = useRef(null);
349
+ const setDialogRef = useCallback((element) => {
350
+ dialogRef.current = element;
351
+ assignRef(forwardedRef, element);
352
+ }, [forwardedRef]);
353
+ useEffect(() => {
354
+ if (open) setPresent(true);
355
+ }, [open]);
356
+ useEffect(() => {
357
+ if (!present) return;
358
+ const dialog = dialogRef.current;
359
+ if (!dialog) return;
360
+ if (!dialog.open) if (typeof dialog.showModal === "function") dialog.showModal();
361
+ else dialog.setAttribute("open", "");
362
+ lockBodyScroll();
363
+ (dialog.querySelector("[data-sheet-initial-focus], [autofocus]") ?? dialog.querySelector("[data-slot=\"sheet-title\"]") ?? dialog.querySelector("button, [href], [tabindex=\"0\"]"))?.focus({ preventScroll: true });
364
+ return () => {
365
+ unlockBodyScroll();
366
+ if (dialog.open) if (typeof dialog.close === "function") dialog.close();
367
+ else dialog.removeAttribute("open");
368
+ triggerRef.current?.focus({ preventScroll: true });
369
+ };
370
+ }, [present, triggerRef]);
371
+ useEffect(() => {
372
+ if (open || !present) return;
373
+ const fallbackTimer = window.setTimeout(() => setPresent(false), 250);
374
+ return () => window.clearTimeout(fallbackTimer);
375
+ }, [open, present]);
376
+ if (!present) return null;
377
+ const state = open ? "open" : "closed";
378
+ return /* @__PURE__ */ jsx("dialog", {
379
+ ...props,
380
+ ref: setDialogRef,
381
+ id: contentId,
382
+ "data-slot": "sheet-overlay",
383
+ "data-state": state,
384
+ "aria-label": ariaLabel,
385
+ "aria-labelledby": ariaLabelledBy ?? labelledBy,
386
+ "aria-describedby": ariaDescribedBy ?? describedBy,
387
+ className: "plai-sheet-overlay fixed inset-0 m-0 h-full max-h-none w-full max-w-none border-0 bg-black/80 p-0",
388
+ onCancel: (event) => {
389
+ onCancel?.(event);
390
+ if (!event.defaultPrevented) {
391
+ event.preventDefault();
392
+ setOpen(false);
393
+ }
394
+ },
395
+ onClick: (event) => {
396
+ onClick?.(event);
397
+ if (!event.defaultPrevented && event.target === event.currentTarget) setOpen(false);
398
+ },
399
+ children: /* @__PURE__ */ jsxs("div", {
400
+ "data-slot": "sheet-content",
401
+ "data-state": state,
402
+ "data-side": side,
403
+ className: joinClasses("plai-sheet-content fixed overflow-y-auto border-neutral-200 bg-white px-6 py-5 text-neutral-950 shadow-2xl outline-none", getSideClasses(side), className),
404
+ onAnimationEnd: (event) => {
405
+ if (event.currentTarget === event.target && !open) setPresent(false);
406
+ },
407
+ children: [showCloseButton ? /* @__PURE__ */ jsx(SheetClose, {
408
+ "aria-label": closeLabel,
409
+ className: "absolute right-4 top-2 rounded-sm p-1 text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-950 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950",
410
+ children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" })
411
+ }) : null, children]
412
+ })
413
+ });
414
+ });
415
+ const SheetHeader = forwardRef(function SheetHeader$1({ className,...props }, forwardedRef) {
416
+ return /* @__PURE__ */ jsx("div", {
417
+ ...props,
418
+ ref: forwardedRef,
419
+ "data-slot": "sheet-header",
420
+ className: joinClasses("flex flex-col gap-4", className)
421
+ });
422
+ });
423
+ const SheetFooter = forwardRef(function SheetFooter$1({ className,...props }, forwardedRef) {
424
+ return /* @__PURE__ */ jsx("div", {
425
+ ...props,
426
+ ref: forwardedRef,
427
+ "data-slot": "sheet-footer",
428
+ className: joinClasses("mt-auto flex flex-col gap-2", className)
429
+ });
430
+ });
431
+ const SheetTitle = forwardRef(function SheetTitle$1({ className, id, tabIndex = -1,...props }, forwardedRef) {
432
+ const { titleId, setLabelledBy } = useSheetContext("SheetTitle");
433
+ const resolvedId = id ?? titleId;
434
+ useEffect(() => {
435
+ setLabelledBy(resolvedId);
436
+ return () => {
437
+ setLabelledBy((current) => current === resolvedId ? void 0 : current);
438
+ };
439
+ }, [resolvedId, setLabelledBy]);
440
+ return /* @__PURE__ */ jsx("h2", {
441
+ ...props,
442
+ ref: forwardedRef,
443
+ id: resolvedId,
444
+ tabIndex,
445
+ "data-slot": "sheet-title",
446
+ className: joinClasses("text-lg font-semibold leading-6 outline-none", className)
447
+ });
448
+ });
449
+ const SheetDescription = forwardRef(function SheetDescription$1({ className, id,...props }, forwardedRef) {
450
+ const { descriptionId, setDescribedBy } = useSheetContext("SheetDescription");
451
+ const resolvedId = id ?? descriptionId;
452
+ useEffect(() => {
453
+ setDescribedBy(resolvedId);
454
+ return () => {
455
+ setDescribedBy((current) => current === resolvedId ? void 0 : current);
456
+ };
457
+ }, [resolvedId, setDescribedBy]);
458
+ return /* @__PURE__ */ jsx("p", {
459
+ ...props,
460
+ ref: forwardedRef,
461
+ id: resolvedId,
462
+ "data-slot": "sheet-description",
463
+ className: joinClasses("text-sm text-neutral-600", className)
464
+ });
465
+ });
466
+
467
+ //#endregion
468
+ //#region src/components/datasource-folder-card.tsx
469
+ function DatasourceFolderCard({ title, description, type, resources }) {
470
+ return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsx(SheetTrigger, {
471
+ "aria-label": `${type}: ${title}`,
472
+ className: "min-h-[183px] w-[186px] rounded-lg bg-neutral-100 p-4 text-left font-normal text-neutral-950 transition-colors hover:bg-neutral-200 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950",
473
+ children: /* @__PURE__ */ jsx(DatasourceToolResultCardContent, {
474
+ title,
475
+ description,
476
+ type,
477
+ resourceCount: resources.length
478
+ })
479
+ }), /* @__PURE__ */ jsxs(SheetContent, {
480
+ closeLabel: "Cerrar",
481
+ children: [/* @__PURE__ */ jsxs(SheetHeader, {
482
+ className: "pr-10",
483
+ children: [/* @__PURE__ */ jsxs("div", {
484
+ className: "flex items-start gap-3",
485
+ children: [/* @__PURE__ */ jsx("span", {
486
+ className: "mt-0.5 shrink-0",
487
+ children: /* @__PURE__ */ jsx(DatasourceIcon, {})
488
+ }), /* @__PURE__ */ jsx(SheetTitle, { children: title })]
489
+ }), description ? /* @__PURE__ */ jsx(SheetDescription, {
490
+ className: "line-clamp-2 text-xs leading-4",
491
+ children: description
492
+ }) : null]
493
+ }), /* @__PURE__ */ jsxs("section", {
494
+ className: "mt-5",
495
+ "aria-label": "Recursos",
496
+ children: [/* @__PURE__ */ jsx("h3", {
497
+ className: "text-xs font-medium leading-4",
498
+ children: "Ver"
499
+ }), /* @__PURE__ */ jsx("div", {
500
+ className: "mt-7 space-y-3",
501
+ children: resources.map((resource, index) => /* @__PURE__ */ jsx(ResourceCard, { ...resource }, `${resource.url ?? resource.title}-${index}`))
502
+ })]
503
+ })]
504
+ })] });
505
+ }
506
+
507
+ //#endregion
508
+ //#region src/components/datasource-tool-resources.tsx
509
+ function isObject(value) {
510
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
511
+ }
512
+ function readString(value, key) {
513
+ const candidate = value?.[key];
514
+ return typeof candidate === "string" && candidate.trim() ? candidate : null;
515
+ }
516
+ function getResourceIcon(resource) {
517
+ return readString(resource.extra_info, "icon") ?? readString(resource.metadata, "icon") ?? void 0;
518
+ }
519
+ function toResourceCardProps(resource) {
520
+ return {
521
+ icon: getResourceIcon(resource),
522
+ title: resource.type,
523
+ description: resource.name,
524
+ url: resource.external_url ?? resource.url
525
+ };
526
+ }
527
+ function isDatasourceResource(value) {
528
+ if (!isObject(value)) return false;
529
+ const folder = value.folder;
530
+ const datasource = value.datasource;
531
+ return typeof value.id === "string" && typeof value.name === "string" && typeof value.type === "string" && (value.url === null || typeof value.url === "string") && (value.external_url === null || typeof value.external_url === "string") && isObject(value.metadata) && isObject(value.extra_info) && (folder === null || isObject(folder) && typeof folder.id === "string" && typeof folder.name === "string" && isObject(folder.extra_info)) && (datasource === null || isObject(datasource) && typeof datasource.type === "string" && (datasource.description === null || typeof datasource.description === "string") && (datasource.summary === null || typeof datasource.summary === "string"));
532
+ }
533
+ function DatasourceToolResources({ resources, className }) {
534
+ const folderGroups = /* @__PURE__ */ new Map();
535
+ const ungroupedResources = [];
536
+ for (const resource of resources) {
537
+ if (!resource.folder) {
538
+ ungroupedResources.push(resource);
539
+ continue;
540
+ }
541
+ const existingGroup = folderGroups.get(resource.folder.id);
542
+ if (existingGroup) existingGroup.resources.push(resource);
543
+ else folderGroups.set(resource.folder.id, {
544
+ folder: resource.folder,
545
+ resources: [resource]
546
+ });
547
+ }
548
+ return /* @__PURE__ */ jsxs("section", {
549
+ "aria-label": "Recursos de la fuente de datos",
550
+ className: joinClasses("flex flex-wrap gap-3", className),
551
+ children: [Array.from(folderGroups.values()).map(({ folder, resources: group }) => {
552
+ const datasource = group[0]?.datasource;
553
+ const type = readString(folder.extra_info, "type") ?? datasource?.type ?? "FOLDER";
554
+ const description = readString(folder.extra_info, "description") ?? readString(folder.extra_info, "summary") ?? datasource?.description ?? datasource?.summary ?? "";
555
+ return /* @__PURE__ */ jsx(DatasourceFolderCard, {
556
+ title: folder.name,
557
+ description,
558
+ type,
559
+ resources: group.map(toResourceCardProps)
560
+ }, folder.id);
561
+ }), ungroupedResources.map((resource) => /* @__PURE__ */ jsx(ResourceCard, { ...toResourceCardProps(resource) }, resource.id))]
562
+ });
563
+ }
564
+
565
+ //#endregion
566
+ //#region src/components/internal/format-tool-error-details.ts
567
+ function formatToolErrorDetails(value) {
568
+ if (typeof value === "string") return value;
569
+ if (!value || typeof value !== "object" || Array.isArray(value)) return value == null ? null : String(value);
570
+ const details = value;
571
+ for (const key of [
572
+ "error_message",
573
+ "message",
574
+ "detail"
575
+ ]) {
576
+ const candidate = details[key];
577
+ if (typeof candidate === "string" && candidate.trim()) return candidate;
578
+ }
579
+ try {
580
+ return JSON.stringify(value, null, 2);
581
+ } catch {
582
+ return "Unknown tool error";
583
+ }
584
+ }
585
+
9
586
  //#endregion
10
587
  //#region src/components/tool-result-email-send-card.tsx
11
- function formatStatus(status) {
588
+ function formatStatus$1(status) {
12
589
  if (status === "pending") return "pending";
13
590
  if (status === "error") return "error";
14
591
  return "completed";
@@ -17,7 +594,7 @@ function asObject(value) {
17
594
  if (!value || typeof value !== "object" || Array.isArray(value)) return null;
18
595
  return value;
19
596
  }
20
- function toStringOrNull(value) {
597
+ function toStringOrNull$2(value) {
21
598
  return typeof value === "string" && value.trim().length > 0 ? value : null;
22
599
  }
23
600
  function toNumberOrNull(value) {
@@ -32,8 +609,8 @@ function parseEmailSendInput(part) {
32
609
  };
33
610
  return {
34
611
  to: Array.isArray(input.to) ? input.to.filter((item) => typeof item === "string") : [],
35
- subject: toStringOrNull(input.subject),
36
- text: toStringOrNull(input.text)
612
+ subject: toStringOrNull$2(input.subject),
613
+ text: toStringOrNull$2(input.text)
37
614
  };
38
615
  }
39
616
  function parseEmailSendResult(part) {
@@ -60,12 +637,12 @@ function parseEmailSendResult(part) {
60
637
  };
61
638
  const receipt = asObject(resultObject.receipt);
62
639
  return {
63
- status: toStringOrNull(resultObject.status),
640
+ status: toStringOrNull$2(resultObject.status),
64
641
  recipientsCount: toNumberOrNull(resultObject.recipients_count),
65
- subject: toStringOrNull(resultObject.subject),
66
- receiptProvider: receipt ? toStringOrNull(receipt.provider) : null,
67
- receiptMessageId: receipt ? toStringOrNull(receipt.message_id) : null,
68
- receiptRawStatus: receipt ? toStringOrNull(receipt.raw_status) : null,
642
+ subject: toStringOrNull$2(resultObject.subject),
643
+ receiptProvider: receipt ? toStringOrNull$2(receipt.provider) : null,
644
+ receiptMessageId: receipt ? toStringOrNull$2(receipt.message_id) : null,
645
+ receiptRawStatus: receipt ? toStringOrNull$2(receipt.raw_status) : null,
69
646
  raw
70
647
  };
71
648
  }
@@ -73,6 +650,7 @@ function ToolResultEmailSendCard({ part, className }) {
73
650
  const [isExpanded, setIsExpanded] = useState(false);
74
651
  const emailInput = parseEmailSendInput(part);
75
652
  const emailResult = parseEmailSendResult(part);
653
+ const errorDetails = formatToolErrorDetails(part.errorDetails);
76
654
  const statusClass = part.state === "error" ? "border-rose-200 bg-rose-50 text-rose-800" : part.state === "pending" ? "border-amber-200 bg-amber-50 text-amber-800" : "border-emerald-200 bg-emerald-50 text-emerald-800";
77
655
  return /* @__PURE__ */ jsxs("section", {
78
656
  className: joinClasses("space-y-4 rounded-lg border border-slate-200 bg-slate-50 p-3", className),
@@ -88,7 +666,7 @@ function ToolResultEmailSendCard({ part, className }) {
88
666
  className: "flex items-center gap-2",
89
667
  children: [/* @__PURE__ */ jsx("span", {
90
668
  className: joinClasses("rounded-full border px-2 py-0.5 text-xs font-medium", statusClass),
91
- children: formatStatus(part.state)
669
+ children: formatStatus$1(part.state)
92
670
  }), /* @__PURE__ */ jsx("button", {
93
671
  type: "button",
94
672
  "aria-expanded": isExpanded,
@@ -210,19 +788,1061 @@ function ToolResultEmailSendCard({ part, className }) {
210
788
  ]
211
789
  }) : null]
212
790
  }),
213
- part.errorDetails ? /* @__PURE__ */ jsxs("p", {
214
- className: "rounded border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-700",
791
+ errorDetails ? /* @__PURE__ */ jsxs("p", {
792
+ className: "rounded border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-700",
793
+ children: [
794
+ /* @__PURE__ */ jsx("span", {
795
+ className: "font-semibold",
796
+ children: "Error details:"
797
+ }),
798
+ " ",
799
+ errorDetails
800
+ ]
801
+ }) : null
802
+ ]
803
+ });
804
+ }
805
+
806
+ //#endregion
807
+ //#region src/components/tool-result-agent-invocation-card.tsx
808
+ function formatAgentName(part) {
809
+ if (part.metadata?.agent_name) return part.metadata.agent_name;
810
+ return part.name.replace(/^invoke_/, "").replace(/[_-]+/g, " ").trim() || "Agent";
811
+ }
812
+ function formatOutput(value) {
813
+ if (typeof value === "string") return value;
814
+ if (value == null) return null;
815
+ try {
816
+ return JSON.stringify(value, null, 2);
817
+ } catch {
818
+ return null;
819
+ }
820
+ }
821
+ function getPrompt(value) {
822
+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;
823
+ const prompt = value.input;
824
+ return typeof prompt === "string" && prompt.trim() ? prompt : null;
825
+ }
826
+ function ToolResultAgentInvocationCard({ part, className, onOpenThread }) {
827
+ const metadata = part.metadata;
828
+ const agentName = formatAgentName(part);
829
+ const output$1 = formatOutput(part.result);
830
+ const prompt = getPrompt(part.input);
831
+ const error = formatToolErrorDetails(part.errorDetails);
832
+ const threadId = metadata?.thread_id;
833
+ const failed = part.state === "error";
834
+ const pending = part.state === "pending";
835
+ return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsx(SheetTrigger, {
836
+ "aria-label": `Agent: ${agentName}`,
837
+ className: joinClasses("w-full rounded-lg border border-neutral-200 bg-white text-left font-normal text-neutral-950 transition-colors hover:bg-neutral-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950", className),
838
+ children: /* @__PURE__ */ jsxs("span", {
839
+ className: "flex items-center gap-2 px-3 py-2 text-sm",
840
+ children: [
841
+ /* @__PURE__ */ jsx(Bot, {
842
+ className: "h-4 w-4 shrink-0 text-neutral-500",
843
+ "aria-hidden": "true"
844
+ }),
845
+ /* @__PURE__ */ jsx("span", {
846
+ className: "shrink-0 font-medium",
847
+ children: "Agent"
848
+ }),
849
+ /* @__PURE__ */ jsx("span", {
850
+ className: "min-w-0 truncate text-neutral-600",
851
+ children: agentName
852
+ }),
853
+ /* @__PURE__ */ jsx("span", {
854
+ className: "ml-auto shrink-0",
855
+ children: pending ? /* @__PURE__ */ jsx(LoaderCircle, {
856
+ className: "h-4 w-4 animate-spin text-amber-600",
857
+ "aria-label": "Pending"
858
+ }) : failed ? /* @__PURE__ */ jsx(XCircle, {
859
+ className: "h-4 w-4 text-rose-600",
860
+ "aria-hidden": "true"
861
+ }) : /* @__PURE__ */ jsx(CheckCircle2, {
862
+ className: "h-4 w-4 text-emerald-600",
863
+ "aria-hidden": "true"
864
+ })
865
+ })
866
+ ]
867
+ })
868
+ }), /* @__PURE__ */ jsxs(SheetContent, {
869
+ closeLabel: "Close",
870
+ children: [/* @__PURE__ */ jsx(SheetHeader, {
871
+ className: "pr-10",
872
+ children: /* @__PURE__ */ jsx(SheetTitle, { children: agentName })
873
+ }), /* @__PURE__ */ jsxs("section", {
874
+ className: "mt-6 space-y-4",
875
+ "aria-label": "Agent invocation result",
876
+ children: [
877
+ /* @__PURE__ */ jsxs("dl", {
878
+ className: "grid gap-2 text-sm",
879
+ children: [
880
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", {
881
+ className: "text-xs text-neutral-500",
882
+ children: "Status"
883
+ }), /* @__PURE__ */ jsx("dd", { children: part.state })] }),
884
+ metadata?.agent_id ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", {
885
+ className: "text-xs text-neutral-500",
886
+ children: "Agent ID"
887
+ }), /* @__PURE__ */ jsx("dd", {
888
+ className: "break-all",
889
+ children: metadata.agent_id
890
+ })] }) : null,
891
+ metadata?.tracked_execution_id ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", {
892
+ className: "text-xs text-neutral-500",
893
+ children: "Execution ID"
894
+ }), /* @__PURE__ */ jsx("dd", {
895
+ className: "break-all",
896
+ children: metadata.tracked_execution_id
897
+ })] }) : null,
898
+ threadId ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", {
899
+ className: "text-xs text-neutral-500",
900
+ children: "Thread ID"
901
+ }), /* @__PURE__ */ jsx("dd", {
902
+ className: "break-all",
903
+ children: threadId
904
+ })] }) : null
905
+ ]
906
+ }),
907
+ prompt ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
908
+ className: "mb-2 text-sm font-medium",
909
+ children: "Prompt"
910
+ }), /* @__PURE__ */ jsx("p", {
911
+ className: "whitespace-pre-wrap rounded-md border border-neutral-200 bg-neutral-50 p-3 text-sm leading-6",
912
+ children: prompt
913
+ })] }) : null,
914
+ output$1 ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
915
+ className: "mb-2 text-sm font-medium",
916
+ children: "Result"
917
+ }), /* @__PURE__ */ jsx("pre", {
918
+ className: "overflow-x-auto whitespace-pre-wrap rounded-md border border-neutral-200 bg-neutral-50 p-3 text-xs leading-5",
919
+ children: output$1
920
+ })] }) : null,
921
+ threadId && onOpenThread ? /* @__PURE__ */ jsxs("button", {
922
+ type: "button",
923
+ className: "inline-flex items-center gap-2 rounded-md border border-neutral-300 px-3 py-2 text-sm font-medium text-neutral-900 transition-colors hover:bg-neutral-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950",
924
+ onClick: () => onOpenThread(threadId),
925
+ children: [/* @__PURE__ */ jsx(MessageSquare, {
926
+ className: "h-4 w-4",
927
+ "aria-hidden": "true"
928
+ }), "Open conversation"]
929
+ }) : null,
930
+ error ? /* @__PURE__ */ jsxs("p", {
931
+ className: "rounded border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-700",
932
+ children: [
933
+ /* @__PURE__ */ jsx("span", {
934
+ className: "font-semibold",
935
+ children: "Error details:"
936
+ }),
937
+ " ",
938
+ error
939
+ ]
940
+ }) : null
941
+ ]
942
+ })]
943
+ })] });
944
+ }
945
+
946
+ //#endregion
947
+ //#region src/components/tool-result-browser-card.tsx
948
+ const SCRAPER_LABELS = {
949
+ beautifulsoup: "BeautifulSoup",
950
+ firecrawl: "Firecrawl",
951
+ scraperapi: "ScraperAPI"
952
+ };
953
+ function getUrl(input) {
954
+ if (!input || typeof input !== "object" || Array.isArray(input)) return null;
955
+ const url = input.url;
956
+ return typeof url === "string" && url.trim() ? url : null;
957
+ }
958
+ function toOutput(value) {
959
+ if (typeof value === "string") return value;
960
+ if (value == null) return null;
961
+ try {
962
+ return JSON.stringify(value, null, 2);
963
+ } catch {
964
+ return null;
965
+ }
966
+ }
967
+ function getPreview(output$1) {
968
+ if (!output$1) return null;
969
+ return output$1.length > 200 ? `${output$1.slice(0, 200)}…` : output$1;
970
+ }
971
+ function ToolResultBrowserCard({ part, className }) {
972
+ const [expanded, setExpanded] = useState(false);
973
+ const metadata = part.metadata;
974
+ const preview = getPreview(toOutput(part.result));
975
+ const url = getUrl(part.input);
976
+ const error = formatToolErrorDetails(part.errorDetails);
977
+ const scraperLabel = metadata?.scraper_type ? SCRAPER_LABELS[metadata.scraper_type] : null;
978
+ const credits = metadata?.scraper_api_tokens ?? metadata?.firecrawl_credits;
979
+ const subtitle = [scraperLabel, typeof credits === "number" ? `${credits} credit${credits === 1 ? "" : "s"}` : null].filter(Boolean).join(" · ");
980
+ const failed = part.state === "error";
981
+ const pending = part.state === "pending";
982
+ const canExpand = Boolean(preview || error || url);
983
+ return /* @__PURE__ */ jsxs("section", {
984
+ className: joinClasses("overflow-hidden rounded-lg border border-neutral-200 bg-white", className),
985
+ "aria-label": "Browser result",
986
+ children: [/* @__PURE__ */ jsxs("div", {
987
+ className: "flex items-center gap-2 px-3 py-2 text-sm",
988
+ children: [
989
+ /* @__PURE__ */ jsx(Globe, {
990
+ className: "h-4 w-4 shrink-0 text-neutral-500",
991
+ "aria-hidden": "true"
992
+ }),
993
+ /* @__PURE__ */ jsx("span", {
994
+ className: "font-medium text-neutral-800",
995
+ children: "Browser"
996
+ }),
997
+ subtitle ? /* @__PURE__ */ jsx("span", {
998
+ className: "min-w-0 truncate text-xs text-neutral-500",
999
+ children: subtitle
1000
+ }) : null,
1001
+ /* @__PURE__ */ jsxs("span", {
1002
+ className: "ml-auto flex shrink-0 items-center gap-2",
1003
+ children: [pending ? /* @__PURE__ */ jsx(LoaderCircle, {
1004
+ className: "h-4 w-4 animate-spin text-amber-600",
1005
+ "aria-label": "Pending"
1006
+ }) : failed ? /* @__PURE__ */ jsx(XCircle, {
1007
+ className: "h-4 w-4 text-rose-600",
1008
+ "aria-hidden": "true"
1009
+ }) : /* @__PURE__ */ jsx(CheckCircle2, {
1010
+ className: "h-4 w-4 text-emerald-600",
1011
+ "aria-hidden": "true"
1012
+ }), canExpand ? /* @__PURE__ */ jsx("button", {
1013
+ type: "button",
1014
+ "aria-label": expanded ? "Collapse browser result" : "Expand browser result",
1015
+ "aria-expanded": expanded,
1016
+ className: "flex h-5 w-5 items-center justify-center rounded text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950",
1017
+ onClick: () => setExpanded((value) => !value),
1018
+ children: expanded ? /* @__PURE__ */ jsx(Minus, {
1019
+ className: "h-3 w-3",
1020
+ "aria-hidden": "true"
1021
+ }) : /* @__PURE__ */ jsx(Plus, {
1022
+ className: "h-3 w-3",
1023
+ "aria-hidden": "true"
1024
+ })
1025
+ }) : null]
1026
+ })
1027
+ ]
1028
+ }), expanded ? /* @__PURE__ */ jsxs("div", {
1029
+ className: "space-y-3 border-t border-neutral-200 bg-neutral-50 p-3",
1030
+ children: [
1031
+ url ? /* @__PURE__ */ jsx("a", {
1032
+ href: url,
1033
+ target: "_blank",
1034
+ rel: "noreferrer noopener",
1035
+ className: "block truncate text-xs text-blue-700 underline underline-offset-2 hover:text-blue-900",
1036
+ children: url
1037
+ }) : null,
1038
+ preview ? /* @__PURE__ */ jsx("p", {
1039
+ className: "whitespace-pre-wrap text-xs leading-5 text-neutral-600",
1040
+ children: preview
1041
+ }) : null,
1042
+ error ? /* @__PURE__ */ jsxs("p", {
1043
+ className: "text-xs text-rose-700",
1044
+ children: [
1045
+ /* @__PURE__ */ jsx("span", {
1046
+ className: "font-semibold",
1047
+ children: "Error details:"
1048
+ }),
1049
+ " ",
1050
+ error
1051
+ ]
1052
+ }) : null
1053
+ ]
1054
+ }) : null]
1055
+ });
1056
+ }
1057
+
1058
+ //#endregion
1059
+ //#region src/components/tool-result-external-datasource-card.tsx
1060
+ function isRecord(value) {
1061
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1062
+ }
1063
+ function toStringOrNull$1(value) {
1064
+ return typeof value === "string" && value.trim().length > 0 ? value : null;
1065
+ }
1066
+ function formatCell(value) {
1067
+ if (value === null || value === void 0) return "-";
1068
+ if (typeof value === "string") return value;
1069
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
1070
+ try {
1071
+ return JSON.stringify(value);
1072
+ } catch {
1073
+ return String(value);
1074
+ }
1075
+ }
1076
+ function parseJson(value) {
1077
+ try {
1078
+ return JSON.parse(value);
1079
+ } catch {
1080
+ return null;
1081
+ }
1082
+ }
1083
+ function normalizeTable(value) {
1084
+ const raw = typeof value === "string" ? parseJson(value) : value;
1085
+ if (!raw) return {
1086
+ columns: [],
1087
+ rows: []
1088
+ };
1089
+ if (Array.isArray(raw)) {
1090
+ const records = raw.filter(isRecord);
1091
+ const columns$1 = Array.from(new Set(records.flatMap((record) => Object.keys(record))));
1092
+ return {
1093
+ columns: columns$1,
1094
+ rows: records.map((record) => columns$1.map((column) => record[column]))
1095
+ };
1096
+ }
1097
+ if (!isRecord(raw)) return {
1098
+ columns: [],
1099
+ rows: []
1100
+ };
1101
+ if (Array.isArray(raw.columns) && Array.isArray(raw.rows)) return {
1102
+ columns: raw.columns.filter((column) => typeof column === "string"),
1103
+ rows: raw.rows.map((row) => Array.isArray(row) ? row : [row])
1104
+ };
1105
+ const columns = Object.keys(raw);
1106
+ if (columns.length === 0) return {
1107
+ columns: [],
1108
+ rows: []
1109
+ };
1110
+ const columnValues = columns.map((column) => raw[column]);
1111
+ if (!columnValues.some(isRecord)) return {
1112
+ columns: ["Property", "Value"],
1113
+ rows: Object.entries(raw)
1114
+ };
1115
+ return {
1116
+ columns,
1117
+ rows: Array.from(new Set(columnValues.flatMap((column) => isRecord(column) ? Object.keys(column) : []))).map((rowKey) => columnValues.map((column) => isRecord(column) ? column[rowKey] : null))
1118
+ };
1119
+ }
1120
+ function getTableValue(part) {
1121
+ if (part.metadata?.json_table !== void 0) return part.metadata.json_table;
1122
+ return typeof part.result === "string" ? part.result : null;
1123
+ }
1124
+ function formatStatus(state) {
1125
+ if (state === "pending") return "pending";
1126
+ if (state === "error") return "error";
1127
+ return "completed";
1128
+ }
1129
+ function ToolResultExternalDatasourceCard({ part, className }) {
1130
+ const sqlQuery = toStringOrNull$1(part.metadata?.sql_query);
1131
+ const table = normalizeTable(getTableValue(part));
1132
+ const errorDetails = formatToolErrorDetails(part.errorDetails);
1133
+ const statusClass = part.state === "error" ? "text-rose-600" : part.state === "pending" ? "text-amber-600" : "text-emerald-600";
1134
+ return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsx(SheetTrigger, {
1135
+ "aria-label": `External datasource: ${formatStatus(part.state)}`,
1136
+ className: joinClasses("w-full overflow-hidden rounded-lg border border-neutral-200 bg-white text-left font-normal text-neutral-950 transition-colors hover:bg-neutral-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950", className),
1137
+ children: /* @__PURE__ */ jsxs("span", {
1138
+ className: "flex items-center gap-2 px-3 py-2 text-sm",
1139
+ children: [
1140
+ /* @__PURE__ */ jsx(Database, {
1141
+ className: "h-4 w-4 shrink-0 text-neutral-500",
1142
+ "aria-hidden": "true"
1143
+ }),
1144
+ /* @__PURE__ */ jsx("span", {
1145
+ className: "truncate font-medium",
1146
+ children: "External datasource"
1147
+ }),
1148
+ /* @__PURE__ */ jsx("span", {
1149
+ className: joinClasses("ml-auto shrink-0", statusClass),
1150
+ children: part.state === "error" ? /* @__PURE__ */ jsx(XCircle, {
1151
+ className: "h-4 w-4",
1152
+ "aria-hidden": "true"
1153
+ }) : part.state === "completed" ? /* @__PURE__ */ jsx(CheckCircle2, {
1154
+ className: "h-4 w-4",
1155
+ "aria-hidden": "true"
1156
+ }) : /* @__PURE__ */ jsx("span", {
1157
+ className: "text-xs",
1158
+ children: "pending"
1159
+ })
1160
+ })
1161
+ ]
1162
+ })
1163
+ }), /* @__PURE__ */ jsxs(SheetContent, {
1164
+ closeLabel: "Close",
1165
+ children: [/* @__PURE__ */ jsx(SheetHeader, {
1166
+ className: "pr-10",
1167
+ children: /* @__PURE__ */ jsx(SheetTitle, { children: "External datasource" })
1168
+ }), /* @__PURE__ */ jsxs("section", {
1169
+ className: "mt-6 space-y-8",
1170
+ "aria-label": "External datasource result",
1171
+ children: [
1172
+ sqlQuery ? /* @__PURE__ */ jsxs("div", {
1173
+ className: "space-y-2",
1174
+ children: [/* @__PURE__ */ jsxs("div", {
1175
+ className: "flex items-center gap-2",
1176
+ children: [/* @__PURE__ */ jsx(Database, {
1177
+ className: "h-5 w-5 text-blue-500",
1178
+ "aria-hidden": "true"
1179
+ }), /* @__PURE__ */ jsx("h3", {
1180
+ className: "text-sm font-medium",
1181
+ children: "SQL query"
1182
+ })]
1183
+ }), /* @__PURE__ */ jsx("pre", {
1184
+ className: "overflow-x-auto rounded-md border border-neutral-200 bg-neutral-50 p-3 text-xs leading-5 text-neutral-800",
1185
+ children: sqlQuery
1186
+ })]
1187
+ }) : null,
1188
+ table.columns.length > 0 && table.rows.length > 0 ? /* @__PURE__ */ jsxs("div", {
1189
+ className: "space-y-2",
1190
+ children: [/* @__PURE__ */ jsx("h3", {
1191
+ className: "text-sm font-medium",
1192
+ children: "Query results"
1193
+ }), /* @__PURE__ */ jsx("div", {
1194
+ className: "overflow-x-auto rounded-md border border-neutral-200",
1195
+ children: /* @__PURE__ */ jsxs("table", {
1196
+ className: "w-full border-collapse text-left text-xs",
1197
+ children: [/* @__PURE__ */ jsx("thead", {
1198
+ className: "bg-neutral-50 text-neutral-600",
1199
+ children: /* @__PURE__ */ jsx("tr", { children: table.columns.map((column) => /* @__PURE__ */ jsx("th", {
1200
+ className: "max-w-56 truncate border-b border-neutral-200 px-3 py-2 font-medium",
1201
+ title: column,
1202
+ children: column
1203
+ }, column)) })
1204
+ }), /* @__PURE__ */ jsx("tbody", { children: table.rows.map((row) => /* @__PURE__ */ jsx("tr", {
1205
+ className: "border-b border-neutral-100 last:border-0",
1206
+ children: table.columns.map((column, columnIndex) => {
1207
+ const value = formatCell(row[columnIndex]);
1208
+ return /* @__PURE__ */ jsx("td", {
1209
+ className: "max-w-56 truncate px-3 py-2 text-neutral-700",
1210
+ title: value,
1211
+ children: value
1212
+ }, column);
1213
+ })
1214
+ }, row.map(formatCell).join("\0"))) })]
1215
+ })
1216
+ })]
1217
+ }) : part.state === "completed" && !errorDetails ? /* @__PURE__ */ jsx("p", {
1218
+ className: "text-sm text-neutral-600",
1219
+ children: "No data to display."
1220
+ }) : null,
1221
+ errorDetails ? /* @__PURE__ */ jsxs("p", {
1222
+ className: "rounded border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-700",
1223
+ children: [
1224
+ /* @__PURE__ */ jsx("span", {
1225
+ className: "font-semibold",
1226
+ children: "Error details:"
1227
+ }),
1228
+ " ",
1229
+ errorDetails
1230
+ ]
1231
+ }) : null
1232
+ ]
1233
+ })]
1234
+ })] });
1235
+ }
1236
+
1237
+ //#endregion
1238
+ //#region src/components/tool-result-http-request-card.tsx
1239
+ function output(value) {
1240
+ if (typeof value === "string") return value;
1241
+ if (value === void 0 || value === null) return null;
1242
+ try {
1243
+ return JSON.stringify(value, null, 2);
1244
+ } catch {
1245
+ return null;
1246
+ }
1247
+ }
1248
+ function ToolResultHttpRequestCard({ part, className }) {
1249
+ const metadata = part.metadata;
1250
+ const statusCode = metadata?.status_code;
1251
+ const failed = part.state === "error" || typeof statusCode === "number" && statusCode >= 400;
1252
+ const response = output(part.result);
1253
+ const errorDetails = formatToolErrorDetails(part.errorDetails);
1254
+ const status = statusCode ? `${statusCode}${metadata?.status_reason ? ` ${metadata.status_reason}` : ""}` : part.state;
1255
+ return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsx(SheetTrigger, {
1256
+ "aria-label": `HTTP request: ${status}`,
1257
+ className: joinClasses("w-full rounded-lg border border-neutral-200 bg-white text-left font-normal text-neutral-950 transition-colors hover:bg-neutral-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950", className),
1258
+ children: /* @__PURE__ */ jsxs("span", {
1259
+ className: "flex items-center gap-2 px-3 py-2 text-sm",
1260
+ children: [
1261
+ /* @__PURE__ */ jsx(Globe, {
1262
+ className: "h-4 w-4 shrink-0 text-neutral-500",
1263
+ "aria-hidden": "true"
1264
+ }),
1265
+ /* @__PURE__ */ jsx("span", {
1266
+ className: "shrink-0 font-medium",
1267
+ children: metadata?.method ?? "HTTP"
1268
+ }),
1269
+ /* @__PURE__ */ jsx("span", {
1270
+ className: "min-w-0 truncate text-neutral-600",
1271
+ children: metadata?.url ?? part.name
1272
+ }),
1273
+ /* @__PURE__ */ jsx("span", {
1274
+ className: joinClasses("ml-auto shrink-0", failed ? "text-rose-600" : "text-emerald-600"),
1275
+ children: failed ? /* @__PURE__ */ jsx(XCircle, {
1276
+ className: "h-4 w-4",
1277
+ "aria-hidden": "true"
1278
+ }) : /* @__PURE__ */ jsx(CheckCircle2, {
1279
+ className: "h-4 w-4",
1280
+ "aria-hidden": "true"
1281
+ })
1282
+ })
1283
+ ]
1284
+ })
1285
+ }), /* @__PURE__ */ jsxs(SheetContent, {
1286
+ closeLabel: "Close",
1287
+ children: [/* @__PURE__ */ jsx(SheetHeader, {
1288
+ className: "pr-10",
1289
+ children: /* @__PURE__ */ jsx(SheetTitle, { children: "HTTP request" })
1290
+ }), /* @__PURE__ */ jsxs("section", {
1291
+ className: "mt-6 space-y-5",
1292
+ "aria-label": "HTTP response",
1293
+ children: [
1294
+ /* @__PURE__ */ jsxs("dl", {
1295
+ className: "grid gap-2 text-sm",
1296
+ children: [
1297
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", {
1298
+ className: "text-xs text-neutral-500",
1299
+ children: "Status"
1300
+ }), /* @__PURE__ */ jsx("dd", { children: status })] }),
1301
+ metadata?.url ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", {
1302
+ className: "text-xs text-neutral-500",
1303
+ children: "Request URL"
1304
+ }), /* @__PURE__ */ jsx("dd", {
1305
+ className: "break-all",
1306
+ children: metadata.url
1307
+ })] }) : null,
1308
+ metadata?.response_url && metadata.response_url !== metadata.url ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", {
1309
+ className: "text-xs text-neutral-500",
1310
+ children: "Response URL"
1311
+ }), /* @__PURE__ */ jsx("dd", {
1312
+ className: "break-all",
1313
+ children: metadata.response_url
1314
+ })] }) : null,
1315
+ metadata?.content_type ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", {
1316
+ className: "text-xs text-neutral-500",
1317
+ children: "Content type"
1318
+ }), /* @__PURE__ */ jsx("dd", { children: metadata.content_type })] }) : null
1319
+ ]
1320
+ }),
1321
+ response ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
1322
+ className: "mb-2 text-sm font-medium",
1323
+ children: "Response"
1324
+ }), /* @__PURE__ */ jsx("pre", {
1325
+ className: "overflow-x-auto rounded-md border border-neutral-200 bg-neutral-50 p-3 text-xs leading-5",
1326
+ children: response
1327
+ })] }) : null,
1328
+ metadata?.response_headers && Object.keys(metadata.response_headers).length ? /* @__PURE__ */ jsxs("details", { children: [/* @__PURE__ */ jsx("summary", {
1329
+ className: "cursor-pointer text-sm font-medium",
1330
+ children: "Response headers"
1331
+ }), /* @__PURE__ */ jsx("pre", {
1332
+ className: "mt-2 overflow-x-auto rounded-md border border-neutral-200 bg-neutral-50 p-3 text-xs",
1333
+ children: JSON.stringify(metadata.response_headers, null, 2)
1334
+ })] }) : null,
1335
+ errorDetails ? /* @__PURE__ */ jsxs("p", {
1336
+ className: "rounded border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-700",
1337
+ children: [
1338
+ /* @__PURE__ */ jsx("span", {
1339
+ className: "font-semibold",
1340
+ children: "Error details:"
1341
+ }),
1342
+ " ",
1343
+ errorDetails
1344
+ ]
1345
+ }) : null
1346
+ ]
1347
+ })]
1348
+ })] });
1349
+ }
1350
+
1351
+ //#endregion
1352
+ //#region src/components/tool-result-mcp-card.tsx
1353
+ function text(value) {
1354
+ if (typeof value === "string") return value;
1355
+ if (value == null) return null;
1356
+ try {
1357
+ return JSON.stringify(value, null, 2);
1358
+ } catch {
1359
+ return null;
1360
+ }
1361
+ }
1362
+ function ToolResultMcpCard({ part, className }) {
1363
+ const meta = part.metadata;
1364
+ const server = meta?.mcp_server_url ?? meta?.server_name;
1365
+ const tool = meta?.mcp_tool_name ?? meta?.tool_name ?? part.name;
1366
+ const result = text(part.result);
1367
+ const error = formatToolErrorDetails(part.errorDetails);
1368
+ const failed = part.state === "error";
1369
+ return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsx(SheetTrigger, {
1370
+ "aria-label": `MCP tool: ${tool}`,
1371
+ className: joinClasses("w-full rounded-lg border border-neutral-200 bg-white text-left font-normal text-neutral-950 transition-colors hover:bg-neutral-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950", className),
1372
+ children: /* @__PURE__ */ jsxs("span", {
1373
+ className: "flex items-center gap-2 px-3 py-2 text-sm",
1374
+ children: [
1375
+ /* @__PURE__ */ jsx(Plug, {
1376
+ className: "h-4 w-4 shrink-0 text-neutral-500",
1377
+ "aria-hidden": "true"
1378
+ }),
1379
+ /* @__PURE__ */ jsx("span", {
1380
+ className: "truncate font-medium",
1381
+ children: "MCP"
1382
+ }),
1383
+ /* @__PURE__ */ jsx("span", {
1384
+ className: "min-w-0 truncate text-neutral-600",
1385
+ children: tool
1386
+ }),
1387
+ /* @__PURE__ */ jsx("span", {
1388
+ className: joinClasses("ml-auto shrink-0", failed ? "text-rose-600" : "text-emerald-600"),
1389
+ children: failed ? /* @__PURE__ */ jsx(XCircle, {
1390
+ className: "h-4 w-4",
1391
+ "aria-hidden": "true"
1392
+ }) : /* @__PURE__ */ jsx(CheckCircle2, {
1393
+ className: "h-4 w-4",
1394
+ "aria-hidden": "true"
1395
+ })
1396
+ })
1397
+ ]
1398
+ })
1399
+ }), /* @__PURE__ */ jsxs(SheetContent, {
1400
+ closeLabel: "Close",
1401
+ children: [/* @__PURE__ */ jsx(SheetHeader, {
1402
+ className: "pr-10",
1403
+ children: /* @__PURE__ */ jsx(SheetTitle, { children: "MCP tool" })
1404
+ }), /* @__PURE__ */ jsxs("section", {
1405
+ className: "mt-6 space-y-4",
1406
+ "aria-label": "MCP tool result",
1407
+ children: [
1408
+ /* @__PURE__ */ jsxs("dl", {
1409
+ className: "grid gap-2 text-sm",
1410
+ children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", {
1411
+ className: "text-xs text-neutral-500",
1412
+ children: "Tool"
1413
+ }), /* @__PURE__ */ jsx("dd", { children: tool })] }), server ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", {
1414
+ className: "text-xs text-neutral-500",
1415
+ children: "Server"
1416
+ }), /* @__PURE__ */ jsx("dd", {
1417
+ className: "break-all",
1418
+ children: server
1419
+ })] }) : null]
1420
+ }),
1421
+ result ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
1422
+ className: "mb-2 text-sm font-medium",
1423
+ children: "Result"
1424
+ }), /* @__PURE__ */ jsx("pre", {
1425
+ className: "overflow-x-auto rounded-md border border-neutral-200 bg-neutral-50 p-3 text-xs leading-5",
1426
+ children: result
1427
+ })] }) : null,
1428
+ error ? /* @__PURE__ */ jsxs("p", {
1429
+ className: "rounded border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-700",
1430
+ children: [
1431
+ /* @__PURE__ */ jsx("span", {
1432
+ className: "font-semibold",
1433
+ children: "Error details:"
1434
+ }),
1435
+ " ",
1436
+ error
1437
+ ]
1438
+ }) : null
1439
+ ]
1440
+ })]
1441
+ })] });
1442
+ }
1443
+
1444
+ //#endregion
1445
+ //#region src/components/tool-result-office-documents-card.tsx
1446
+ function getFiles(part) {
1447
+ const files = part.metadata?.media_files;
1448
+ return Array.isArray(files) ? files.filter((file) => Boolean(file) && typeof file === "object" && typeof file.id === "string") : [];
1449
+ }
1450
+ function getExtension(file) {
1451
+ const name = file.name ?? file.pathname ?? "";
1452
+ const extension = name.split(".").pop()?.toLowerCase();
1453
+ if (extension && extension !== name.toLowerCase()) return extension;
1454
+ const mime = file.content_type ?? "";
1455
+ if (mime.includes("pdf")) return "pdf";
1456
+ if (mime.includes("wordprocessingml")) return "docx";
1457
+ if (mime.includes("spreadsheetml")) return "xlsx";
1458
+ if (mime.includes("presentationml")) return "pptx";
1459
+ return null;
1460
+ }
1461
+ function iconClass(extension) {
1462
+ if (extension === "pdf") return "text-rose-500";
1463
+ if (["doc", "docx"].includes(extension ?? "")) return "text-blue-600";
1464
+ if ([
1465
+ "xls",
1466
+ "xlsx",
1467
+ "csv"
1468
+ ].includes(extension ?? "")) return "text-emerald-600";
1469
+ if (["ppt", "pptx"].includes(extension ?? "")) return "text-orange-600";
1470
+ return "text-neutral-500";
1471
+ }
1472
+ function ToolResultOfficeDocumentsCard({ part, className }) {
1473
+ const files = getFiles(part);
1474
+ const errorDetails = formatToolErrorDetails(part.errorDetails);
1475
+ const fileLabel = files.length === 1 ? "file" : "files";
1476
+ const statusClass = part.state === "error" ? "text-rose-600" : part.state === "pending" ? "text-amber-600" : "text-emerald-600";
1477
+ return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsx(SheetTrigger, {
1478
+ "aria-label": `Office documents: ${files.length} ${fileLabel}`,
1479
+ className: joinClasses("w-full overflow-hidden rounded-lg border border-neutral-200 bg-white text-left font-normal text-neutral-950 transition-colors hover:bg-neutral-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950", className),
1480
+ children: /* @__PURE__ */ jsxs("span", {
1481
+ className: "flex items-center gap-2 px-3 py-2 text-sm",
1482
+ children: [
1483
+ /* @__PURE__ */ jsx(FileText, {
1484
+ className: "h-4 w-4 shrink-0 text-neutral-500",
1485
+ "aria-hidden": "true"
1486
+ }),
1487
+ /* @__PURE__ */ jsx("span", {
1488
+ className: "truncate font-medium",
1489
+ children: "Office documents"
1490
+ }),
1491
+ /* @__PURE__ */ jsx("span", {
1492
+ className: "truncate text-xs text-neutral-500",
1493
+ children: part.state === "pending" ? "pending" : `${files.length} ${fileLabel}`
1494
+ }),
1495
+ /* @__PURE__ */ jsx("span", {
1496
+ className: joinClasses("ml-auto shrink-0", statusClass),
1497
+ children: part.state === "error" ? /* @__PURE__ */ jsx(XCircle, {
1498
+ className: "h-4 w-4",
1499
+ "aria-hidden": "true"
1500
+ }) : part.state === "completed" ? /* @__PURE__ */ jsx(CheckCircle2, {
1501
+ className: "h-4 w-4",
1502
+ "aria-hidden": "true"
1503
+ }) : null
1504
+ })
1505
+ ]
1506
+ })
1507
+ }), /* @__PURE__ */ jsxs(SheetContent, {
1508
+ closeLabel: "Close",
1509
+ children: [/* @__PURE__ */ jsx(SheetHeader, {
1510
+ className: "pr-10",
1511
+ children: /* @__PURE__ */ jsx(SheetTitle, { children: "Office documents" })
1512
+ }), /* @__PURE__ */ jsxs("section", {
1513
+ className: "mt-6 space-y-3",
1514
+ "aria-label": "Generated files",
1515
+ children: [
1516
+ files.map((file) => {
1517
+ const extension = getExtension(file);
1518
+ const label = file.name ?? file.pathname ?? file.id;
1519
+ const content = /* @__PURE__ */ jsxs("div", {
1520
+ className: "flex items-center gap-3 rounded-lg border border-neutral-200 bg-white p-3",
1521
+ children: [/* @__PURE__ */ jsx(File, {
1522
+ className: joinClasses("h-8 w-8 shrink-0", iconClass(extension)),
1523
+ "aria-hidden": "true"
1524
+ }), /* @__PURE__ */ jsxs("div", {
1525
+ className: "min-w-0",
1526
+ children: [/* @__PURE__ */ jsx("p", {
1527
+ className: "truncate text-sm font-medium",
1528
+ children: label
1529
+ }), extension ? /* @__PURE__ */ jsx("p", {
1530
+ className: "text-[11px] uppercase text-neutral-500",
1531
+ children: extension
1532
+ }) : null]
1533
+ })]
1534
+ }, file.id);
1535
+ return file.url ? /* @__PURE__ */ jsx("a", {
1536
+ href: file.url,
1537
+ target: "_blank",
1538
+ rel: "noreferrer noopener",
1539
+ className: "block hover:bg-neutral-50",
1540
+ children: content
1541
+ }, file.id) : /* @__PURE__ */ jsx("div", { children: content }, file.id);
1542
+ }),
1543
+ files.length === 0 && part.state === "pending" ? /* @__PURE__ */ jsx("p", {
1544
+ className: "text-sm text-neutral-600",
1545
+ children: "Creating documents…"
1546
+ }) : null,
1547
+ files.length === 0 && part.state === "completed" && !errorDetails ? /* @__PURE__ */ jsx("p", {
1548
+ className: "text-sm text-neutral-600",
1549
+ children: "No files were generated."
1550
+ }) : null,
1551
+ errorDetails ? /* @__PURE__ */ jsxs("p", {
1552
+ className: "rounded border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-700",
1553
+ children: [
1554
+ /* @__PURE__ */ jsx("span", {
1555
+ className: "font-semibold",
1556
+ children: "Error details:"
1557
+ }),
1558
+ " ",
1559
+ errorDetails
1560
+ ]
1561
+ }) : null
1562
+ ]
1563
+ })]
1564
+ })] });
1565
+ }
1566
+
1567
+ //#endregion
1568
+ //#region src/components/tool-result-web-search-card.tsx
1569
+ function isWebSearchResult(value) {
1570
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
1571
+ const candidate = value;
1572
+ return typeof candidate.title === "string" && typeof candidate.url === "string";
1573
+ }
1574
+ function toStringOrNull(value) {
1575
+ return typeof value === "string" && value.trim().length > 0 ? value : null;
1576
+ }
1577
+ function getHostname(url) {
1578
+ try {
1579
+ return new URL(url).hostname;
1580
+ } catch {
1581
+ return null;
1582
+ }
1583
+ }
1584
+ function getLegacyCitationResults(metadata) {
1585
+ if (!Array.isArray(metadata.citations)) return [];
1586
+ return metadata.citations.filter((citation) => typeof citation === "string").map((url) => ({
1587
+ title: getHostname(url) ?? url,
1588
+ url
1589
+ }));
1590
+ }
1591
+ function getSearchResults(part) {
1592
+ const searchResults = part.metadata?.search_results;
1593
+ if (Array.isArray(searchResults)) {
1594
+ const results = searchResults.filter(isWebSearchResult);
1595
+ if (results.length > 0) return results;
1596
+ }
1597
+ return getLegacyCitationResults(part.metadata ?? {});
1598
+ }
1599
+ function getFaviconUrl(url) {
1600
+ const hostname = getHostname(url);
1601
+ return hostname ? `https://www.google.com/s2/favicons?domain=${encodeURIComponent(hostname)}&sz=32` : null;
1602
+ }
1603
+ function WebSearchResultItem({ result }) {
1604
+ const hostname = getHostname(result.url);
1605
+ const source = toStringOrNull(result.source);
1606
+ const snippet = toStringOrNull(result.snippet);
1607
+ const date = toStringOrNull(result.date) ?? toStringOrNull(result.last_updated);
1608
+ const imageUrl = toStringOrNull(result.image_url);
1609
+ const faviconUrl = getFaviconUrl(result.url);
1610
+ return /* @__PURE__ */ jsx("article", {
1611
+ className: "rounded-lg border border-neutral-200 bg-white p-4",
1612
+ children: /* @__PURE__ */ jsxs("div", {
1613
+ className: "flex items-start gap-3",
1614
+ children: [/* @__PURE__ */ jsxs("span", {
1615
+ "aria-hidden": "true",
1616
+ className: "relative flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-full border border-neutral-300 bg-white text-neutral-600",
1617
+ children: [/* @__PURE__ */ jsx(Globe, { className: "h-4 w-4" }), faviconUrl ? /* @__PURE__ */ jsx("img", {
1618
+ src: faviconUrl,
1619
+ alt: "",
1620
+ width: "16",
1621
+ height: "16",
1622
+ className: "absolute h-4 w-4 bg-white",
1623
+ onError: (event) => {
1624
+ event.currentTarget.style.display = "none";
1625
+ }
1626
+ }) : null]
1627
+ }), /* @__PURE__ */ jsxs("div", {
1628
+ className: "min-w-0 flex-1 space-y-1",
1629
+ children: [
1630
+ /* @__PURE__ */ jsx("a", {
1631
+ href: result.url,
1632
+ target: "_blank",
1633
+ rel: "noreferrer noopener",
1634
+ className: "block line-clamp-2 text-sm font-medium leading-5 text-neutral-950 hover:underline",
1635
+ children: result.title
1636
+ }),
1637
+ /* @__PURE__ */ jsxs("div", {
1638
+ className: "flex flex-wrap items-center gap-1.5 text-xs text-neutral-500",
1639
+ children: [
1640
+ date ? /* @__PURE__ */ jsx("span", { children: date }) : null,
1641
+ source ? /* @__PURE__ */ jsx("span", {
1642
+ className: "rounded-full bg-neutral-100 px-1.5 py-0.5 capitalize text-neutral-600",
1643
+ children: source
1644
+ }) : null,
1645
+ !date && !source && hostname ? /* @__PURE__ */ jsx("span", { children: hostname }) : null
1646
+ ]
1647
+ }),
1648
+ snippet ? /* @__PURE__ */ jsx("p", {
1649
+ className: "line-clamp-2 text-xs leading-5 text-neutral-600",
1650
+ children: snippet
1651
+ }) : null,
1652
+ imageUrl ? /* @__PURE__ */ jsx("img", {
1653
+ src: imageUrl,
1654
+ alt: "",
1655
+ className: "max-h-64 w-full rounded-md border border-neutral-200 object-contain",
1656
+ loading: "lazy"
1657
+ }) : null
1658
+ ]
1659
+ })]
1660
+ })
1661
+ });
1662
+ }
1663
+ function ToolResultWebSearchCard({ part, className }) {
1664
+ const searchResults = getSearchResults(part);
1665
+ const errorDetails = formatToolErrorDetails(part.errorDetails);
1666
+ const sourceLabel = searchResults.length === 1 ? "source" : "sources";
1667
+ return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsxs(SheetTrigger, {
1668
+ "aria-label": `Web: Internet search results, ${searchResults.length} ${sourceLabel}`,
1669
+ className: joinClasses("min-h-[183px] w-[186px] rounded-lg bg-neutral-100 p-4 text-left font-normal text-neutral-950 transition-colors hover:bg-neutral-200 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950", className),
1670
+ children: [
1671
+ /* @__PURE__ */ jsxs("header", {
1672
+ className: "flex items-center gap-3",
1673
+ children: [/* @__PURE__ */ jsx(Globe, {
1674
+ className: "h-5 w-5 shrink-0",
1675
+ "aria-hidden": "true"
1676
+ }), /* @__PURE__ */ jsx("p", {
1677
+ className: "text-base leading-5",
1678
+ children: "WEB"
1679
+ })]
1680
+ }),
1681
+ /* @__PURE__ */ jsx("h3", {
1682
+ className: "mt-3 line-clamp-2 text-sm font-normal leading-5",
1683
+ children: "Internet search results"
1684
+ }),
1685
+ /* @__PURE__ */ jsx("p", {
1686
+ className: "mt-2 text-xs leading-4 text-neutral-600",
1687
+ children: part.state === "pending" ? "Searching…" : `${searchResults.length} ${sourceLabel}`
1688
+ })
1689
+ ]
1690
+ }), /* @__PURE__ */ jsxs(SheetContent, {
1691
+ closeLabel: "Close",
1692
+ children: [/* @__PURE__ */ jsx(SheetHeader, {
1693
+ className: "pr-10",
1694
+ children: /* @__PURE__ */ jsx(SheetTitle, { children: "Internet search results" })
1695
+ }), /* @__PURE__ */ jsxs("section", {
1696
+ className: "mt-5",
1697
+ "aria-label": "Search results",
1698
+ children: [searchResults.length > 0 ? /* @__PURE__ */ jsx("div", {
1699
+ className: "space-y-3",
1700
+ children: searchResults.map((result, index) => /* @__PURE__ */ jsx(WebSearchResultItem, { result }, `${result.url}-${index}`))
1701
+ }) : part.state === "pending" ? /* @__PURE__ */ jsx("p", {
1702
+ className: "text-sm text-neutral-600",
1703
+ children: "Searching for sources…"
1704
+ }) : /* @__PURE__ */ jsx("p", {
1705
+ className: "text-sm text-neutral-600",
1706
+ children: "No sources returned."
1707
+ }), errorDetails ? /* @__PURE__ */ jsxs("p", {
1708
+ className: "mt-4 rounded border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-700",
215
1709
  children: [
216
1710
  /* @__PURE__ */ jsx("span", {
217
1711
  className: "font-semibold",
218
1712
  children: "Error details:"
219
1713
  }),
220
1714
  " ",
221
- part.errorDetails
1715
+ errorDetails
222
1716
  ]
223
- }) : null
224
- ]
225
- });
1717
+ }) : null]
1718
+ })]
1719
+ })] });
1720
+ }
1721
+
1722
+ //#endregion
1723
+ //#region src/components/tool-result-workflow-dispatch-card.tsx
1724
+ function parseResult(value) {
1725
+ let parsed = value;
1726
+ if (typeof value === "string") try {
1727
+ parsed = JSON.parse(value);
1728
+ } catch {
1729
+ return {};
1730
+ }
1731
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
1732
+ const result = parsed;
1733
+ return {
1734
+ executionId: typeof result.execution_id === "string" ? result.execution_id : void 0,
1735
+ workflowId: typeof result.workflow_id === "string" ? result.workflow_id : void 0,
1736
+ workflowName: typeof result.workflow_name_slug === "string" ? result.workflow_name_slug : void 0,
1737
+ status: typeof result.status === "string" ? result.status : void 0
1738
+ };
1739
+ }
1740
+ function formatResult(value) {
1741
+ if (typeof value === "string") return value;
1742
+ if (value == null) return null;
1743
+ try {
1744
+ return JSON.stringify(value, null, 2);
1745
+ } catch {
1746
+ return null;
1747
+ }
1748
+ }
1749
+ function ToolResultWorkflowDispatchCard({ part, className }) {
1750
+ const result = parseResult(part.result);
1751
+ const workflowName = result.workflowName ?? part.name;
1752
+ const status = result.status ?? part.state;
1753
+ const failed = part.state === "error";
1754
+ const output$1 = formatResult(part.result);
1755
+ const error = formatToolErrorDetails(part.errorDetails);
1756
+ return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsx(SheetTrigger, {
1757
+ "aria-label": `Workflow: ${workflowName}`,
1758
+ className: joinClasses("w-full rounded-lg border border-neutral-200 bg-white text-left font-normal text-neutral-950 transition-colors hover:bg-neutral-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950", className),
1759
+ children: /* @__PURE__ */ jsxs("span", {
1760
+ className: "flex items-center gap-2 px-3 py-2 text-sm",
1761
+ children: [
1762
+ /* @__PURE__ */ jsx(Workflow, {
1763
+ className: "h-4 w-4 shrink-0 text-neutral-500",
1764
+ "aria-hidden": "true"
1765
+ }),
1766
+ /* @__PURE__ */ jsx("span", {
1767
+ className: "shrink-0 font-medium",
1768
+ children: "Workflow"
1769
+ }),
1770
+ /* @__PURE__ */ jsx("span", {
1771
+ className: "min-w-0 truncate text-neutral-600",
1772
+ children: workflowName
1773
+ }),
1774
+ /* @__PURE__ */ jsxs("span", {
1775
+ className: "ml-auto flex shrink-0 items-center gap-2",
1776
+ children: [/* @__PURE__ */ jsx("span", {
1777
+ className: "text-xs text-neutral-500",
1778
+ children: status
1779
+ }), failed ? /* @__PURE__ */ jsx(XCircle, {
1780
+ className: "h-4 w-4 text-rose-600",
1781
+ "aria-hidden": "true"
1782
+ }) : /* @__PURE__ */ jsx(CheckCircle2, {
1783
+ className: "h-4 w-4 text-emerald-600",
1784
+ "aria-hidden": "true"
1785
+ })]
1786
+ })
1787
+ ]
1788
+ })
1789
+ }), /* @__PURE__ */ jsxs(SheetContent, {
1790
+ closeLabel: "Close",
1791
+ children: [/* @__PURE__ */ jsx(SheetHeader, {
1792
+ className: "pr-10",
1793
+ children: /* @__PURE__ */ jsx(SheetTitle, { children: "Workflow dispatch" })
1794
+ }), /* @__PURE__ */ jsxs("section", {
1795
+ className: "mt-6 space-y-4",
1796
+ "aria-label": "Workflow dispatch result",
1797
+ children: [
1798
+ /* @__PURE__ */ jsxs("dl", {
1799
+ className: "grid gap-2 text-sm",
1800
+ children: [
1801
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", {
1802
+ className: "text-xs text-neutral-500",
1803
+ children: "Workflow"
1804
+ }), /* @__PURE__ */ jsx("dd", { children: workflowName })] }),
1805
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", {
1806
+ className: "text-xs text-neutral-500",
1807
+ children: "Status"
1808
+ }), /* @__PURE__ */ jsx("dd", { children: status })] }),
1809
+ result.executionId ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", {
1810
+ className: "text-xs text-neutral-500",
1811
+ children: "Execution ID"
1812
+ }), /* @__PURE__ */ jsx("dd", {
1813
+ className: "break-all",
1814
+ children: result.executionId
1815
+ })] }) : null,
1816
+ result.workflowId ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", {
1817
+ className: "text-xs text-neutral-500",
1818
+ children: "Workflow ID"
1819
+ }), /* @__PURE__ */ jsx("dd", {
1820
+ className: "break-all",
1821
+ children: result.workflowId
1822
+ })] }) : null
1823
+ ]
1824
+ }),
1825
+ output$1 ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
1826
+ className: "mb-2 text-sm font-medium",
1827
+ children: "Result"
1828
+ }), /* @__PURE__ */ jsx("pre", {
1829
+ className: "overflow-x-auto rounded-md border border-neutral-200 bg-neutral-50 p-3 text-xs leading-5",
1830
+ children: output$1
1831
+ })] }) : null,
1832
+ error ? /* @__PURE__ */ jsxs("p", {
1833
+ className: "rounded border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-700",
1834
+ children: [
1835
+ /* @__PURE__ */ jsx("span", {
1836
+ className: "font-semibold",
1837
+ children: "Error details:"
1838
+ }),
1839
+ " ",
1840
+ error
1841
+ ]
1842
+ }) : null
1843
+ ]
1844
+ })]
1845
+ })] });
226
1846
  }
227
1847
 
228
1848
  //#endregion
@@ -237,12 +1857,56 @@ function getOfficeDocumentMediaFiles(part) {
237
1857
  if (!Array.isArray(metadata.media_files)) return [];
238
1858
  return metadata.media_files.filter((file) => Boolean(file) && typeof file === "object" && typeof file.id === "string");
239
1859
  }
240
- function ToolResultCard({ part, className, detailsOpen = true }) {
1860
+ function getDatasourceResources(part) {
1861
+ if (part.toolType !== "datasource" || !part.metadata) return [];
1862
+ const resources = part.metadata.resources;
1863
+ return Array.isArray(resources) ? resources.filter(isDatasourceResource) : [];
1864
+ }
1865
+ function ToolResultCard({ part, className, detailsOpen = true, onOpenAgentThread }) {
241
1866
  const officeMediaFiles = getOfficeDocumentMediaFiles(part);
1867
+ const datasourceResources = getDatasourceResources(part);
1868
+ const errorDetails = formatToolErrorDetails(part.errorDetails);
242
1869
  if (part.toolType === "email_send") return /* @__PURE__ */ jsx(ToolResultEmailSendCard, {
243
1870
  part,
244
1871
  className
245
1872
  });
1873
+ if (part.toolType === "agent_invocation") return /* @__PURE__ */ jsx(ToolResultAgentInvocationCard, {
1874
+ part,
1875
+ className,
1876
+ onOpenThread: onOpenAgentThread
1877
+ });
1878
+ if (part.toolType === "browser") return /* @__PURE__ */ jsx(ToolResultBrowserCard, {
1879
+ part,
1880
+ className
1881
+ });
1882
+ if (part.toolType === "external_datasource") return /* @__PURE__ */ jsx(ToolResultExternalDatasourceCard, {
1883
+ part,
1884
+ className
1885
+ });
1886
+ if (part.toolType === "office_documents") return /* @__PURE__ */ jsx(ToolResultOfficeDocumentsCard, {
1887
+ part,
1888
+ className
1889
+ });
1890
+ if (part.toolType === "http_request") return /* @__PURE__ */ jsx(ToolResultHttpRequestCard, {
1891
+ part,
1892
+ className
1893
+ });
1894
+ if (part.toolType === "mcp_tool") return /* @__PURE__ */ jsx(ToolResultMcpCard, {
1895
+ part,
1896
+ className
1897
+ });
1898
+ if (part.toolType === "workflow_dispatch") return /* @__PURE__ */ jsx(ToolResultWorkflowDispatchCard, {
1899
+ part,
1900
+ className
1901
+ });
1902
+ if (part.toolType === "perplexity" || part.toolType === "firecrawl_search") return /* @__PURE__ */ jsx(ToolResultWebSearchCard, {
1903
+ part,
1904
+ className
1905
+ });
1906
+ if (datasourceResources.length > 0) return /* @__PURE__ */ jsx(DatasourceToolResources, {
1907
+ resources: datasourceResources,
1908
+ className
1909
+ });
246
1910
  const statusClass = part.state === "error" ? "border-rose-200 bg-rose-50 text-rose-800" : part.state === "pending" ? "border-amber-200 bg-amber-50 text-amber-800" : "border-emerald-200 bg-emerald-50 text-emerald-800";
247
1911
  const statusLabel = part.state === "pending" ? "pending" : part.state === "error" ? "error" : "completed";
248
1912
  return /* @__PURE__ */ jsxs("section", {
@@ -318,7 +1982,7 @@ function ToolResultCard({ part, className, detailsOpen = true }) {
318
1982
  })
319
1983
  ]
320
1984
  }) : null,
321
- part.errorDetails ? /* @__PURE__ */ jsxs("p", {
1985
+ errorDetails ? /* @__PURE__ */ jsxs("p", {
322
1986
  className: "rounded border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-700",
323
1987
  children: [
324
1988
  /* @__PURE__ */ jsx("span", {
@@ -326,7 +1990,7 @@ function ToolResultCard({ part, className, detailsOpen = true }) {
326
1990
  children: "Error details:"
327
1991
  }),
328
1992
  " ",
329
- part.errorDetails
1993
+ errorDetails
330
1994
  ]
331
1995
  }) : null
332
1996
  ]
@@ -350,7 +2014,7 @@ function getDisplayExtension(label) {
350
2014
  if (!ext || ext === label.toUpperCase()) return;
351
2015
  return ext;
352
2016
  }
353
- function renderPart(part, index) {
2017
+ function renderPart(part, index, onOpenAgentThread) {
354
2018
  if (part.type === "text") return /* @__PURE__ */ jsx("p", {
355
2019
  className: "whitespace-pre-wrap text-sm leading-6",
356
2020
  children: part.text
@@ -395,14 +2059,29 @@ function renderPart(part, index) {
395
2059
  })]
396
2060
  }, `file-${index}`);
397
2061
  }
398
- if (part.type === "tool-call") return /* @__PURE__ */ jsx(ToolResultCard, { part }, `tool-${part.id}-${index}`);
2062
+ if (part.type === "tool-call") return /* @__PURE__ */ jsx(ToolResultCard, {
2063
+ part,
2064
+ onOpenAgentThread
2065
+ }, `tool-${part.id}-${index}`);
399
2066
  if (part.type === "guardrail") return /* @__PURE__ */ jsx("p", {
400
2067
  className: "rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900",
401
2068
  children: part.content
402
2069
  }, `guardrail-${index}`);
403
2070
  return null;
404
2071
  }
405
- function Message({ message, className, showRole = true, collapseThreshold = DEFAULT_COLLAPSE_THRESHOLD }) {
2072
+ function orderMessageParts(parts, datasourceToolResultsPosition) {
2073
+ const indexedParts = parts.map((part, index) => ({
2074
+ part,
2075
+ index
2076
+ }));
2077
+ if (datasourceToolResultsPosition === "inline") return indexedParts;
2078
+ const datasourceParts = [];
2079
+ const remainingParts = [];
2080
+ for (const indexedPart of indexedParts) if (indexedPart.part.type === "tool-call" && indexedPart.part.toolType === "datasource") datasourceParts.push(indexedPart);
2081
+ else remainingParts.push(indexedPart);
2082
+ return [...datasourceParts, ...remainingParts];
2083
+ }
2084
+ function Message({ message, className, showRole = true, collapseThreshold = DEFAULT_COLLAPSE_THRESHOLD, datasourceToolResultsPosition = "inline", onOpenAgentThread }) {
406
2085
  const roleLabel = message.role.charAt(0).toUpperCase() + message.role.slice(1);
407
2086
  const [isExpanded, setIsExpanded] = useState(false);
408
2087
  const textContent = useMemo(() => {
@@ -410,6 +2089,7 @@ function Message({ message, className, showRole = true, collapseThreshold = DEFA
410
2089
  }, [message.parts]);
411
2090
  const canCollapse = message.role === "user" && message.parts.every((part) => part.type === "text") && textContent.length > collapseThreshold;
412
2091
  const previewText = canCollapse ? `${textContent.slice(0, collapseThreshold).trimEnd()}...` : textContent;
2092
+ const orderedParts = useMemo(() => orderMessageParts(message.parts, datasourceToolResultsPosition), [message.parts, datasourceToolResultsPosition]);
413
2093
  return /* @__PURE__ */ jsxs("article", {
414
2094
  className: joinClasses("space-y-3 rounded-xl border border-slate-200 bg-white p-4 shadow-sm", className),
415
2095
  "data-message-role": message.role,
@@ -423,7 +2103,7 @@ function Message({ message, className, showRole = true, collapseThreshold = DEFA
423
2103
  children: canCollapse && !isExpanded ? /* @__PURE__ */ jsx("p", {
424
2104
  className: "whitespace-pre-wrap text-sm leading-6",
425
2105
  children: previewText
426
- }) : message.parts.map((part, index) => renderPart(part, index))
2106
+ }) : orderedParts.map(({ part, index }) => renderPart(part, index, onOpenAgentThread))
427
2107
  }),
428
2108
  canCollapse ? /* @__PURE__ */ jsx("button", {
429
2109
  type: "button",
@@ -435,130 +2115,6 @@ function Message({ message, className, showRole = true, collapseThreshold = DEFA
435
2115
  });
436
2116
  }
437
2117
 
438
- //#endregion
439
- //#region src/components/icons/arrow.tsx
440
- function ArrowUp(props) {
441
- return /* @__PURE__ */ jsxs("svg", {
442
- ...props,
443
- xmlns: "http://www.w3.org/2000/svg",
444
- width: "24",
445
- height: "24",
446
- viewBox: "0 0 24 24",
447
- fill: "none",
448
- stroke: "currentColor",
449
- strokeWidth: "2",
450
- strokeLinecap: "round",
451
- strokeLinejoin: "round",
452
- "aria-hidden": "true",
453
- children: [/* @__PURE__ */ jsx("path", { d: "m5 12 7-7 7 7" }), /* @__PURE__ */ jsx("path", { d: "M12 19V5" })]
454
- });
455
- }
456
-
457
- //#endregion
458
- //#region src/components/icons/loader.tsx
459
- function Loader(props) {
460
- return /* @__PURE__ */ jsx("svg", {
461
- ...props,
462
- xmlns: "http://www.w3.org/2000/svg",
463
- width: "24",
464
- height: "24",
465
- viewBox: "0 0 24 24",
466
- fill: "none",
467
- stroke: "currentColor",
468
- strokeWidth: "2",
469
- strokeLinecap: "round",
470
- strokeLinejoin: "round",
471
- "aria-hidden": "true",
472
- children: /* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" })
473
- });
474
- }
475
-
476
- //#endregion
477
- //#region src/components/icons/microphone.tsx
478
- function Microphone(props) {
479
- return /* @__PURE__ */ jsxs("svg", {
480
- ...props,
481
- xmlns: "http://www.w3.org/2000/svg",
482
- width: "24",
483
- height: "24",
484
- viewBox: "0 0 24 24",
485
- fill: "none",
486
- stroke: "currentColor",
487
- strokeWidth: "2",
488
- strokeLinecap: "round",
489
- strokeLinejoin: "round",
490
- "aria-hidden": "true",
491
- children: [
492
- /* @__PURE__ */ jsx("path", { d: "M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z" }),
493
- /* @__PURE__ */ jsx("path", { d: "M19 10v2a7 7 0 0 1-14 0v-2" }),
494
- /* @__PURE__ */ jsx("path", { d: "M12 19v3" })
495
- ]
496
- });
497
- }
498
-
499
- //#endregion
500
- //#region src/components/icons/paperclip.tsx
501
- function Paperclip(props) {
502
- return /* @__PURE__ */ jsx("svg", {
503
- ...props,
504
- xmlns: "http://www.w3.org/2000/svg",
505
- width: "24",
506
- height: "24",
507
- viewBox: "0 0 24 24",
508
- fill: "none",
509
- stroke: "currentColor",
510
- strokeWidth: "2",
511
- strokeLinecap: "round",
512
- strokeLinejoin: "round",
513
- "aria-hidden": "true",
514
- children: /* @__PURE__ */ jsx("path", { d: "m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48" })
515
- });
516
- }
517
-
518
- //#endregion
519
- //#region src/components/icons/stop.tsx
520
- function Stop(props) {
521
- return /* @__PURE__ */ jsx("svg", {
522
- ...props,
523
- xmlns: "http://www.w3.org/2000/svg",
524
- width: "24",
525
- height: "24",
526
- viewBox: "0 0 24 24",
527
- fill: "none",
528
- stroke: "currentColor",
529
- strokeWidth: "2",
530
- strokeLinecap: "round",
531
- strokeLinejoin: "round",
532
- "aria-hidden": "true",
533
- children: /* @__PURE__ */ jsx("rect", {
534
- x: "6",
535
- y: "6",
536
- width: "12",
537
- height: "12",
538
- rx: "1"
539
- })
540
- });
541
- }
542
-
543
- //#endregion
544
- //#region src/components/icons/x.tsx
545
- function X(props) {
546
- return /* @__PURE__ */ jsxs("svg", {
547
- ...props,
548
- xmlns: "http://www.w3.org/2000/svg",
549
- width: "24",
550
- height: "24",
551
- viewBox: "0 0 24 24",
552
- fill: "none",
553
- stroke: "currentColor",
554
- strokeWidth: "2",
555
- strokeLinecap: "round",
556
- strokeLinejoin: "round",
557
- "aria-hidden": "true",
558
- children: [/* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }), /* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })]
559
- });
560
- }
561
-
562
2118
  //#endregion
563
2119
  //#region src/components/prompt-form/file-attachments.ts
564
2120
  const ALLOWED_EXTENSIONS = new Set([
@@ -682,10 +2238,10 @@ function PromptForm({ value, onValueChange, onSubmit, status = "ready", onStop,
682
2238
  if (!canSubmit) return;
683
2239
  setIsSubmitting(true);
684
2240
  try {
685
- const text = value.trim();
2241
+ const text$1 = value.trim();
686
2242
  const selectedFiles = [...files];
687
2243
  await onSubmit({
688
- text,
2244
+ text: text$1,
689
2245
  ...enabledTools ? { enabledTools } : {},
690
2246
  files: selectedFiles
691
2247
  });
@@ -785,9 +2341,9 @@ async function transcribeAudioViaEndpoint(audio, endpoint, signal) {
785
2341
  });
786
2342
  if (!response.ok) throw new Error(`Transcription request failed with status ${response.status}`);
787
2343
  const body = await response.json();
788
- const text = body.text ?? body.data;
789
- if (!text) throw new Error("Transcription response did not include text");
790
- return text;
2344
+ const text$1 = body.text ?? body.data;
2345
+ if (!text$1) throw new Error("Transcription response did not include text");
2346
+ return text$1;
791
2347
  }
792
2348
 
793
2349
  //#endregion
@@ -865,8 +2421,8 @@ function SpeechToTextToggle({ onTranscriptionComplete, onTranscriptionError, tra
865
2421
  const abortController = new AbortController();
866
2422
  abortControllerRef.current = abortController;
867
2423
  try {
868
- const text = await transcribeAudio(await stop(), abortController.signal);
869
- if (text.trim()) onTranscriptionComplete(text);
2424
+ const text$1 = await transcribeAudio(await stop(), abortController.signal);
2425
+ if (text$1.trim()) onTranscriptionComplete(text$1);
870
2426
  } catch (error) {
871
2427
  if (error instanceof DOMException && error.name === "AbortError") return;
872
2428
  onTranscriptionError?.(error instanceof Error ? error : /* @__PURE__ */ new Error("Transcription failed"));
@@ -892,5 +2448,5 @@ function SpeechToTextToggle({ onTranscriptionComplete, onTranscriptionError, tra
892
2448
  }
893
2449
 
894
2450
  //#endregion
895
- export { ArrowUp, Loader, Message, Microphone, PROMPT_FORM_FILE_ACCEPT, Paperclip, PromptForm, PromptFormAttachButton, PromptFormIconButton, SpeechToTextToggle, Stop, ToolResultCard, X, dummyTranscribeAudio, isAllowedPromptFormFile, partitionPromptFormFiles, transcribeAudioViaEndpoint };
2451
+ export { ArrowUp, DatasourceFolderCard, DatasourceToolResources, DatasourceToolResultCard, Loader, Message, Microphone, PROMPT_FORM_FILE_ACCEPT, Paperclip, PromptForm, PromptFormAttachButton, PromptFormIconButton, ResourceCard, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, SpeechToTextToggle, Stop, ToolResultAgentInvocationCard, ToolResultBrowserCard, ToolResultCard, ToolResultExternalDatasourceCard, ToolResultHttpRequestCard, ToolResultMcpCard, ToolResultOfficeDocumentsCard, ToolResultWebSearchCard, ToolResultWorkflowDispatchCard, X, dummyTranscribeAudio, isAllowedPromptFormFile, partitionPromptFormFiles, transcribeAudioViaEndpoint };
896
2452
  //# sourceMappingURL=index.js.map