@plaisolutions/react 0.8.5 → 0.9.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/README.md +8 -0
- package/dist/components/index.d.ts +28 -4
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +384 -215
- package/dist/components/index.js.map +1 -1
- package/dist/index.d.ts +28 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +384 -215
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/components/index.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
2
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { Bot, Brain, Check, CheckCircle2, ChevronDown, CircleX, Copy, Database, File, FileText, Globe, LoaderCircle, MessageSquare, Minus, Plug, Plus, RotateCcw, ThumbsDown, ThumbsUp, Workflow, XCircle } from "lucide-react";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
|
|
5
|
-
//#region src/components/internal/join-classes.ts
|
|
6
|
-
function joinClasses(...classes) {
|
|
7
|
-
return classes.filter(Boolean).join(" ");
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
//#endregion
|
|
11
5
|
//#region src/components/datasource-tool-result-card.tsx
|
|
12
6
|
function DatasourceIcon() {
|
|
13
7
|
return /* @__PURE__ */ jsxs("svg", {
|
|
@@ -81,6 +75,12 @@ function DatasourceToolResultCard(props) {
|
|
|
81
75
|
});
|
|
82
76
|
}
|
|
83
77
|
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/components/internal/join-classes.ts
|
|
80
|
+
function joinClasses(...classes) {
|
|
81
|
+
return classes.filter(Boolean).join(" ");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
84
|
//#endregion
|
|
85
85
|
//#region src/components/resource-card.tsx
|
|
86
86
|
function ResourceCardContent({ icon, type, title, description }) {
|
|
@@ -481,10 +481,10 @@ const SheetDescription = forwardRef(function SheetDescription$1({ className, id,
|
|
|
481
481
|
|
|
482
482
|
//#endregion
|
|
483
483
|
//#region src/components/datasource-folder-card.tsx
|
|
484
|
-
function DatasourceFolderCard({ icon, title, description, type, url, resources }) {
|
|
484
|
+
function DatasourceFolderCard({ icon, title, description, type, url, resources, variant = "card" }) {
|
|
485
485
|
return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsx(SheetTrigger, {
|
|
486
486
|
"aria-label": `${type}: ${title}`,
|
|
487
|
-
className: "min-h-[183px] w-[186px] max-w-full 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
|
|
487
|
+
className: `${variant === "card" ? "min-h-[183px] w-[186px] max-w-full" : "w-full"} 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`,
|
|
488
488
|
children: /* @__PURE__ */ jsx(DatasourceToolResultCardContent, {
|
|
489
489
|
icon,
|
|
490
490
|
title,
|
|
@@ -658,13 +658,25 @@ function toResourceCardProps(resource, locale) {
|
|
|
658
658
|
url: getResourceUrl(resource, locale)
|
|
659
659
|
};
|
|
660
660
|
}
|
|
661
|
+
function toFolderCardProps(folder, group, locale) {
|
|
662
|
+
const datasource = group[0]?.datasource;
|
|
663
|
+
const type = getLocalizedOpenGraphValue(folder, "type", locale) ?? readString(folder.extra_info, "type") ?? datasource?.type ?? "FOLDER";
|
|
664
|
+
return {
|
|
665
|
+
icon: getLocalizedOpenGraphValue(folder, "image", locale) ?? void 0,
|
|
666
|
+
title: getLocalizedOpenGraphValue(folder, "title", locale) ?? folder.name,
|
|
667
|
+
description: getLocalizedOpenGraphValue(folder, "description", locale) ?? readString(folder.extra_info, "description") ?? readString(folder.extra_info, "summary") ?? datasource?.description ?? datasource?.summary ?? "",
|
|
668
|
+
type,
|
|
669
|
+
url: getLocalizedOpenGraphValue(folder, "url", locale),
|
|
670
|
+
resources: group.map((resource) => toResourceCardProps(resource, locale))
|
|
671
|
+
};
|
|
672
|
+
}
|
|
661
673
|
function isDatasourceResource(value) {
|
|
662
674
|
if (!isObject(value)) return false;
|
|
663
675
|
const folder = value.folder;
|
|
664
676
|
const datasource = value.datasource;
|
|
665
677
|
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"));
|
|
666
678
|
}
|
|
667
|
-
function
|
|
679
|
+
function getDatasourceResourceCards(resources, locale) {
|
|
668
680
|
const folderGroups = /* @__PURE__ */ new Map();
|
|
669
681
|
const ungroupedResources = [];
|
|
670
682
|
const seenUrls = /* @__PURE__ */ new Set();
|
|
@@ -686,28 +698,58 @@ function DatasourceToolResources({ resources, locale, className }) {
|
|
|
686
698
|
resources: [resource]
|
|
687
699
|
});
|
|
688
700
|
}
|
|
689
|
-
return
|
|
701
|
+
return [...Array.from(folderGroups.values()).map(({ folder, resources: group }) => ({
|
|
702
|
+
kind: "folder",
|
|
703
|
+
key: `folder-${folder.id}`,
|
|
704
|
+
props: toFolderCardProps(folder, group, locale)
|
|
705
|
+
})), ...ungroupedResources.map((resource) => ({
|
|
706
|
+
kind: "resource",
|
|
707
|
+
key: `resource-${resource.id}`,
|
|
708
|
+
props: toResourceCardProps(resource, locale)
|
|
709
|
+
}))];
|
|
710
|
+
}
|
|
711
|
+
function DatasourceResourceCardView({ card, variant = "card" }) {
|
|
712
|
+
if (card.kind === "folder") return /* @__PURE__ */ jsx(DatasourceFolderCard, {
|
|
713
|
+
...card.props,
|
|
714
|
+
variant
|
|
715
|
+
});
|
|
716
|
+
return /* @__PURE__ */ jsx(ResourceCard, {
|
|
717
|
+
...card.props,
|
|
718
|
+
variant
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
function DatasourceToolResources({ resources, locale, className }) {
|
|
722
|
+
const cards = getDatasourceResourceCards(resources, locale);
|
|
723
|
+
return /* @__PURE__ */ jsx("section", {
|
|
690
724
|
"aria-label": "Recursos de la fuente de datos",
|
|
691
725
|
className: joinClasses("flex flex-wrap gap-3", className),
|
|
692
|
-
children:
|
|
693
|
-
const datasource = group[0]?.datasource;
|
|
694
|
-
const type = getLocalizedOpenGraphValue(folder, "type", locale) ?? readString(folder.extra_info, "type") ?? datasource?.type ?? "FOLDER";
|
|
695
|
-
const title = getLocalizedOpenGraphValue(folder, "title", locale) ?? folder.name;
|
|
696
|
-
const description = getLocalizedOpenGraphValue(folder, "description", locale) ?? readString(folder.extra_info, "description") ?? readString(folder.extra_info, "summary") ?? datasource?.description ?? datasource?.summary ?? "";
|
|
697
|
-
const icon = getLocalizedOpenGraphValue(folder, "image", locale);
|
|
698
|
-
const url = getLocalizedOpenGraphValue(folder, "url", locale);
|
|
699
|
-
return /* @__PURE__ */ jsx(DatasourceFolderCard, {
|
|
700
|
-
icon,
|
|
701
|
-
title,
|
|
702
|
-
description,
|
|
703
|
-
type: getLocalizedOpenGraphValue(folder, "type", locale) ?? type,
|
|
704
|
-
url,
|
|
705
|
-
resources: group.map((resource) => toResourceCardProps(resource, locale))
|
|
706
|
-
}, folder.id);
|
|
707
|
-
}), ungroupedResources.map((resource) => /* @__PURE__ */ jsx(ResourceCard, { ...toResourceCardProps(resource, locale) }, resource.id))]
|
|
726
|
+
children: cards.map((card) => /* @__PURE__ */ jsx(DatasourceResourceCardView, { card }, card.key))
|
|
708
727
|
});
|
|
709
728
|
}
|
|
710
729
|
|
|
730
|
+
//#endregion
|
|
731
|
+
//#region src/components/internal/tool-locale.ts
|
|
732
|
+
const SUPPORTED_TOOL_LOCALES = new Set([
|
|
733
|
+
"ca",
|
|
734
|
+
"da",
|
|
735
|
+
"de",
|
|
736
|
+
"en",
|
|
737
|
+
"es",
|
|
738
|
+
"fr",
|
|
739
|
+
"it",
|
|
740
|
+
"no",
|
|
741
|
+
"pt",
|
|
742
|
+
"sv"
|
|
743
|
+
]);
|
|
744
|
+
function getCurrentLocale() {
|
|
745
|
+
return typeof navigator === "undefined" ? "en" : navigator.language;
|
|
746
|
+
}
|
|
747
|
+
function getSupportedToolLocale(locale) {
|
|
748
|
+
const language = (locale ?? getCurrentLocale()).trim().toLowerCase().split(/[-_]/)[0];
|
|
749
|
+
const normalizedLanguage = language === "nb" || language === "nn" ? "no" : language;
|
|
750
|
+
return SUPPORTED_TOOL_LOCALES.has(normalizedLanguage) ? normalizedLanguage : "en";
|
|
751
|
+
}
|
|
752
|
+
|
|
711
753
|
//#endregion
|
|
712
754
|
//#region src/components/internal/format-tool-error-details.ts
|
|
713
755
|
function formatToolErrorDetails(value) {
|
|
@@ -730,26 +772,266 @@ function formatToolErrorDetails(value) {
|
|
|
730
772
|
}
|
|
731
773
|
|
|
732
774
|
//#endregion
|
|
733
|
-
//#region src/components/
|
|
734
|
-
|
|
735
|
-
"
|
|
736
|
-
|
|
737
|
-
"
|
|
738
|
-
"en",
|
|
739
|
-
"es",
|
|
740
|
-
"fr",
|
|
741
|
-
"it",
|
|
742
|
-
"no",
|
|
743
|
-
"pt",
|
|
744
|
-
"sv"
|
|
745
|
-
]);
|
|
746
|
-
function getCurrentLocale() {
|
|
747
|
-
return typeof navigator === "undefined" ? "en" : navigator.language;
|
|
775
|
+
//#region src/components/tool-result-web-search-card.tsx
|
|
776
|
+
function isWebSearchResult(value) {
|
|
777
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
778
|
+
const candidate = value;
|
|
779
|
+
return typeof candidate.title === "string" && typeof candidate.url === "string";
|
|
748
780
|
}
|
|
749
|
-
function
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
781
|
+
function toStringOrNull$2(value) {
|
|
782
|
+
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
|
783
|
+
}
|
|
784
|
+
function getHostname(url) {
|
|
785
|
+
try {
|
|
786
|
+
return new URL(url).hostname;
|
|
787
|
+
} catch {
|
|
788
|
+
return null;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
function getLegacyCitationResults(metadata) {
|
|
792
|
+
if (!Array.isArray(metadata.citations)) return [];
|
|
793
|
+
return metadata.citations.filter((citation) => typeof citation === "string").map((url) => ({
|
|
794
|
+
title: getHostname(url) ?? url,
|
|
795
|
+
url
|
|
796
|
+
}));
|
|
797
|
+
}
|
|
798
|
+
function getWebSearchResults(part) {
|
|
799
|
+
const searchResults = part.metadata?.search_results;
|
|
800
|
+
if (Array.isArray(searchResults)) {
|
|
801
|
+
const results = searchResults.filter(isWebSearchResult);
|
|
802
|
+
if (results.length > 0) return results;
|
|
803
|
+
}
|
|
804
|
+
return getLegacyCitationResults(part.metadata ?? {});
|
|
805
|
+
}
|
|
806
|
+
function getFaviconUrl(url) {
|
|
807
|
+
const hostname = getHostname(url);
|
|
808
|
+
return hostname ? `https://www.google.com/s2/favicons?domain=${encodeURIComponent(hostname)}&sz=32` : null;
|
|
809
|
+
}
|
|
810
|
+
function WebSearchResultItem({ result }) {
|
|
811
|
+
const hostname = getHostname(result.url);
|
|
812
|
+
const source = toStringOrNull$2(result.source);
|
|
813
|
+
const snippet = toStringOrNull$2(result.snippet);
|
|
814
|
+
const date = toStringOrNull$2(result.date) ?? toStringOrNull$2(result.last_updated);
|
|
815
|
+
const imageUrl = toStringOrNull$2(result.image_url);
|
|
816
|
+
const faviconUrl = getFaviconUrl(result.url);
|
|
817
|
+
return /* @__PURE__ */ jsx("article", {
|
|
818
|
+
className: "rounded-lg border border-neutral-200 bg-white p-4",
|
|
819
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
820
|
+
className: "flex items-start gap-3",
|
|
821
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
822
|
+
"aria-hidden": "true",
|
|
823
|
+
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",
|
|
824
|
+
children: [/* @__PURE__ */ jsx(Globe, { className: "h-4 w-4" }), faviconUrl ? /* @__PURE__ */ jsx("img", {
|
|
825
|
+
src: faviconUrl,
|
|
826
|
+
alt: "",
|
|
827
|
+
width: "16",
|
|
828
|
+
height: "16",
|
|
829
|
+
className: "absolute h-4 w-4 bg-white",
|
|
830
|
+
onError: (event) => {
|
|
831
|
+
event.currentTarget.style.display = "none";
|
|
832
|
+
}
|
|
833
|
+
}) : null]
|
|
834
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
835
|
+
className: "min-w-0 flex-1 space-y-1",
|
|
836
|
+
children: [
|
|
837
|
+
/* @__PURE__ */ jsx("a", {
|
|
838
|
+
href: result.url,
|
|
839
|
+
target: "_blank",
|
|
840
|
+
rel: "noreferrer noopener",
|
|
841
|
+
className: "block line-clamp-2 text-sm font-medium leading-5 text-neutral-950 hover:underline",
|
|
842
|
+
children: result.title
|
|
843
|
+
}),
|
|
844
|
+
/* @__PURE__ */ jsxs("div", {
|
|
845
|
+
className: "flex flex-wrap items-center gap-1.5 text-xs text-neutral-500",
|
|
846
|
+
children: [
|
|
847
|
+
date ? /* @__PURE__ */ jsx("span", { children: date }) : null,
|
|
848
|
+
source ? /* @__PURE__ */ jsx("span", {
|
|
849
|
+
className: "rounded-full bg-neutral-100 px-1.5 py-0.5 capitalize text-neutral-600",
|
|
850
|
+
children: source
|
|
851
|
+
}) : null,
|
|
852
|
+
!date && !source && hostname ? /* @__PURE__ */ jsx("span", { children: hostname }) : null
|
|
853
|
+
]
|
|
854
|
+
}),
|
|
855
|
+
snippet ? /* @__PURE__ */ jsx("p", {
|
|
856
|
+
className: "line-clamp-2 text-xs leading-5 text-neutral-600",
|
|
857
|
+
children: snippet
|
|
858
|
+
}) : null,
|
|
859
|
+
imageUrl ? /* @__PURE__ */ jsx("img", {
|
|
860
|
+
src: imageUrl,
|
|
861
|
+
alt: "",
|
|
862
|
+
className: "max-h-64 w-full rounded-md border border-neutral-200 object-contain",
|
|
863
|
+
loading: "lazy"
|
|
864
|
+
}) : null
|
|
865
|
+
]
|
|
866
|
+
})]
|
|
867
|
+
})
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
function ToolResultWebSearchCard({ part, className }) {
|
|
871
|
+
const searchResults = getWebSearchResults(part);
|
|
872
|
+
const errorDetails = formatToolErrorDetails(part.errorDetails);
|
|
873
|
+
const sourceLabel = searchResults.length === 1 ? "source" : "sources";
|
|
874
|
+
return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsxs(SheetTrigger, {
|
|
875
|
+
"aria-label": `Web: Internet search results, ${searchResults.length} ${sourceLabel}`,
|
|
876
|
+
className: joinClasses("plai-tool-result-web-search-card 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),
|
|
877
|
+
children: [
|
|
878
|
+
/* @__PURE__ */ jsxs("header", {
|
|
879
|
+
className: "flex items-center gap-3",
|
|
880
|
+
children: [/* @__PURE__ */ jsx(Globe, {
|
|
881
|
+
className: "h-5 w-5 shrink-0",
|
|
882
|
+
"aria-hidden": "true"
|
|
883
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
884
|
+
className: "text-base leading-5",
|
|
885
|
+
children: "WEB"
|
|
886
|
+
})]
|
|
887
|
+
}),
|
|
888
|
+
/* @__PURE__ */ jsx("h3", {
|
|
889
|
+
className: "mt-3 line-clamp-2 text-sm font-normal leading-5",
|
|
890
|
+
children: "Internet search results"
|
|
891
|
+
}),
|
|
892
|
+
/* @__PURE__ */ jsx("p", {
|
|
893
|
+
className: "mt-2 text-xs leading-4 text-neutral-600",
|
|
894
|
+
children: part.state === "pending" ? "Searching…" : `${searchResults.length} ${sourceLabel}`
|
|
895
|
+
})
|
|
896
|
+
]
|
|
897
|
+
}), /* @__PURE__ */ jsxs(SheetContent, {
|
|
898
|
+
closeLabel: "Close",
|
|
899
|
+
children: [/* @__PURE__ */ jsx(SheetHeader, {
|
|
900
|
+
className: "pr-10",
|
|
901
|
+
children: /* @__PURE__ */ jsx(SheetTitle, { children: "Internet search results" })
|
|
902
|
+
}), /* @__PURE__ */ jsx(ToolResultWebSearchResults, {
|
|
903
|
+
part,
|
|
904
|
+
searchResults,
|
|
905
|
+
errorDetails,
|
|
906
|
+
className: "mt-5"
|
|
907
|
+
})]
|
|
908
|
+
})] });
|
|
909
|
+
}
|
|
910
|
+
function ToolResultWebSearchResults({ part, searchResults = getWebSearchResults(part), errorDetails = formatToolErrorDetails(part.errorDetails), className }) {
|
|
911
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
912
|
+
className,
|
|
913
|
+
"aria-label": "Search results",
|
|
914
|
+
children: [searchResults.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
915
|
+
className: "space-y-3",
|
|
916
|
+
children: searchResults.map((result, index) => /* @__PURE__ */ jsx(WebSearchResultItem, { result }, `${result.url}-${index}`))
|
|
917
|
+
}) : part.state === "pending" ? /* @__PURE__ */ jsx("p", {
|
|
918
|
+
className: "text-sm text-neutral-600",
|
|
919
|
+
children: "Searching for sources…"
|
|
920
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
921
|
+
className: "text-sm text-neutral-600",
|
|
922
|
+
children: "No sources returned."
|
|
923
|
+
}), errorDetails ? /* @__PURE__ */ jsxs("p", {
|
|
924
|
+
className: "mt-4 rounded border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-700",
|
|
925
|
+
children: [
|
|
926
|
+
/* @__PURE__ */ jsx("span", {
|
|
927
|
+
className: "font-semibold",
|
|
928
|
+
children: "Error details:"
|
|
929
|
+
}),
|
|
930
|
+
" ",
|
|
931
|
+
errorDetails
|
|
932
|
+
]
|
|
933
|
+
}) : null]
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
//#endregion
|
|
938
|
+
//#region src/components/aggregated-source-results.tsx
|
|
939
|
+
const SOURCE_LABELS = {
|
|
940
|
+
en: ["source", "sources"],
|
|
941
|
+
es: ["fuente", "fuentes"],
|
|
942
|
+
ca: ["font", "fonts"],
|
|
943
|
+
fr: ["source", "sources"],
|
|
944
|
+
it: ["fonte", "fonti"],
|
|
945
|
+
de: ["Quelle", "Quellen"],
|
|
946
|
+
da: ["kilde", "kilder"],
|
|
947
|
+
sv: ["källa", "källor"],
|
|
948
|
+
no: ["kilde", "kilder"],
|
|
949
|
+
pt: ["fonte", "fontes"]
|
|
950
|
+
};
|
|
951
|
+
function isCompletedSourceToolPart(part) {
|
|
952
|
+
return part.type === "tool-call" && part.state === "completed" && (part.toolType === "datasource" || part.toolType === "perplexity" || part.toolType === "firecrawl_search");
|
|
953
|
+
}
|
|
954
|
+
function getDatasourceResources$1(part) {
|
|
955
|
+
const resources = part.metadata?.resources;
|
|
956
|
+
return Array.isArray(resources) ? resources.filter(isDatasourceResource) : [];
|
|
957
|
+
}
|
|
958
|
+
function getAggregatedCards(parts, locale) {
|
|
959
|
+
const datasourceCards = parts.filter((part) => part.toolType === "datasource").flatMap((part) => getDatasourceResourceCards(getDatasourceResources$1(part), locale).map((card) => ({
|
|
960
|
+
kind: "datasource",
|
|
961
|
+
key: `${part.id}-${card.key}`,
|
|
962
|
+
card
|
|
963
|
+
})));
|
|
964
|
+
const webCards = parts.filter((part) => part.toolType === "perplexity" || part.toolType === "firecrawl_search").map((part) => ({
|
|
965
|
+
kind: "web",
|
|
966
|
+
key: part.id,
|
|
967
|
+
part
|
|
968
|
+
}));
|
|
969
|
+
return [...datasourceCards, ...webCards];
|
|
970
|
+
}
|
|
971
|
+
function SourceCard({ source, variant = "card" }) {
|
|
972
|
+
if (source.kind === "datasource") return /* @__PURE__ */ jsx(DatasourceResourceCardView, {
|
|
973
|
+
card: source.card,
|
|
974
|
+
variant
|
|
975
|
+
});
|
|
976
|
+
if (variant === "card") return /* @__PURE__ */ jsx(ToolResultWebSearchCard, { part: source.part });
|
|
977
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
978
|
+
className: "rounded-lg bg-neutral-100 p-4",
|
|
979
|
+
children: [/* @__PURE__ */ jsxs("header", {
|
|
980
|
+
className: "mb-4 flex items-center gap-3",
|
|
981
|
+
children: [/* @__PURE__ */ jsx(Globe, {
|
|
982
|
+
className: "h-5 w-5 shrink-0",
|
|
983
|
+
"aria-hidden": "true"
|
|
984
|
+
}), /* @__PURE__ */ jsx("h3", {
|
|
985
|
+
className: "text-sm font-medium",
|
|
986
|
+
children: "Internet search results"
|
|
987
|
+
})]
|
|
988
|
+
}), /* @__PURE__ */ jsx(ToolResultWebSearchResults, { part: source.part })]
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
function getTotalSourceCount(cards) {
|
|
992
|
+
return cards.reduce((count, source) => count + (source.kind === "web" ? getWebSearchResults(source.part).length : 1), 0);
|
|
993
|
+
}
|
|
994
|
+
function AggregatedSourceResults({ parts, locale, maxVisible = 3, className }) {
|
|
995
|
+
const cards = getAggregatedCards(parts, locale);
|
|
996
|
+
if (cards.length === 0) return null;
|
|
997
|
+
const visibleLimit = Number.isFinite(maxVisible) && maxVisible >= 1 ? Math.floor(maxVisible) : 3;
|
|
998
|
+
const visibleCards = cards.slice(0, visibleLimit);
|
|
999
|
+
const overflowCount = cards.length - visibleCards.length;
|
|
1000
|
+
const totalSourceCount = getTotalSourceCount(cards);
|
|
1001
|
+
const [singularSource, pluralSources] = SOURCE_LABELS[getSupportedToolLocale(locale)];
|
|
1002
|
+
const overflowLabel = overflowCount === 1 ? singularSource : pluralSources;
|
|
1003
|
+
const totalLabel = totalSourceCount === 1 ? singularSource : pluralSources;
|
|
1004
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
1005
|
+
"aria-label": pluralSources,
|
|
1006
|
+
className: joinClasses("flex flex-wrap gap-3", className),
|
|
1007
|
+
children: [visibleCards.map((source) => /* @__PURE__ */ jsx(SourceCard, { source }, source.key)), overflowCount > 0 ? /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsxs(SheetTrigger, {
|
|
1008
|
+
"aria-label": `+${overflowCount} ${overflowLabel}`,
|
|
1009
|
+
className: "flex min-h-[183px] w-[186px] max-w-full flex-col justify-center 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",
|
|
1010
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
1011
|
+
className: "text-2xl font-medium leading-7",
|
|
1012
|
+
children: ["+", overflowCount]
|
|
1013
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1014
|
+
className: "mt-2 text-sm leading-5",
|
|
1015
|
+
children: overflowLabel
|
|
1016
|
+
})]
|
|
1017
|
+
}), /* @__PURE__ */ jsxs(SheetContent, {
|
|
1018
|
+
closeLabel: "Close",
|
|
1019
|
+
children: [/* @__PURE__ */ jsx(SheetHeader, {
|
|
1020
|
+
className: "pr-10",
|
|
1021
|
+
children: /* @__PURE__ */ jsxs(SheetTitle, { children: [
|
|
1022
|
+
totalSourceCount,
|
|
1023
|
+
" ",
|
|
1024
|
+
totalLabel
|
|
1025
|
+
] })
|
|
1026
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1027
|
+
className: "mt-5 space-y-3",
|
|
1028
|
+
children: cards.map((source) => /* @__PURE__ */ jsx(SourceCard, {
|
|
1029
|
+
source,
|
|
1030
|
+
variant: "list"
|
|
1031
|
+
}, `sheet-${source.key}`))
|
|
1032
|
+
})]
|
|
1033
|
+
})] }) : null]
|
|
1034
|
+
});
|
|
753
1035
|
}
|
|
754
1036
|
|
|
755
1037
|
//#endregion
|
|
@@ -904,7 +1186,7 @@ function asObject(value) {
|
|
|
904
1186
|
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
905
1187
|
return value;
|
|
906
1188
|
}
|
|
907
|
-
function toStringOrNull$
|
|
1189
|
+
function toStringOrNull$1(value) {
|
|
908
1190
|
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
|
909
1191
|
}
|
|
910
1192
|
function toNumberOrNull(value) {
|
|
@@ -919,8 +1201,8 @@ function parseEmailSendInput(part) {
|
|
|
919
1201
|
};
|
|
920
1202
|
return {
|
|
921
1203
|
to: Array.isArray(input.to) ? input.to.filter((item) => typeof item === "string") : [],
|
|
922
|
-
subject: toStringOrNull$
|
|
923
|
-
text: toStringOrNull$
|
|
1204
|
+
subject: toStringOrNull$1(input.subject),
|
|
1205
|
+
text: toStringOrNull$1(input.text)
|
|
924
1206
|
};
|
|
925
1207
|
}
|
|
926
1208
|
function parseEmailSendResult(part) {
|
|
@@ -947,12 +1229,12 @@ function parseEmailSendResult(part) {
|
|
|
947
1229
|
};
|
|
948
1230
|
const receipt = asObject(resultObject.receipt);
|
|
949
1231
|
return {
|
|
950
|
-
status: toStringOrNull$
|
|
1232
|
+
status: toStringOrNull$1(resultObject.status),
|
|
951
1233
|
recipientsCount: toNumberOrNull(resultObject.recipients_count),
|
|
952
|
-
subject: toStringOrNull$
|
|
953
|
-
receiptProvider: receipt ? toStringOrNull$
|
|
954
|
-
receiptMessageId: receipt ? toStringOrNull$
|
|
955
|
-
receiptRawStatus: receipt ? toStringOrNull$
|
|
1234
|
+
subject: toStringOrNull$1(resultObject.subject),
|
|
1235
|
+
receiptProvider: receipt ? toStringOrNull$1(receipt.provider) : null,
|
|
1236
|
+
receiptMessageId: receipt ? toStringOrNull$1(receipt.message_id) : null,
|
|
1237
|
+
receiptRawStatus: receipt ? toStringOrNull$1(receipt.raw_status) : null,
|
|
956
1238
|
raw
|
|
957
1239
|
};
|
|
958
1240
|
}
|
|
@@ -1370,7 +1652,7 @@ function ToolResultBrowserCard({ part, className }) {
|
|
|
1370
1652
|
function isRecord(value) {
|
|
1371
1653
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
1372
1654
|
}
|
|
1373
|
-
function toStringOrNull
|
|
1655
|
+
function toStringOrNull(value) {
|
|
1374
1656
|
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
|
1375
1657
|
}
|
|
1376
1658
|
function formatCell(value) {
|
|
@@ -1437,7 +1719,7 @@ function formatStatus(state) {
|
|
|
1437
1719
|
return "completed";
|
|
1438
1720
|
}
|
|
1439
1721
|
function ToolResultExternalDatasourceCard({ part, className }) {
|
|
1440
|
-
const sqlQuery = toStringOrNull
|
|
1722
|
+
const sqlQuery = toStringOrNull(part.metadata?.sql_query);
|
|
1441
1723
|
const table = normalizeTable(getTableValue(part));
|
|
1442
1724
|
const errorDetails = formatToolErrorDetails(part.errorDetails);
|
|
1443
1725
|
const statusClass = part.state === "error" ? "text-rose-600" : part.state === "pending" ? "text-amber-600" : "text-emerald-600";
|
|
@@ -1874,161 +2156,6 @@ function ToolResultOfficeDocumentsCard({ part, className }) {
|
|
|
1874
2156
|
})] });
|
|
1875
2157
|
}
|
|
1876
2158
|
|
|
1877
|
-
//#endregion
|
|
1878
|
-
//#region src/components/tool-result-web-search-card.tsx
|
|
1879
|
-
function isWebSearchResult(value) {
|
|
1880
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
1881
|
-
const candidate = value;
|
|
1882
|
-
return typeof candidate.title === "string" && typeof candidate.url === "string";
|
|
1883
|
-
}
|
|
1884
|
-
function toStringOrNull(value) {
|
|
1885
|
-
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
|
1886
|
-
}
|
|
1887
|
-
function getHostname(url) {
|
|
1888
|
-
try {
|
|
1889
|
-
return new URL(url).hostname;
|
|
1890
|
-
} catch {
|
|
1891
|
-
return null;
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
function getLegacyCitationResults(metadata) {
|
|
1895
|
-
if (!Array.isArray(metadata.citations)) return [];
|
|
1896
|
-
return metadata.citations.filter((citation) => typeof citation === "string").map((url) => ({
|
|
1897
|
-
title: getHostname(url) ?? url,
|
|
1898
|
-
url
|
|
1899
|
-
}));
|
|
1900
|
-
}
|
|
1901
|
-
function getSearchResults(part) {
|
|
1902
|
-
const searchResults = part.metadata?.search_results;
|
|
1903
|
-
if (Array.isArray(searchResults)) {
|
|
1904
|
-
const results = searchResults.filter(isWebSearchResult);
|
|
1905
|
-
if (results.length > 0) return results;
|
|
1906
|
-
}
|
|
1907
|
-
return getLegacyCitationResults(part.metadata ?? {});
|
|
1908
|
-
}
|
|
1909
|
-
function getFaviconUrl(url) {
|
|
1910
|
-
const hostname = getHostname(url);
|
|
1911
|
-
return hostname ? `https://www.google.com/s2/favicons?domain=${encodeURIComponent(hostname)}&sz=32` : null;
|
|
1912
|
-
}
|
|
1913
|
-
function WebSearchResultItem({ result }) {
|
|
1914
|
-
const hostname = getHostname(result.url);
|
|
1915
|
-
const source = toStringOrNull(result.source);
|
|
1916
|
-
const snippet = toStringOrNull(result.snippet);
|
|
1917
|
-
const date = toStringOrNull(result.date) ?? toStringOrNull(result.last_updated);
|
|
1918
|
-
const imageUrl = toStringOrNull(result.image_url);
|
|
1919
|
-
const faviconUrl = getFaviconUrl(result.url);
|
|
1920
|
-
return /* @__PURE__ */ jsx("article", {
|
|
1921
|
-
className: "rounded-lg border border-neutral-200 bg-white p-4",
|
|
1922
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
1923
|
-
className: "flex items-start gap-3",
|
|
1924
|
-
children: [/* @__PURE__ */ jsxs("span", {
|
|
1925
|
-
"aria-hidden": "true",
|
|
1926
|
-
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",
|
|
1927
|
-
children: [/* @__PURE__ */ jsx(Globe, { className: "h-4 w-4" }), faviconUrl ? /* @__PURE__ */ jsx("img", {
|
|
1928
|
-
src: faviconUrl,
|
|
1929
|
-
alt: "",
|
|
1930
|
-
width: "16",
|
|
1931
|
-
height: "16",
|
|
1932
|
-
className: "absolute h-4 w-4 bg-white",
|
|
1933
|
-
onError: (event) => {
|
|
1934
|
-
event.currentTarget.style.display = "none";
|
|
1935
|
-
}
|
|
1936
|
-
}) : null]
|
|
1937
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
1938
|
-
className: "min-w-0 flex-1 space-y-1",
|
|
1939
|
-
children: [
|
|
1940
|
-
/* @__PURE__ */ jsx("a", {
|
|
1941
|
-
href: result.url,
|
|
1942
|
-
target: "_blank",
|
|
1943
|
-
rel: "noreferrer noopener",
|
|
1944
|
-
className: "block line-clamp-2 text-sm font-medium leading-5 text-neutral-950 hover:underline",
|
|
1945
|
-
children: result.title
|
|
1946
|
-
}),
|
|
1947
|
-
/* @__PURE__ */ jsxs("div", {
|
|
1948
|
-
className: "flex flex-wrap items-center gap-1.5 text-xs text-neutral-500",
|
|
1949
|
-
children: [
|
|
1950
|
-
date ? /* @__PURE__ */ jsx("span", { children: date }) : null,
|
|
1951
|
-
source ? /* @__PURE__ */ jsx("span", {
|
|
1952
|
-
className: "rounded-full bg-neutral-100 px-1.5 py-0.5 capitalize text-neutral-600",
|
|
1953
|
-
children: source
|
|
1954
|
-
}) : null,
|
|
1955
|
-
!date && !source && hostname ? /* @__PURE__ */ jsx("span", { children: hostname }) : null
|
|
1956
|
-
]
|
|
1957
|
-
}),
|
|
1958
|
-
snippet ? /* @__PURE__ */ jsx("p", {
|
|
1959
|
-
className: "line-clamp-2 text-xs leading-5 text-neutral-600",
|
|
1960
|
-
children: snippet
|
|
1961
|
-
}) : null,
|
|
1962
|
-
imageUrl ? /* @__PURE__ */ jsx("img", {
|
|
1963
|
-
src: imageUrl,
|
|
1964
|
-
alt: "",
|
|
1965
|
-
className: "max-h-64 w-full rounded-md border border-neutral-200 object-contain",
|
|
1966
|
-
loading: "lazy"
|
|
1967
|
-
}) : null
|
|
1968
|
-
]
|
|
1969
|
-
})]
|
|
1970
|
-
})
|
|
1971
|
-
});
|
|
1972
|
-
}
|
|
1973
|
-
function ToolResultWebSearchCard({ part, className }) {
|
|
1974
|
-
const searchResults = getSearchResults(part);
|
|
1975
|
-
const errorDetails = formatToolErrorDetails(part.errorDetails);
|
|
1976
|
-
const sourceLabel = searchResults.length === 1 ? "source" : "sources";
|
|
1977
|
-
return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsxs(SheetTrigger, {
|
|
1978
|
-
"aria-label": `Web: Internet search results, ${searchResults.length} ${sourceLabel}`,
|
|
1979
|
-
className: joinClasses("plai-tool-result-web-search-card 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),
|
|
1980
|
-
children: [
|
|
1981
|
-
/* @__PURE__ */ jsxs("header", {
|
|
1982
|
-
className: "flex items-center gap-3",
|
|
1983
|
-
children: [/* @__PURE__ */ jsx(Globe, {
|
|
1984
|
-
className: "h-5 w-5 shrink-0",
|
|
1985
|
-
"aria-hidden": "true"
|
|
1986
|
-
}), /* @__PURE__ */ jsx("p", {
|
|
1987
|
-
className: "text-base leading-5",
|
|
1988
|
-
children: "WEB"
|
|
1989
|
-
})]
|
|
1990
|
-
}),
|
|
1991
|
-
/* @__PURE__ */ jsx("h3", {
|
|
1992
|
-
className: "mt-3 line-clamp-2 text-sm font-normal leading-5",
|
|
1993
|
-
children: "Internet search results"
|
|
1994
|
-
}),
|
|
1995
|
-
/* @__PURE__ */ jsx("p", {
|
|
1996
|
-
className: "mt-2 text-xs leading-4 text-neutral-600",
|
|
1997
|
-
children: part.state === "pending" ? "Searching…" : `${searchResults.length} ${sourceLabel}`
|
|
1998
|
-
})
|
|
1999
|
-
]
|
|
2000
|
-
}), /* @__PURE__ */ jsxs(SheetContent, {
|
|
2001
|
-
closeLabel: "Close",
|
|
2002
|
-
children: [/* @__PURE__ */ jsx(SheetHeader, {
|
|
2003
|
-
className: "pr-10",
|
|
2004
|
-
children: /* @__PURE__ */ jsx(SheetTitle, { children: "Internet search results" })
|
|
2005
|
-
}), /* @__PURE__ */ jsxs("section", {
|
|
2006
|
-
className: "mt-5",
|
|
2007
|
-
"aria-label": "Search results",
|
|
2008
|
-
children: [searchResults.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
2009
|
-
className: "space-y-3",
|
|
2010
|
-
children: searchResults.map((result, index) => /* @__PURE__ */ jsx(WebSearchResultItem, { result }, `${result.url}-${index}`))
|
|
2011
|
-
}) : part.state === "pending" ? /* @__PURE__ */ jsx("p", {
|
|
2012
|
-
className: "text-sm text-neutral-600",
|
|
2013
|
-
children: "Searching for sources…"
|
|
2014
|
-
}) : /* @__PURE__ */ jsx("p", {
|
|
2015
|
-
className: "text-sm text-neutral-600",
|
|
2016
|
-
children: "No sources returned."
|
|
2017
|
-
}), errorDetails ? /* @__PURE__ */ jsxs("p", {
|
|
2018
|
-
className: "mt-4 rounded border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-700",
|
|
2019
|
-
children: [
|
|
2020
|
-
/* @__PURE__ */ jsx("span", {
|
|
2021
|
-
className: "font-semibold",
|
|
2022
|
-
children: "Error details:"
|
|
2023
|
-
}),
|
|
2024
|
-
" ",
|
|
2025
|
-
errorDetails
|
|
2026
|
-
]
|
|
2027
|
-
}) : null]
|
|
2028
|
-
})]
|
|
2029
|
-
})] });
|
|
2030
|
-
}
|
|
2031
|
-
|
|
2032
2159
|
//#endregion
|
|
2033
2160
|
//#region src/components/tool-result-workflow-dispatch-card.tsx
|
|
2034
2161
|
function parseResult(value) {
|
|
@@ -2375,6 +2502,7 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
|
|
|
2375
2502
|
locale,
|
|
2376
2503
|
className
|
|
2377
2504
|
});
|
|
2505
|
+
if (part.toolType === "datasource") return null;
|
|
2378
2506
|
return /* @__PURE__ */ jsxs("section", {
|
|
2379
2507
|
className: joinClasses("space-y-3 rounded-lg border border-slate-200 bg-slate-50 p-3", className),
|
|
2380
2508
|
"data-tool-call-id": part.id,
|
|
@@ -2665,14 +2793,51 @@ function orderMessageParts(parts, position) {
|
|
|
2665
2793
|
else remainingParts.push(indexedPart);
|
|
2666
2794
|
return [...datasourceParts, ...remainingParts];
|
|
2667
2795
|
}
|
|
2668
|
-
function
|
|
2796
|
+
function aggregateSourceToolParts(parts, position) {
|
|
2797
|
+
const indexedParts = parts.map((part, index) => ({
|
|
2798
|
+
kind: "part",
|
|
2799
|
+
part,
|
|
2800
|
+
index
|
|
2801
|
+
}));
|
|
2802
|
+
const sourceParts = indexedParts.flatMap(({ part, index }) => isCompletedSourceToolPart(part) ? [{
|
|
2803
|
+
part,
|
|
2804
|
+
index
|
|
2805
|
+
}] : []);
|
|
2806
|
+
if (sourceParts.length === 0) return indexedParts;
|
|
2807
|
+
const sourceIndexes = new Set(sourceParts.map(({ index }) => index));
|
|
2808
|
+
const remainingParts = indexedParts.filter(({ index }) => !sourceIndexes.has(index));
|
|
2809
|
+
const sourceResults = {
|
|
2810
|
+
kind: "source-results",
|
|
2811
|
+
parts: sourceParts.map(({ part }) => part),
|
|
2812
|
+
index: sourceParts[0].index
|
|
2813
|
+
};
|
|
2814
|
+
if (position === "before-content") return [sourceResults, ...remainingParts];
|
|
2815
|
+
const insertionIndex = remainingParts.findIndex(({ index }) => index > sourceResults.index);
|
|
2816
|
+
if (insertionIndex === -1) return [...remainingParts, sourceResults];
|
|
2817
|
+
return [
|
|
2818
|
+
...remainingParts.slice(0, insertionIndex),
|
|
2819
|
+
sourceResults,
|
|
2820
|
+
...remainingParts.slice(insertionIndex)
|
|
2821
|
+
];
|
|
2822
|
+
}
|
|
2823
|
+
function MessageParts({ message, collapseThreshold = DEFAULT_COLLAPSE_THRESHOLD, sourceToolResultsLayout = "aggregated", sourceToolResultsPosition, maxVisibleSourceCards = 3, datasourceToolResultsPosition, onOpenAgentThread, locale, renderText, renderToolCall, renderThinking, isStreaming = false, thinkingLabel, completedThinkingLabel, readMoreLabel = "Read more", readLessLabel = "Read less", className,...props }) {
|
|
2669
2824
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
2670
2825
|
const textContent = useMemo(() => message.parts.filter((part) => part.type === "text").map((part) => part.text).join("\n"), [message.parts]);
|
|
2671
2826
|
const canCollapse = message.role === "user" && message.parts.every((part) => part.type === "text") && textContent.length > collapseThreshold;
|
|
2672
2827
|
const previewText = canCollapse ? `${textContent.slice(0, collapseThreshold).trimEnd()}...` : textContent;
|
|
2673
2828
|
const textClassName = getMessageTextClassName(message.role);
|
|
2674
2829
|
const textAlignmentClassName = getMessageTextAlignmentClassName(message.role);
|
|
2675
|
-
const
|
|
2830
|
+
const resolvedSourceResultsPosition = sourceToolResultsPosition ?? datasourceToolResultsPosition ?? (sourceToolResultsLayout === "aggregated" && !renderToolCall ? "before-content" : "inline");
|
|
2831
|
+
const shouldAggregateSourceResults = message.role === "assistant" && sourceToolResultsLayout === "aggregated" && !renderToolCall;
|
|
2832
|
+
const orderedParts = useMemo(() => shouldAggregateSourceResults ? aggregateSourceToolParts(message.parts, resolvedSourceResultsPosition) : orderMessageParts(message.parts, resolvedSourceResultsPosition).map(({ part, index }) => ({
|
|
2833
|
+
kind: "part",
|
|
2834
|
+
part,
|
|
2835
|
+
index
|
|
2836
|
+
})), [
|
|
2837
|
+
message.parts,
|
|
2838
|
+
resolvedSourceResultsPosition,
|
|
2839
|
+
shouldAggregateSourceResults
|
|
2840
|
+
]);
|
|
2676
2841
|
return /* @__PURE__ */ jsxs("div", {
|
|
2677
2842
|
className: joinClasses("space-y-2", textAlignmentClassName, className),
|
|
2678
2843
|
"data-message-role": message.role,
|
|
@@ -2680,7 +2845,11 @@ function MessageParts({ message, collapseThreshold = DEFAULT_COLLAPSE_THRESHOLD,
|
|
|
2680
2845
|
children: [canCollapse && !isExpanded ? /* @__PURE__ */ jsx("p", {
|
|
2681
2846
|
className: textClassName,
|
|
2682
2847
|
children: previewText
|
|
2683
|
-
}) : orderedParts.map((
|
|
2848
|
+
}) : orderedParts.map((item) => item.kind === "source-results" ? /* @__PURE__ */ jsx(AggregatedSourceResults, {
|
|
2849
|
+
parts: item.parts,
|
|
2850
|
+
locale,
|
|
2851
|
+
maxVisible: maxVisibleSourceCards
|
|
2852
|
+
}, `source-results-${item.index}`) : renderPart(item.part, item.index, message, isStreaming, onOpenAgentThread, locale, renderText, renderToolCall, renderThinking, thinkingLabel, completedThinkingLabel, textClassName)), canCollapse ? /* @__PURE__ */ jsx("button", {
|
|
2684
2853
|
type: "button",
|
|
2685
2854
|
className: "text-xs font-medium text-slate-600 hover:text-slate-900",
|
|
2686
2855
|
onClick: () => setIsExpanded((previous) => !previous),
|
|
@@ -3279,5 +3448,5 @@ async function dummyTranscribeAudio(_audio, signal) {
|
|
|
3279
3448
|
}
|
|
3280
3449
|
|
|
3281
3450
|
//#endregion
|
|
3282
|
-
export { ArrowUp, Clipboard, DatasourceFolderCard, DatasourceToolResources, DatasourceToolResultCard, Loader, Message, MessageAvatar, MessageContent, MessageFooter, MessageHeader, MessageParts, Microphone, PROMPT_FORM_FILE_ACCEPT, Paperclip, PromptForm, PromptFormAttachButton, PromptFormIconButton, Reload, ResourceCard, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, SpeechToTextToggle, Stop, Thinking, ThumbDown, ThumbUp, ToolError, ToolResultAgentInvocationCard, ToolResultBrowserCard, ToolResultCard, ToolResultExternalDatasourceCard, ToolResultHttpRequestCard, ToolResultMcpCard, ToolResultOfficeDocumentsCard, ToolResultWebSearchCard, ToolResultWorkflowDispatchCard, ToolUseIndicator, X, dummyTranscribeAudio, getLocalizedOpenGraphValue, getResourceDescription, getResourceIcon, getResourceOpenGraphImage, getResourceOpenGraphType, getResourceTitle, getResourceType, getResourceUrl, getToolUseLabel, isAllowedPromptFormFile, partitionPromptFormFiles, useSpeechToText };
|
|
3451
|
+
export { AggregatedSourceResults, ArrowUp, Clipboard, DatasourceFolderCard, DatasourceToolResources, DatasourceToolResultCard, Loader, Message, MessageAvatar, MessageContent, MessageFooter, MessageHeader, MessageParts, Microphone, PROMPT_FORM_FILE_ACCEPT, Paperclip, PromptForm, PromptFormAttachButton, PromptFormIconButton, Reload, ResourceCard, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, SpeechToTextToggle, Stop, Thinking, ThumbDown, ThumbUp, ToolError, ToolResultAgentInvocationCard, ToolResultBrowserCard, ToolResultCard, ToolResultExternalDatasourceCard, ToolResultHttpRequestCard, ToolResultMcpCard, ToolResultOfficeDocumentsCard, ToolResultWebSearchCard, ToolResultWorkflowDispatchCard, ToolUseIndicator, X, dummyTranscribeAudio, getLocalizedOpenGraphValue, getResourceDescription, getResourceIcon, getResourceOpenGraphImage, getResourceOpenGraphType, getResourceTitle, getResourceType, getResourceUrl, getToolUseLabel, isAllowedPromptFormFile, partitionPromptFormFiles, useSpeechToText };
|
|
3283
3452
|
//# sourceMappingURL=index.js.map
|