@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.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PlaiChat } from "@plaisolutions/client";
2
2
  import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
3
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
- import { Bot, Brain, Check, CheckCircle2, ChevronDown, Copy, Database, File, FileText, Globe, LoaderCircle, MessageSquare, Minus, Plug, Plus, RotateCcw, ThumbsDown, ThumbsUp, Workflow, XCircle } from "lucide-react";
4
+ 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";
5
5
 
6
6
  //#region src/use-chat.ts
7
7
  function useChat(options) {
@@ -162,18 +162,19 @@ function ResourceCardContent({ icon, type, title, description }) {
162
162
  ] });
163
163
  }
164
164
  function ResourceCard(props) {
165
- const className = "block w-full rounded-lg bg-neutral-100 p-4 text-left text-neutral-950";
166
- if (!props.url) return /* @__PURE__ */ jsx("article", {
167
- "aria-label": `${props.title}: ${props.description}`,
165
+ const { className: customClassName, variant = "card",...contentProps } = props;
166
+ 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);
167
+ if (!contentProps.url) return /* @__PURE__ */ jsx("article", {
168
+ "aria-label": `${contentProps.title}: ${contentProps.description}`,
168
169
  className,
169
- children: /* @__PURE__ */ jsx(ResourceCardContent, { ...props })
170
+ children: /* @__PURE__ */ jsx(ResourceCardContent, { ...contentProps })
170
171
  });
171
172
  return /* @__PURE__ */ jsx("a", {
172
- href: props.url,
173
+ href: contentProps.url,
173
174
  target: "_blank",
174
175
  rel: "noreferrer noopener",
175
176
  className: `${className} transition-colors hover:bg-neutral-200 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950`,
176
- children: /* @__PURE__ */ jsx(ResourceCardContent, { ...props })
177
+ children: /* @__PURE__ */ jsx(ResourceCardContent, { ...contentProps })
177
178
  });
178
179
  }
179
180
 
@@ -530,7 +531,7 @@ const SheetDescription = forwardRef(function SheetDescription$1({ className, id,
530
531
  function DatasourceFolderCard({ icon, title, description, type, url, resources }) {
531
532
  return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsx(SheetTrigger, {
532
533
  "aria-label": `${type}: ${title}`,
533
- 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",
534
+ 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",
534
535
  children: /* @__PURE__ */ jsx(DatasourceToolResultCardContent, {
535
536
  icon,
536
537
  title,
@@ -574,7 +575,10 @@ function DatasourceFolderCard({ icon, title, description, type, url, resources }
574
575
  children: "Ver"
575
576
  }), /* @__PURE__ */ jsx("div", {
576
577
  className: "mt-7 space-y-3",
577
- children: resources.map((resource, index) => /* @__PURE__ */ jsx(ResourceCard, { ...resource }, `${resource.url ?? resource.title}-${index}`))
578
+ children: resources.map((resource, index) => /* @__PURE__ */ jsx(ResourceCard, {
579
+ ...resource,
580
+ variant: "list"
581
+ }, `${resource.url ?? resource.title}-${index}`))
578
582
  })]
579
583
  })]
580
584
  })] });
@@ -585,7 +589,7 @@ function DatasourceFolderCard({ icon, title, description, type, url, resources }
585
589
  function normalizeLocale(locale) {
586
590
  return locale?.trim().toLowerCase();
587
591
  }
588
- function getCurrentLocale() {
592
+ function getCurrentLocale$1() {
589
593
  if (typeof document !== "undefined" && document.documentElement.lang) return document.documentElement.lang;
590
594
  if (typeof navigator !== "undefined") return navigator.language || navigator.userLanguage;
591
595
  }
@@ -605,7 +609,7 @@ function getTranslation(translations, locale) {
605
609
  function getLocalizedOpenGraphValue(container, field, locale) {
606
610
  const opengraph = container.extra_info?.opengraph;
607
611
  if (!opengraph) return void 0;
608
- for (const candidate of getLocaleCandidates(locale ?? getCurrentLocale())) {
612
+ for (const candidate of getLocaleCandidates(locale ?? getCurrentLocale$1())) {
609
613
  const translated = getTranslation(opengraph.translations, candidate)?.[field];
610
614
  if (hasStringValue(translated)) return translated.trim();
611
615
  }
@@ -772,6 +776,170 @@ function formatToolErrorDetails(value) {
772
776
  }
773
777
  }
774
778
 
779
+ //#endregion
780
+ //#region src/components/internal/tool-locale.ts
781
+ const SUPPORTED_TOOL_LOCALES = new Set([
782
+ "ca",
783
+ "da",
784
+ "de",
785
+ "en",
786
+ "es",
787
+ "fr",
788
+ "it",
789
+ "no",
790
+ "pt",
791
+ "sv"
792
+ ]);
793
+ function getCurrentLocale() {
794
+ return typeof navigator === "undefined" ? "en" : navigator.language;
795
+ }
796
+ function getSupportedToolLocale(locale) {
797
+ const language = (locale ?? getCurrentLocale()).trim().toLowerCase().split(/[-_]/)[0];
798
+ const normalizedLanguage = language === "nb" || language === "nn" ? "no" : language;
799
+ return SUPPORTED_TOOL_LOCALES.has(normalizedLanguage) ? normalizedLanguage : "en";
800
+ }
801
+
802
+ //#endregion
803
+ //#region src/components/tool-error.tsx
804
+ const TOOL_ERROR_TRANSLATIONS = {
805
+ en: {
806
+ summary: "Failed to use tool {{toolName}}",
807
+ input: "Input",
808
+ output: "Output",
809
+ details: "Error details",
810
+ noOutput: "No output available"
811
+ },
812
+ es: {
813
+ summary: "Falló al usar la tool {{toolName}}",
814
+ input: "Entrada",
815
+ output: "Salida",
816
+ details: "Detalles del error",
817
+ noOutput: "No hay salida disponible"
818
+ },
819
+ ca: {
820
+ summary: "No s’ha pogut utilitzar l’eina {{toolName}}",
821
+ input: "Entrada",
822
+ output: "Sortida",
823
+ details: "Detalls de l’error",
824
+ noOutput: "No hi ha cap sortida disponible"
825
+ },
826
+ fr: {
827
+ summary: "Échec de l’utilisation de l’outil {{toolName}}",
828
+ input: "Entrée",
829
+ output: "Sortie",
830
+ details: "Détails de l’erreur",
831
+ noOutput: "Aucune sortie disponible"
832
+ },
833
+ it: {
834
+ summary: "Impossibile utilizzare lo strumento {{toolName}}",
835
+ input: "Input",
836
+ output: "Output",
837
+ details: "Dettagli dell’errore",
838
+ noOutput: "Nessun output disponibile"
839
+ },
840
+ de: {
841
+ summary: "Tool {{toolName}} konnte nicht verwendet werden",
842
+ input: "Eingabe",
843
+ output: "Ausgabe",
844
+ details: "Fehlerdetails",
845
+ noOutput: "Keine Ausgabe verfügbar"
846
+ },
847
+ da: {
848
+ summary: "Kunne ikke bruge værktøjet {{toolName}}",
849
+ input: "Input",
850
+ output: "Output",
851
+ details: "Fejldetaljer",
852
+ noOutput: "Intet output tilgængeligt"
853
+ },
854
+ sv: {
855
+ summary: "Det gick inte att använda verktyget {{toolName}}",
856
+ input: "Indata",
857
+ output: "Utdata",
858
+ details: "Feldetaljer",
859
+ noOutput: "Ingen utdata tillgänglig"
860
+ },
861
+ no: {
862
+ summary: "Kunne ikke bruke verktøyet {{toolName}}",
863
+ input: "Inndata",
864
+ output: "Utdata",
865
+ details: "Feildetaljer",
866
+ noOutput: "Ingen utdata tilgjengelig"
867
+ },
868
+ pt: {
869
+ summary: "Falha ao usar a ferramenta {{toolName}}",
870
+ input: "Entrada",
871
+ output: "Saída",
872
+ details: "Detalhes do erro",
873
+ noOutput: "Nenhuma saída disponível"
874
+ }
875
+ };
876
+ function formatJson$1(value) {
877
+ return JSON.stringify(value, null, 2) ?? String(value);
878
+ }
879
+ function getToolErrorCopy(part, locale) {
880
+ const copy = TOOL_ERROR_TRANSLATIONS[getSupportedToolLocale(locale)];
881
+ return {
882
+ ...copy,
883
+ summary: copy.summary.replaceAll("{{toolName}}", part.name)
884
+ };
885
+ }
886
+ function ToolError({ part, locale, defaultOpen = false, className,...props }) {
887
+ const [isOpen, setIsOpen] = useState(defaultOpen);
888
+ const contentId = useId();
889
+ const copy = getToolErrorCopy(part, locale);
890
+ const errorDetails = formatToolErrorDetails(part.errorDetails);
891
+ return /* @__PURE__ */ jsxs("section", {
892
+ className: joinClasses("text-sm text-neutral-600", className),
893
+ "data-tool-call-id": part.id,
894
+ "data-tool-call-state": part.state,
895
+ ...props,
896
+ children: [/* @__PURE__ */ jsxs("button", {
897
+ type: "button",
898
+ "aria-controls": contentId,
899
+ "aria-expanded": isOpen,
900
+ 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",
901
+ onClick: () => setIsOpen((value) => !value),
902
+ children: [
903
+ /* @__PURE__ */ jsx(CircleX, {
904
+ className: "size-4 shrink-0",
905
+ "aria-hidden": "true"
906
+ }),
907
+ /* @__PURE__ */ jsx("span", { children: copy.summary }),
908
+ /* @__PURE__ */ jsx(ChevronDown, {
909
+ className: joinClasses("size-4 shrink-0 transition-transform motion-reduce:transition-none", isOpen ? "rotate-180" : void 0),
910
+ "aria-hidden": "true"
911
+ })
912
+ ]
913
+ }), isOpen ? /* @__PURE__ */ jsxs("div", {
914
+ id: contentId,
915
+ className: "mt-2 space-y-3 border-l-2 border-rose-200 pl-3",
916
+ children: [
917
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
918
+ className: "mb-2 text-xs font-semibold text-neutral-700",
919
+ children: copy.input
920
+ }), /* @__PURE__ */ jsx("pre", {
921
+ className: "overflow-x-auto whitespace-pre-wrap rounded-md bg-neutral-100 p-3 text-xs leading-5 text-neutral-800",
922
+ children: formatJson$1(part.input)
923
+ })] }),
924
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
925
+ className: "mb-2 text-xs font-semibold text-neutral-700",
926
+ children: copy.output
927
+ }), /* @__PURE__ */ jsx("pre", {
928
+ className: "overflow-x-auto whitespace-pre-wrap rounded-md bg-neutral-100 p-3 text-xs leading-5 text-neutral-800",
929
+ children: part.result === void 0 ? copy.noOutput : formatJson$1(part.result)
930
+ })] }),
931
+ errorDetails ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
932
+ className: "mb-2 text-xs font-semibold text-rose-700",
933
+ children: copy.details
934
+ }), /* @__PURE__ */ jsx("p", {
935
+ className: "whitespace-pre-wrap text-xs leading-5 text-rose-700",
936
+ children: errorDetails
937
+ })] }) : null
938
+ ]
939
+ }) : null]
940
+ });
941
+ }
942
+
775
943
  //#endregion
776
944
  //#region src/components/tool-result-email-send-card.tsx
777
945
  function formatStatus$1(status) {
@@ -1855,7 +2023,7 @@ function ToolResultWebSearchCard({ part, className }) {
1855
2023
  const sourceLabel = searchResults.length === 1 ? "source" : "sources";
1856
2024
  return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsxs(SheetTrigger, {
1857
2025
  "aria-label": `Web: Internet search results, ${searchResults.length} ${sourceLabel}`,
1858
- 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),
2026
+ 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),
1859
2027
  children: [
1860
2028
  /* @__PURE__ */ jsxs("header", {
1861
2029
  className: "flex items-center gap-3",
@@ -2034,6 +2202,154 @@ function ToolResultWorkflowDispatchCard({ part, className }) {
2034
2202
  })] });
2035
2203
  }
2036
2204
 
2205
+ //#endregion
2206
+ //#region src/components/tool-use-indicator.tsx
2207
+ const TOOL_USE_ACTIONS = {
2208
+ agent_invocation: "agent",
2209
+ browser: "web",
2210
+ datasource: "datasource",
2211
+ email_send: "email",
2212
+ external_datasource: "query",
2213
+ firecrawl_search: "web",
2214
+ http_request: "request",
2215
+ mcp_tool: "request",
2216
+ office_documents: "documents",
2217
+ perplexity: "web",
2218
+ structured_datasource: "query",
2219
+ workflow_dispatch: "workflow",
2220
+ unknown: "tool"
2221
+ };
2222
+ const TOOL_USE_TRANSLATIONS = {
2223
+ en: {
2224
+ agent: "Running agent {{toolName}}",
2225
+ datasource: "Searching in datasource {{toolName}}",
2226
+ documents: "Working with documents using {{toolName}}",
2227
+ email: "Sending email with {{toolName}}",
2228
+ query: "Querying {{toolName}}",
2229
+ request: "Sending a request with {{toolName}}",
2230
+ tool: "Running {{toolName}}",
2231
+ web: "Searching the web with {{toolName}}",
2232
+ workflow: "Running workflow {{toolName}}"
2233
+ },
2234
+ es: {
2235
+ agent: "Ejecutando el agente {{toolName}}",
2236
+ datasource: "Buscando en la fuente de datos {{toolName}}",
2237
+ documents: "Trabajando con documentos mediante {{toolName}}",
2238
+ email: "Enviando un correo con {{toolName}}",
2239
+ query: "Consultando {{toolName}}",
2240
+ request: "Ejecutando una petición con {{toolName}}",
2241
+ tool: "Ejecutando {{toolName}}",
2242
+ web: "Buscando en la web con {{toolName}}",
2243
+ workflow: "Ejecutando el flujo {{toolName}}"
2244
+ },
2245
+ ca: {
2246
+ agent: "Executant l’agent {{toolName}}",
2247
+ datasource: "Cercant a la font de dades {{toolName}}",
2248
+ documents: "Treballant amb documents mitjançant {{toolName}}",
2249
+ email: "Enviant un correu amb {{toolName}}",
2250
+ query: "Consultant {{toolName}}",
2251
+ request: "Executant una petició amb {{toolName}}",
2252
+ tool: "Executant {{toolName}}",
2253
+ web: "Cercant al web amb {{toolName}}",
2254
+ workflow: "Executant el flux {{toolName}}"
2255
+ },
2256
+ fr: {
2257
+ agent: "Exécution de l’agent {{toolName}}",
2258
+ datasource: "Recherche dans la source de données {{toolName}}",
2259
+ documents: "Traitement de documents avec {{toolName}}",
2260
+ email: "Envoi d’un e-mail avec {{toolName}}",
2261
+ query: "Interrogation de {{toolName}}",
2262
+ request: "Exécution d’une requête avec {{toolName}}",
2263
+ tool: "Exécution de {{toolName}}",
2264
+ web: "Recherche sur le web avec {{toolName}}",
2265
+ workflow: "Exécution du workflow {{toolName}}"
2266
+ },
2267
+ it: {
2268
+ agent: "Esecuzione dell’agente {{toolName}}",
2269
+ datasource: "Ricerca nella fonte dati {{toolName}}",
2270
+ documents: "Elaborazione di documenti con {{toolName}}",
2271
+ email: "Invio di un’email con {{toolName}}",
2272
+ query: "Interrogazione di {{toolName}}",
2273
+ request: "Esecuzione di una richiesta con {{toolName}}",
2274
+ tool: "Esecuzione di {{toolName}}",
2275
+ web: "Ricerca sul web con {{toolName}}",
2276
+ workflow: "Esecuzione del flusso {{toolName}}"
2277
+ },
2278
+ de: {
2279
+ agent: "Agent {{toolName}} wird ausgeführt",
2280
+ datasource: "Suche in der Datenquelle {{toolName}}",
2281
+ documents: "Dokumente werden mit {{toolName}} bearbeitet",
2282
+ email: "E-Mail wird mit {{toolName}} gesendet",
2283
+ query: "Abfrage von {{toolName}}",
2284
+ request: "Anfrage wird mit {{toolName}} ausgeführt",
2285
+ tool: "{{toolName}} wird ausgeführt",
2286
+ web: "Websuche mit {{toolName}}",
2287
+ workflow: "Workflow {{toolName}} wird ausgeführt"
2288
+ },
2289
+ da: {
2290
+ agent: "Kører agenten {{toolName}}",
2291
+ datasource: "Søger i datakilden {{toolName}}",
2292
+ documents: "Arbejder med dokumenter via {{toolName}}",
2293
+ email: "Sender e-mail med {{toolName}}",
2294
+ query: "Forespørger {{toolName}}",
2295
+ request: "Udfører en anmodning med {{toolName}}",
2296
+ tool: "Kører {{toolName}}",
2297
+ web: "Søger på nettet med {{toolName}}",
2298
+ workflow: "Kører workflowet {{toolName}}"
2299
+ },
2300
+ sv: {
2301
+ agent: "Kör agenten {{toolName}}",
2302
+ datasource: "Söker i datakällan {{toolName}}",
2303
+ documents: "Arbetar med dokument via {{toolName}}",
2304
+ email: "Skickar e-post med {{toolName}}",
2305
+ query: "Frågar {{toolName}}",
2306
+ request: "Kör en begäran med {{toolName}}",
2307
+ tool: "Kör {{toolName}}",
2308
+ web: "Söker på webben med {{toolName}}",
2309
+ workflow: "Kör arbetsflödet {{toolName}}"
2310
+ },
2311
+ no: {
2312
+ agent: "Kjører agenten {{toolName}}",
2313
+ datasource: "Søker i datakilden {{toolName}}",
2314
+ documents: "Arbeider med dokumenter via {{toolName}}",
2315
+ email: "Sender e-post med {{toolName}}",
2316
+ query: "Spør {{toolName}}",
2317
+ request: "Kjører en forespørsel med {{toolName}}",
2318
+ tool: "Kjører {{toolName}}",
2319
+ web: "Søker på nettet med {{toolName}}",
2320
+ workflow: "Kjører arbeidsflyten {{toolName}}"
2321
+ },
2322
+ pt: {
2323
+ agent: "Executando o agente {{toolName}}",
2324
+ datasource: "Pesquisando na fonte de dados {{toolName}}",
2325
+ documents: "Trabalhando com documentos usando {{toolName}}",
2326
+ email: "Enviando e-mail com {{toolName}}",
2327
+ query: "Consultando {{toolName}}",
2328
+ request: "Executando um pedido com {{toolName}}",
2329
+ tool: "Executando {{toolName}}",
2330
+ web: "Pesquisando na web com {{toolName}}",
2331
+ workflow: "Executando o fluxo {{toolName}}"
2332
+ }
2333
+ };
2334
+ function getToolUseLabel(part, locale) {
2335
+ const action = part.toolType ? TOOL_USE_ACTIONS[part.toolType] ?? "tool" : "tool";
2336
+ return TOOL_USE_TRANSLATIONS[getSupportedToolLocale(locale)][action].replaceAll("{{toolName}}", part.name);
2337
+ }
2338
+ function ToolUseIndicator({ part, locale, className,...props }) {
2339
+ const label = getToolUseLabel(part, locale);
2340
+ return /* @__PURE__ */ jsx("output", {
2341
+ "aria-live": "polite",
2342
+ className: joinClasses("block min-h-10 py-2 text-sm", className),
2343
+ "data-tool-call-id": part.id,
2344
+ "data-tool-call-state": part.state,
2345
+ ...props,
2346
+ children: /* @__PURE__ */ jsxs("span", {
2347
+ className: "plai-tool-use-shimmer",
2348
+ children: [label, "…"]
2349
+ })
2350
+ });
2351
+ }
2352
+
2037
2353
  //#endregion
2038
2354
  //#region src/components/tool-result-card.tsx
2039
2355
  function formatJson(value) {
@@ -2052,9 +2368,18 @@ function getDatasourceResources(part) {
2052
2368
  return Array.isArray(resources) ? resources.filter(isDatasourceResource) : [];
2053
2369
  }
2054
2370
  function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAgentThread }) {
2371
+ if (part.state === "pending") return /* @__PURE__ */ jsx(ToolUseIndicator, {
2372
+ part,
2373
+ locale,
2374
+ className
2375
+ });
2376
+ if (part.state === "error") return /* @__PURE__ */ jsx(ToolError, {
2377
+ part,
2378
+ locale,
2379
+ className
2380
+ });
2055
2381
  const officeMediaFiles = getOfficeDocumentMediaFiles(part);
2056
2382
  const datasourceResources = getDatasourceResources(part);
2057
- const errorDetails = formatToolErrorDetails(part.errorDetails);
2058
2383
  if (part.toolType === "email_send") return /* @__PURE__ */ jsx(ToolResultEmailSendCard, {
2059
2384
  part,
2060
2385
  className
@@ -2097,8 +2422,6 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
2097
2422
  locale,
2098
2423
  className
2099
2424
  });
2100
- 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";
2101
- const statusLabel = part.state === "pending" ? "pending" : part.state === "error" ? "error" : "completed";
2102
2425
  return /* @__PURE__ */ jsxs("section", {
2103
2426
  className: joinClasses("space-y-3 rounded-lg border border-slate-200 bg-slate-50 p-3", className),
2104
2427
  "data-tool-call-id": part.id,
@@ -2110,8 +2433,8 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
2110
2433
  className: "text-sm font-semibold text-slate-900",
2111
2434
  children: part.name
2112
2435
  }), /* @__PURE__ */ jsx("span", {
2113
- className: joinClasses("rounded-full border px-2 py-0.5 text-xs font-medium", statusClass),
2114
- children: statusLabel
2436
+ className: "rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-xs font-medium text-emerald-800",
2437
+ children: "completed"
2115
2438
  })]
2116
2439
  }),
2117
2440
  part.toolType ? /* @__PURE__ */ jsxs("p", {
@@ -2171,17 +2494,6 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
2171
2494
  children: formatJson(part.result)
2172
2495
  })
2173
2496
  ]
2174
- }) : null,
2175
- errorDetails ? /* @__PURE__ */ jsxs("p", {
2176
- className: "rounded border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-700",
2177
- children: [
2178
- /* @__PURE__ */ jsx("span", {
2179
- className: "font-semibold",
2180
- children: "Error details:"
2181
- }),
2182
- " ",
2183
- errorDetails
2184
- ]
2185
2497
  }) : null
2186
2498
  ]
2187
2499
  });
@@ -2246,7 +2558,7 @@ function Thinking({ part, thinkingLabel = "Thinking…", completedLabel = "Thoug
2246
2558
  //#region src/components/message.tsx
2247
2559
  function Message({ align = "start", className,...props }) {
2248
2560
  return /* @__PURE__ */ jsx("article", {
2249
- className: joinClasses("flex w-full items-start gap-3", align === "end" ? "flex-row-reverse" : void 0, className),
2561
+ className: joinClasses("plai-message flex w-full items-start gap-3", align === "end" ? "flex-row-reverse" : void 0, className),
2250
2562
  "data-align": align,
2251
2563
  ...props
2252
2564
  });
@@ -2262,7 +2574,7 @@ function MessageAvatar({ src, fallback, alt = fallback, className, imageClassNam
2262
2574
  const showImage = src.trim().length > 0 && failedSrc !== src;
2263
2575
  const initials = getFallbackInitials(fallback);
2264
2576
  return /* @__PURE__ */ jsx("div", {
2265
- 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),
2577
+ 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),
2266
2578
  ...props,
2267
2579
  children: showImage ? /* @__PURE__ */ jsx("img", {
2268
2580
  src,
@@ -2309,14 +2621,20 @@ function getDisplayExtension(label) {
2309
2621
  if (!ext || ext === label.toUpperCase()) return void 0;
2310
2622
  return ext;
2311
2623
  }
2312
- function renderPart(part, index, message, isStreaming, onOpenAgentThread, locale, renderText, renderToolCall, renderThinking, thinkingLabel, completedThinkingLabel) {
2624
+ function getMessageTextClassName(role) {
2625
+ return joinClasses("whitespace-pre-wrap text-sm leading-6", role === "user" ? "font-medium" : "font-normal");
2626
+ }
2627
+ function getMessageTextAlignmentClassName(role) {
2628
+ return role === "user" ? "text-right" : "text-left";
2629
+ }
2630
+ function renderPart(part, index, message, isStreaming, onOpenAgentThread, locale, renderText, renderToolCall, renderThinking, thinkingLabel, completedThinkingLabel, textClassName) {
2313
2631
  if (part.type === "text") {
2314
2632
  if (renderText) return /* @__PURE__ */ jsx("div", { children: renderText(part, {
2315
2633
  message,
2316
2634
  isStreaming
2317
2635
  }) }, `text-${index}`);
2318
2636
  return /* @__PURE__ */ jsx("p", {
2319
- className: "whitespace-pre-wrap text-sm leading-6",
2637
+ className: textClassName,
2320
2638
  children: part.text
2321
2639
  }, `text-${index}`);
2322
2640
  }
@@ -2399,17 +2717,19 @@ function MessageParts({ message, collapseThreshold = DEFAULT_COLLAPSE_THRESHOLD,
2399
2717
  const textContent = useMemo(() => message.parts.filter((part) => part.type === "text").map((part) => part.text).join("\n"), [message.parts]);
2400
2718
  const canCollapse = message.role === "user" && message.parts.every((part) => part.type === "text") && textContent.length > collapseThreshold;
2401
2719
  const previewText = canCollapse ? `${textContent.slice(0, collapseThreshold).trimEnd()}...` : textContent;
2720
+ const textClassName = getMessageTextClassName(message.role);
2721
+ const textAlignmentClassName = getMessageTextAlignmentClassName(message.role);
2402
2722
  const orderedParts = useMemo(() => orderMessageParts(message.parts, datasourceToolResultsPosition), [message.parts, datasourceToolResultsPosition]);
2403
2723
  return /* @__PURE__ */ jsxs("div", {
2404
- className: joinClasses("space-y-2", className),
2724
+ className: joinClasses("space-y-2", textAlignmentClassName, className),
2405
2725
  "data-message-role": message.role,
2406
2726
  ...props,
2407
2727
  children: [canCollapse && !isExpanded ? /* @__PURE__ */ jsx("p", {
2408
- className: "whitespace-pre-wrap text-sm leading-6",
2728
+ className: textClassName,
2409
2729
  children: previewText
2410
- }) : orderedParts.map(({ part, index }) => renderPart(part, index, message, isStreaming, onOpenAgentThread, locale, renderText, renderToolCall, renderThinking, thinkingLabel, completedThinkingLabel)), canCollapse ? /* @__PURE__ */ jsx("button", {
2730
+ }) : orderedParts.map(({ part, index }) => renderPart(part, index, message, isStreaming, onOpenAgentThread, locale, renderText, renderToolCall, renderThinking, thinkingLabel, completedThinkingLabel, textClassName)), canCollapse ? /* @__PURE__ */ jsx("button", {
2411
2731
  type: "button",
2412
- className: "text-left text-xs font-medium text-slate-600 hover:text-slate-900",
2732
+ className: "text-xs font-medium text-slate-600 hover:text-slate-900",
2413
2733
  onClick: () => setIsExpanded((previous) => !previous),
2414
2734
  children: isExpanded ? readLessLabel : readMoreLabel
2415
2735
  }) : null]
@@ -3006,5 +3326,5 @@ async function dummyTranscribeAudio(_audio, signal) {
3006
3326
  }
3007
3327
 
3008
3328
  //#endregion
3009
- 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, useChat, useSpeechToText };
3329
+ 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, useChat, useSpeechToText };
3010
3330
  //# sourceMappingURL=index.js.map