@plaisolutions/react 0.8.3 → 0.8.5

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,6 +1,6 @@
1
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, Brain, Check, CheckCircle2, ChevronDown, Copy, Database, File, FileText, Globe, LoaderCircle, MessageSquare, Minus, Plug, Plus, RotateCcw, ThumbsDown, ThumbsUp, Workflow, XCircle } from "lucide-react";
3
+ 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";
4
4
 
5
5
  //#region src/components/internal/join-classes.ts
6
6
  function joinClasses(...classes) {
@@ -115,18 +115,19 @@ function ResourceCardContent({ icon, type, title, description }) {
115
115
  ] });
116
116
  }
117
117
  function ResourceCard(props) {
118
- const className = "block w-full rounded-lg bg-neutral-100 p-4 text-left text-neutral-950";
119
- if (!props.url) return /* @__PURE__ */ jsx("article", {
120
- "aria-label": `${props.title}: ${props.description}`,
118
+ const { className: customClassName, variant = "card",...contentProps } = props;
119
+ const className = joinClasses("block rounded-lg bg-neutral-100 p-4 text-left text-neutral-950", variant === "card" ? "min-h-[183px] w-[186px] max-w-full" : "w-full", customClassName);
120
+ if (!contentProps.url) return /* @__PURE__ */ jsx("article", {
121
+ "aria-label": `${contentProps.title}: ${contentProps.description}`,
121
122
  className,
122
- children: /* @__PURE__ */ jsx(ResourceCardContent, { ...props })
123
+ children: /* @__PURE__ */ jsx(ResourceCardContent, { ...contentProps })
123
124
  });
124
125
  return /* @__PURE__ */ jsx("a", {
125
- href: props.url,
126
+ href: contentProps.url,
126
127
  target: "_blank",
127
128
  rel: "noreferrer noopener",
128
129
  className: `${className} transition-colors hover:bg-neutral-200 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950`,
129
- children: /* @__PURE__ */ jsx(ResourceCardContent, { ...props })
130
+ children: /* @__PURE__ */ jsx(ResourceCardContent, { ...contentProps })
130
131
  });
131
132
  }
132
133
 
@@ -483,7 +484,7 @@ const SheetDescription = forwardRef(function SheetDescription$1({ className, id,
483
484
  function DatasourceFolderCard({ icon, title, description, type, url, resources }) {
484
485
  return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsx(SheetTrigger, {
485
486
  "aria-label": `${type}: ${title}`,
486
- 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",
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
488
  children: /* @__PURE__ */ jsx(DatasourceToolResultCardContent, {
488
489
  icon,
489
490
  title,
@@ -527,7 +528,10 @@ function DatasourceFolderCard({ icon, title, description, type, url, resources }
527
528
  children: "Ver"
528
529
  }), /* @__PURE__ */ jsx("div", {
529
530
  className: "mt-7 space-y-3",
530
- children: resources.map((resource, index) => /* @__PURE__ */ jsx(ResourceCard, { ...resource }, `${resource.url ?? resource.title}-${index}`))
531
+ children: resources.map((resource, index) => /* @__PURE__ */ jsx(ResourceCard, {
532
+ ...resource,
533
+ variant: "list"
534
+ }, `${resource.url ?? resource.title}-${index}`))
531
535
  })]
532
536
  })]
533
537
  })] });
@@ -538,7 +542,7 @@ function DatasourceFolderCard({ icon, title, description, type, url, resources }
538
542
  function normalizeLocale(locale) {
539
543
  return locale?.trim().toLowerCase();
540
544
  }
541
- function getCurrentLocale() {
545
+ function getCurrentLocale$1() {
542
546
  if (typeof document !== "undefined" && document.documentElement.lang) return document.documentElement.lang;
543
547
  if (typeof navigator !== "undefined") return navigator.language || navigator.userLanguage;
544
548
  }
@@ -558,7 +562,7 @@ function getTranslation(translations, locale) {
558
562
  function getLocalizedOpenGraphValue(container, field, locale) {
559
563
  const opengraph = container.extra_info?.opengraph;
560
564
  if (!opengraph) return void 0;
561
- for (const candidate of getLocaleCandidates(locale ?? getCurrentLocale())) {
565
+ for (const candidate of getLocaleCandidates(locale ?? getCurrentLocale$1())) {
562
566
  const translated = getTranslation(opengraph.translations, candidate)?.[field];
563
567
  if (hasStringValue(translated)) return translated.trim();
564
568
  }
@@ -725,6 +729,170 @@ function formatToolErrorDetails(value) {
725
729
  }
726
730
  }
727
731
 
732
+ //#endregion
733
+ //#region src/components/internal/tool-locale.ts
734
+ const SUPPORTED_TOOL_LOCALES = new Set([
735
+ "ca",
736
+ "da",
737
+ "de",
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;
748
+ }
749
+ function getSupportedToolLocale(locale) {
750
+ const language = (locale ?? getCurrentLocale()).trim().toLowerCase().split(/[-_]/)[0];
751
+ const normalizedLanguage = language === "nb" || language === "nn" ? "no" : language;
752
+ return SUPPORTED_TOOL_LOCALES.has(normalizedLanguage) ? normalizedLanguage : "en";
753
+ }
754
+
755
+ //#endregion
756
+ //#region src/components/tool-error.tsx
757
+ const TOOL_ERROR_TRANSLATIONS = {
758
+ en: {
759
+ summary: "Failed to use tool {{toolName}}",
760
+ input: "Input",
761
+ output: "Output",
762
+ details: "Error details",
763
+ noOutput: "No output available"
764
+ },
765
+ es: {
766
+ summary: "Falló al usar la tool {{toolName}}",
767
+ input: "Entrada",
768
+ output: "Salida",
769
+ details: "Detalles del error",
770
+ noOutput: "No hay salida disponible"
771
+ },
772
+ ca: {
773
+ summary: "No s’ha pogut utilitzar l’eina {{toolName}}",
774
+ input: "Entrada",
775
+ output: "Sortida",
776
+ details: "Detalls de l’error",
777
+ noOutput: "No hi ha cap sortida disponible"
778
+ },
779
+ fr: {
780
+ summary: "Échec de l’utilisation de l’outil {{toolName}}",
781
+ input: "Entrée",
782
+ output: "Sortie",
783
+ details: "Détails de l’erreur",
784
+ noOutput: "Aucune sortie disponible"
785
+ },
786
+ it: {
787
+ summary: "Impossibile utilizzare lo strumento {{toolName}}",
788
+ input: "Input",
789
+ output: "Output",
790
+ details: "Dettagli dell’errore",
791
+ noOutput: "Nessun output disponibile"
792
+ },
793
+ de: {
794
+ summary: "Tool {{toolName}} konnte nicht verwendet werden",
795
+ input: "Eingabe",
796
+ output: "Ausgabe",
797
+ details: "Fehlerdetails",
798
+ noOutput: "Keine Ausgabe verfügbar"
799
+ },
800
+ da: {
801
+ summary: "Kunne ikke bruge værktøjet {{toolName}}",
802
+ input: "Input",
803
+ output: "Output",
804
+ details: "Fejldetaljer",
805
+ noOutput: "Intet output tilgængeligt"
806
+ },
807
+ sv: {
808
+ summary: "Det gick inte att använda verktyget {{toolName}}",
809
+ input: "Indata",
810
+ output: "Utdata",
811
+ details: "Feldetaljer",
812
+ noOutput: "Ingen utdata tillgänglig"
813
+ },
814
+ no: {
815
+ summary: "Kunne ikke bruke verktøyet {{toolName}}",
816
+ input: "Inndata",
817
+ output: "Utdata",
818
+ details: "Feildetaljer",
819
+ noOutput: "Ingen utdata tilgjengelig"
820
+ },
821
+ pt: {
822
+ summary: "Falha ao usar a ferramenta {{toolName}}",
823
+ input: "Entrada",
824
+ output: "Saída",
825
+ details: "Detalhes do erro",
826
+ noOutput: "Nenhuma saída disponível"
827
+ }
828
+ };
829
+ function formatJson$1(value) {
830
+ return JSON.stringify(value, null, 2) ?? String(value);
831
+ }
832
+ function getToolErrorCopy(part, locale) {
833
+ const copy = TOOL_ERROR_TRANSLATIONS[getSupportedToolLocale(locale)];
834
+ return {
835
+ ...copy,
836
+ summary: copy.summary.replaceAll("{{toolName}}", part.name)
837
+ };
838
+ }
839
+ function ToolError({ part, locale, defaultOpen = false, className,...props }) {
840
+ const [isOpen, setIsOpen] = useState(defaultOpen);
841
+ const contentId = useId();
842
+ const copy = getToolErrorCopy(part, locale);
843
+ const errorDetails = formatToolErrorDetails(part.errorDetails);
844
+ return /* @__PURE__ */ jsxs("section", {
845
+ className: joinClasses("text-sm text-neutral-600", className),
846
+ "data-tool-call-id": part.id,
847
+ "data-tool-call-state": part.state,
848
+ ...props,
849
+ children: [/* @__PURE__ */ jsxs("button", {
850
+ type: "button",
851
+ "aria-controls": contentId,
852
+ "aria-expanded": isOpen,
853
+ className: "inline-flex items-center gap-2 rounded-md py-1 text-left font-medium text-rose-600 transition-colors hover:text-rose-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950",
854
+ onClick: () => setIsOpen((value) => !value),
855
+ children: [
856
+ /* @__PURE__ */ jsx(CircleX, {
857
+ className: "size-4 shrink-0",
858
+ "aria-hidden": "true"
859
+ }),
860
+ /* @__PURE__ */ jsx("span", { children: copy.summary }),
861
+ /* @__PURE__ */ jsx(ChevronDown, {
862
+ className: joinClasses("size-4 shrink-0 transition-transform motion-reduce:transition-none", isOpen ? "rotate-180" : void 0),
863
+ "aria-hidden": "true"
864
+ })
865
+ ]
866
+ }), isOpen ? /* @__PURE__ */ jsxs("div", {
867
+ id: contentId,
868
+ className: "mt-2 space-y-3 border-l-2 border-rose-200 pl-3",
869
+ children: [
870
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
871
+ className: "mb-2 text-xs font-semibold text-neutral-700",
872
+ children: copy.input
873
+ }), /* @__PURE__ */ jsx("pre", {
874
+ className: "overflow-x-auto whitespace-pre-wrap rounded-md bg-neutral-100 p-3 text-xs leading-5 text-neutral-800",
875
+ children: formatJson$1(part.input)
876
+ })] }),
877
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
878
+ className: "mb-2 text-xs font-semibold text-neutral-700",
879
+ children: copy.output
880
+ }), /* @__PURE__ */ jsx("pre", {
881
+ className: "overflow-x-auto whitespace-pre-wrap rounded-md bg-neutral-100 p-3 text-xs leading-5 text-neutral-800",
882
+ children: part.result === void 0 ? copy.noOutput : formatJson$1(part.result)
883
+ })] }),
884
+ errorDetails ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
885
+ className: "mb-2 text-xs font-semibold text-rose-700",
886
+ children: copy.details
887
+ }), /* @__PURE__ */ jsx("p", {
888
+ className: "whitespace-pre-wrap text-xs leading-5 text-rose-700",
889
+ children: errorDetails
890
+ })] }) : null
891
+ ]
892
+ }) : null]
893
+ });
894
+ }
895
+
728
896
  //#endregion
729
897
  //#region src/components/tool-result-email-send-card.tsx
730
898
  function formatStatus$1(status) {
@@ -1808,7 +1976,7 @@ function ToolResultWebSearchCard({ part, className }) {
1808
1976
  const sourceLabel = searchResults.length === 1 ? "source" : "sources";
1809
1977
  return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsxs(SheetTrigger, {
1810
1978
  "aria-label": `Web: Internet search results, ${searchResults.length} ${sourceLabel}`,
1811
- 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),
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),
1812
1980
  children: [
1813
1981
  /* @__PURE__ */ jsxs("header", {
1814
1982
  className: "flex items-center gap-3",
@@ -1987,6 +2155,154 @@ function ToolResultWorkflowDispatchCard({ part, className }) {
1987
2155
  })] });
1988
2156
  }
1989
2157
 
2158
+ //#endregion
2159
+ //#region src/components/tool-use-indicator.tsx
2160
+ const TOOL_USE_ACTIONS = {
2161
+ agent_invocation: "agent",
2162
+ browser: "web",
2163
+ datasource: "datasource",
2164
+ email_send: "email",
2165
+ external_datasource: "query",
2166
+ firecrawl_search: "web",
2167
+ http_request: "request",
2168
+ mcp_tool: "request",
2169
+ office_documents: "documents",
2170
+ perplexity: "web",
2171
+ structured_datasource: "query",
2172
+ workflow_dispatch: "workflow",
2173
+ unknown: "tool"
2174
+ };
2175
+ const TOOL_USE_TRANSLATIONS = {
2176
+ en: {
2177
+ agent: "Running agent {{toolName}}",
2178
+ datasource: "Searching in datasource {{toolName}}",
2179
+ documents: "Working with documents using {{toolName}}",
2180
+ email: "Sending email with {{toolName}}",
2181
+ query: "Querying {{toolName}}",
2182
+ request: "Sending a request with {{toolName}}",
2183
+ tool: "Running {{toolName}}",
2184
+ web: "Searching the web with {{toolName}}",
2185
+ workflow: "Running workflow {{toolName}}"
2186
+ },
2187
+ es: {
2188
+ agent: "Ejecutando el agente {{toolName}}",
2189
+ datasource: "Buscando en la fuente de datos {{toolName}}",
2190
+ documents: "Trabajando con documentos mediante {{toolName}}",
2191
+ email: "Enviando un correo con {{toolName}}",
2192
+ query: "Consultando {{toolName}}",
2193
+ request: "Ejecutando una petición con {{toolName}}",
2194
+ tool: "Ejecutando {{toolName}}",
2195
+ web: "Buscando en la web con {{toolName}}",
2196
+ workflow: "Ejecutando el flujo {{toolName}}"
2197
+ },
2198
+ ca: {
2199
+ agent: "Executant l’agent {{toolName}}",
2200
+ datasource: "Cercant a la font de dades {{toolName}}",
2201
+ documents: "Treballant amb documents mitjançant {{toolName}}",
2202
+ email: "Enviant un correu amb {{toolName}}",
2203
+ query: "Consultant {{toolName}}",
2204
+ request: "Executant una petició amb {{toolName}}",
2205
+ tool: "Executant {{toolName}}",
2206
+ web: "Cercant al web amb {{toolName}}",
2207
+ workflow: "Executant el flux {{toolName}}"
2208
+ },
2209
+ fr: {
2210
+ agent: "Exécution de l’agent {{toolName}}",
2211
+ datasource: "Recherche dans la source de données {{toolName}}",
2212
+ documents: "Traitement de documents avec {{toolName}}",
2213
+ email: "Envoi d’un e-mail avec {{toolName}}",
2214
+ query: "Interrogation de {{toolName}}",
2215
+ request: "Exécution d’une requête avec {{toolName}}",
2216
+ tool: "Exécution de {{toolName}}",
2217
+ web: "Recherche sur le web avec {{toolName}}",
2218
+ workflow: "Exécution du workflow {{toolName}}"
2219
+ },
2220
+ it: {
2221
+ agent: "Esecuzione dell’agente {{toolName}}",
2222
+ datasource: "Ricerca nella fonte dati {{toolName}}",
2223
+ documents: "Elaborazione di documenti con {{toolName}}",
2224
+ email: "Invio di un’email con {{toolName}}",
2225
+ query: "Interrogazione di {{toolName}}",
2226
+ request: "Esecuzione di una richiesta con {{toolName}}",
2227
+ tool: "Esecuzione di {{toolName}}",
2228
+ web: "Ricerca sul web con {{toolName}}",
2229
+ workflow: "Esecuzione del flusso {{toolName}}"
2230
+ },
2231
+ de: {
2232
+ agent: "Agent {{toolName}} wird ausgeführt",
2233
+ datasource: "Suche in der Datenquelle {{toolName}}",
2234
+ documents: "Dokumente werden mit {{toolName}} bearbeitet",
2235
+ email: "E-Mail wird mit {{toolName}} gesendet",
2236
+ query: "Abfrage von {{toolName}}",
2237
+ request: "Anfrage wird mit {{toolName}} ausgeführt",
2238
+ tool: "{{toolName}} wird ausgeführt",
2239
+ web: "Websuche mit {{toolName}}",
2240
+ workflow: "Workflow {{toolName}} wird ausgeführt"
2241
+ },
2242
+ da: {
2243
+ agent: "Kører agenten {{toolName}}",
2244
+ datasource: "Søger i datakilden {{toolName}}",
2245
+ documents: "Arbejder med dokumenter via {{toolName}}",
2246
+ email: "Sender e-mail med {{toolName}}",
2247
+ query: "Forespørger {{toolName}}",
2248
+ request: "Udfører en anmodning med {{toolName}}",
2249
+ tool: "Kører {{toolName}}",
2250
+ web: "Søger på nettet med {{toolName}}",
2251
+ workflow: "Kører workflowet {{toolName}}"
2252
+ },
2253
+ sv: {
2254
+ agent: "Kör agenten {{toolName}}",
2255
+ datasource: "Söker i datakällan {{toolName}}",
2256
+ documents: "Arbetar med dokument via {{toolName}}",
2257
+ email: "Skickar e-post med {{toolName}}",
2258
+ query: "Frågar {{toolName}}",
2259
+ request: "Kör en begäran med {{toolName}}",
2260
+ tool: "Kör {{toolName}}",
2261
+ web: "Söker på webben med {{toolName}}",
2262
+ workflow: "Kör arbetsflödet {{toolName}}"
2263
+ },
2264
+ no: {
2265
+ agent: "Kjører agenten {{toolName}}",
2266
+ datasource: "Søker i datakilden {{toolName}}",
2267
+ documents: "Arbeider med dokumenter via {{toolName}}",
2268
+ email: "Sender e-post med {{toolName}}",
2269
+ query: "Spør {{toolName}}",
2270
+ request: "Kjører en forespørsel med {{toolName}}",
2271
+ tool: "Kjører {{toolName}}",
2272
+ web: "Søker på nettet med {{toolName}}",
2273
+ workflow: "Kjører arbeidsflyten {{toolName}}"
2274
+ },
2275
+ pt: {
2276
+ agent: "Executando o agente {{toolName}}",
2277
+ datasource: "Pesquisando na fonte de dados {{toolName}}",
2278
+ documents: "Trabalhando com documentos usando {{toolName}}",
2279
+ email: "Enviando e-mail com {{toolName}}",
2280
+ query: "Consultando {{toolName}}",
2281
+ request: "Executando um pedido com {{toolName}}",
2282
+ tool: "Executando {{toolName}}",
2283
+ web: "Pesquisando na web com {{toolName}}",
2284
+ workflow: "Executando o fluxo {{toolName}}"
2285
+ }
2286
+ };
2287
+ function getToolUseLabel(part, locale) {
2288
+ const action = part.toolType ? TOOL_USE_ACTIONS[part.toolType] ?? "tool" : "tool";
2289
+ return TOOL_USE_TRANSLATIONS[getSupportedToolLocale(locale)][action].replaceAll("{{toolName}}", part.name);
2290
+ }
2291
+ function ToolUseIndicator({ part, locale, className,...props }) {
2292
+ const label = getToolUseLabel(part, locale);
2293
+ return /* @__PURE__ */ jsx("output", {
2294
+ "aria-live": "polite",
2295
+ className: joinClasses("block min-h-10 py-2 text-sm", className),
2296
+ "data-tool-call-id": part.id,
2297
+ "data-tool-call-state": part.state,
2298
+ ...props,
2299
+ children: /* @__PURE__ */ jsxs("span", {
2300
+ className: "plai-tool-use-shimmer",
2301
+ children: [label, "…"]
2302
+ })
2303
+ });
2304
+ }
2305
+
1990
2306
  //#endregion
1991
2307
  //#region src/components/tool-result-card.tsx
1992
2308
  function formatJson(value) {
@@ -2005,9 +2321,18 @@ function getDatasourceResources(part) {
2005
2321
  return Array.isArray(resources) ? resources.filter(isDatasourceResource) : [];
2006
2322
  }
2007
2323
  function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAgentThread }) {
2324
+ if (part.state === "pending") return /* @__PURE__ */ jsx(ToolUseIndicator, {
2325
+ part,
2326
+ locale,
2327
+ className
2328
+ });
2329
+ if (part.state === "error") return /* @__PURE__ */ jsx(ToolError, {
2330
+ part,
2331
+ locale,
2332
+ className
2333
+ });
2008
2334
  const officeMediaFiles = getOfficeDocumentMediaFiles(part);
2009
2335
  const datasourceResources = getDatasourceResources(part);
2010
- const errorDetails = formatToolErrorDetails(part.errorDetails);
2011
2336
  if (part.toolType === "email_send") return /* @__PURE__ */ jsx(ToolResultEmailSendCard, {
2012
2337
  part,
2013
2338
  className
@@ -2050,8 +2375,6 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
2050
2375
  locale,
2051
2376
  className
2052
2377
  });
2053
- 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";
2054
- const statusLabel = part.state === "pending" ? "pending" : part.state === "error" ? "error" : "completed";
2055
2378
  return /* @__PURE__ */ jsxs("section", {
2056
2379
  className: joinClasses("space-y-3 rounded-lg border border-slate-200 bg-slate-50 p-3", className),
2057
2380
  "data-tool-call-id": part.id,
@@ -2063,8 +2386,8 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
2063
2386
  className: "text-sm font-semibold text-slate-900",
2064
2387
  children: part.name
2065
2388
  }), /* @__PURE__ */ jsx("span", {
2066
- className: joinClasses("rounded-full border px-2 py-0.5 text-xs font-medium", statusClass),
2067
- children: statusLabel
2389
+ className: "rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-xs font-medium text-emerald-800",
2390
+ children: "completed"
2068
2391
  })]
2069
2392
  }),
2070
2393
  part.toolType ? /* @__PURE__ */ jsxs("p", {
@@ -2124,17 +2447,6 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
2124
2447
  children: formatJson(part.result)
2125
2448
  })
2126
2449
  ]
2127
- }) : null,
2128
- errorDetails ? /* @__PURE__ */ jsxs("p", {
2129
- className: "rounded border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-700",
2130
- children: [
2131
- /* @__PURE__ */ jsx("span", {
2132
- className: "font-semibold",
2133
- children: "Error details:"
2134
- }),
2135
- " ",
2136
- errorDetails
2137
- ]
2138
2450
  }) : null
2139
2451
  ]
2140
2452
  });
@@ -2199,7 +2511,7 @@ function Thinking({ part, thinkingLabel = "Thinking…", completedLabel = "Thoug
2199
2511
  //#region src/components/message.tsx
2200
2512
  function Message({ align = "start", className,...props }) {
2201
2513
  return /* @__PURE__ */ jsx("article", {
2202
- className: joinClasses("flex w-full items-start gap-3", align === "end" ? "flex-row-reverse" : void 0, className),
2514
+ className: joinClasses("plai-message flex w-full items-start gap-3", align === "end" ? "flex-row-reverse" : void 0, className),
2203
2515
  "data-align": align,
2204
2516
  ...props
2205
2517
  });
@@ -2215,7 +2527,7 @@ function MessageAvatar({ src, fallback, alt = fallback, className, imageClassNam
2215
2527
  const showImage = src.trim().length > 0 && failedSrc !== src;
2216
2528
  const initials = getFallbackInitials(fallback);
2217
2529
  return /* @__PURE__ */ jsx("div", {
2218
- className: joinClasses("flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-full bg-neutral-200 text-xs font-semibold uppercase text-neutral-700", className),
2530
+ className: joinClasses("plai-message-avatar flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-full bg-neutral-200 text-xs font-semibold uppercase text-neutral-700", className),
2219
2531
  ...props,
2220
2532
  children: showImage ? /* @__PURE__ */ jsx("img", {
2221
2533
  src,
@@ -2262,14 +2574,20 @@ function getDisplayExtension(label) {
2262
2574
  if (!ext || ext === label.toUpperCase()) return void 0;
2263
2575
  return ext;
2264
2576
  }
2265
- function renderPart(part, index, message, isStreaming, onOpenAgentThread, locale, renderText, renderToolCall, renderThinking, thinkingLabel, completedThinkingLabel) {
2577
+ function getMessageTextClassName(role) {
2578
+ return joinClasses("whitespace-pre-wrap text-sm leading-6", role === "user" ? "font-medium" : "font-normal");
2579
+ }
2580
+ function getMessageTextAlignmentClassName(role) {
2581
+ return role === "user" ? "text-right" : "text-left";
2582
+ }
2583
+ function renderPart(part, index, message, isStreaming, onOpenAgentThread, locale, renderText, renderToolCall, renderThinking, thinkingLabel, completedThinkingLabel, textClassName) {
2266
2584
  if (part.type === "text") {
2267
2585
  if (renderText) return /* @__PURE__ */ jsx("div", { children: renderText(part, {
2268
2586
  message,
2269
2587
  isStreaming
2270
2588
  }) }, `text-${index}`);
2271
2589
  return /* @__PURE__ */ jsx("p", {
2272
- className: "whitespace-pre-wrap text-sm leading-6",
2590
+ className: textClassName,
2273
2591
  children: part.text
2274
2592
  }, `text-${index}`);
2275
2593
  }
@@ -2352,17 +2670,19 @@ function MessageParts({ message, collapseThreshold = DEFAULT_COLLAPSE_THRESHOLD,
2352
2670
  const textContent = useMemo(() => message.parts.filter((part) => part.type === "text").map((part) => part.text).join("\n"), [message.parts]);
2353
2671
  const canCollapse = message.role === "user" && message.parts.every((part) => part.type === "text") && textContent.length > collapseThreshold;
2354
2672
  const previewText = canCollapse ? `${textContent.slice(0, collapseThreshold).trimEnd()}...` : textContent;
2673
+ const textClassName = getMessageTextClassName(message.role);
2674
+ const textAlignmentClassName = getMessageTextAlignmentClassName(message.role);
2355
2675
  const orderedParts = useMemo(() => orderMessageParts(message.parts, datasourceToolResultsPosition), [message.parts, datasourceToolResultsPosition]);
2356
2676
  return /* @__PURE__ */ jsxs("div", {
2357
- className: joinClasses("space-y-2", className),
2677
+ className: joinClasses("space-y-2", textAlignmentClassName, className),
2358
2678
  "data-message-role": message.role,
2359
2679
  ...props,
2360
2680
  children: [canCollapse && !isExpanded ? /* @__PURE__ */ jsx("p", {
2361
- className: "whitespace-pre-wrap text-sm leading-6",
2681
+ className: textClassName,
2362
2682
  children: previewText
2363
- }) : orderedParts.map(({ part, index }) => renderPart(part, index, message, isStreaming, onOpenAgentThread, locale, renderText, renderToolCall, renderThinking, thinkingLabel, completedThinkingLabel)), canCollapse ? /* @__PURE__ */ jsx("button", {
2683
+ }) : orderedParts.map(({ part, index }) => renderPart(part, index, message, isStreaming, onOpenAgentThread, locale, renderText, renderToolCall, renderThinking, thinkingLabel, completedThinkingLabel, textClassName)), canCollapse ? /* @__PURE__ */ jsx("button", {
2364
2684
  type: "button",
2365
- className: "text-left text-xs font-medium text-slate-600 hover:text-slate-900",
2685
+ className: "text-xs font-medium text-slate-600 hover:text-slate-900",
2366
2686
  onClick: () => setIsExpanded((previous) => !previous),
2367
2687
  children: isExpanded ? readLessLabel : readMoreLabel
2368
2688
  }) : null]
@@ -2959,5 +3279,5 @@ async function dummyTranscribeAudio(_audio, signal) {
2959
3279
  }
2960
3280
 
2961
3281
  //#endregion
2962
- 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, ToolResultAgentInvocationCard, ToolResultBrowserCard, ToolResultCard, ToolResultExternalDatasourceCard, ToolResultHttpRequestCard, ToolResultMcpCard, ToolResultOfficeDocumentsCard, ToolResultWebSearchCard, ToolResultWorkflowDispatchCard, X, dummyTranscribeAudio, getLocalizedOpenGraphValue, getResourceDescription, getResourceIcon, getResourceOpenGraphImage, getResourceOpenGraphType, getResourceTitle, getResourceType, getResourceUrl, isAllowedPromptFormFile, partitionPromptFormFiles, useSpeechToText };
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 };
2963
3283
  //# sourceMappingURL=index.js.map