@plaisolutions/react 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/index.d.ts +17 -5
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +527 -125
- package/dist/components/index.js.map +1 -1
- package/dist/index.d.ts +74 -62
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +527 -125
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpStatusError, OPEN_TOOL_CONFIRMATION_STATUSES, PlaiChat, ToolDecisionRejectedError, ToolSubmissionConflictError, isHiddenMessage, pendingActionIds, toolConfirmationAt } from "@plaisolutions/client";
|
|
2
2
|
import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
3
|
-
import { ArrowUpRight, Bot, Brain, CalendarDays, Check, CheckCircle2, ChevronDown, ChevronUp, CircleAlert, CircleX, Clock, Copy, Database, Download, File, FileText, Globe, LoaderCircle, Mail, MessageSquare, Paperclip as Paperclip$1, Plug, RotateCcw, ThumbsDown, ThumbsUp, Video, Workflow, X as X$1, XCircle } from "lucide-react";
|
|
3
|
+
import { ArrowUpRight, Bot, Brain, CalendarDays, Check, CheckCircle2, ChevronDown, ChevronUp, CircleAlert, CircleX, Clock, Copy, Database, Download, Eye, File, FilePen, FilePlus2, FileText, Globe, LoaderCircle, Mail, MessageSquare, Paperclip as Paperclip$1, Plug, RotateCcw, Terminal, ThumbsDown, ThumbsUp, TriangleAlert, Video, Workflow, X as X$1, XCircle } from "lucide-react";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
|
|
6
6
|
//#region src/use-tool-confirmations.ts
|
|
@@ -437,6 +437,17 @@ const ENGLISH_COPY = {
|
|
|
437
437
|
officeDocuments: "Office documents",
|
|
438
438
|
creatingDocuments: "Creating documents…",
|
|
439
439
|
noFilesGenerated: "No files were generated.",
|
|
440
|
+
codeExecution: "Code execution",
|
|
441
|
+
codeExecutionSteps: "Steps",
|
|
442
|
+
earlierStepNotShown: "earlier step not shown",
|
|
443
|
+
earlierStepsNotShown: "earlier steps not shown",
|
|
444
|
+
partialResultWarning: "The result may be incomplete",
|
|
445
|
+
exitCode: "Exit code",
|
|
446
|
+
partial: "partial",
|
|
447
|
+
stepCommand: "Command",
|
|
448
|
+
stepFileCreate: "File created",
|
|
449
|
+
stepFileEdit: "File edited",
|
|
450
|
+
stepFileView: "File viewed",
|
|
440
451
|
download: "Download",
|
|
441
452
|
downloading: "Downloading…",
|
|
442
453
|
downloadFailed: "Download failed. Try again.",
|
|
@@ -545,6 +556,17 @@ const TRANSLATIONS = {
|
|
|
545
556
|
officeDocuments: "Documents d’Office",
|
|
546
557
|
creatingDocuments: "Creant documents…",
|
|
547
558
|
noFilesGenerated: "No s’han generat fitxers.",
|
|
559
|
+
codeExecution: "Execució de codi",
|
|
560
|
+
codeExecutionSteps: "Passos",
|
|
561
|
+
earlierStepNotShown: "pas anterior no mostrat",
|
|
562
|
+
earlierStepsNotShown: "passos anteriors no mostrats",
|
|
563
|
+
partialResultWarning: "El resultat pot estar incomplet",
|
|
564
|
+
exitCode: "Codi de sortida",
|
|
565
|
+
partial: "parcial",
|
|
566
|
+
stepCommand: "Ordre",
|
|
567
|
+
stepFileCreate: "Fitxer creat",
|
|
568
|
+
stepFileEdit: "Fitxer editat",
|
|
569
|
+
stepFileView: "Fitxer consultat",
|
|
548
570
|
download: "Baixa",
|
|
549
571
|
downloading: "Baixant…",
|
|
550
572
|
downloadFailed: "No s’ha pogut baixar. Torna-ho a provar.",
|
|
@@ -652,6 +674,17 @@ const TRANSLATIONS = {
|
|
|
652
674
|
officeDocuments: "Office-dokumenter",
|
|
653
675
|
creatingDocuments: "Opretter dokumenter…",
|
|
654
676
|
noFilesGenerated: "Ingen filer blev genereret.",
|
|
677
|
+
codeExecution: "Kodeudførelse",
|
|
678
|
+
codeExecutionSteps: "Trin",
|
|
679
|
+
earlierStepNotShown: "tidligere trin vises ikke",
|
|
680
|
+
earlierStepsNotShown: "tidligere trin vises ikke",
|
|
681
|
+
partialResultWarning: "Resultatet kan være ufuldstændigt",
|
|
682
|
+
exitCode: "Afslutningskode",
|
|
683
|
+
partial: "delvis",
|
|
684
|
+
stepCommand: "Kommando",
|
|
685
|
+
stepFileCreate: "Fil oprettet",
|
|
686
|
+
stepFileEdit: "Fil redigeret",
|
|
687
|
+
stepFileView: "Fil vist",
|
|
655
688
|
download: "Download",
|
|
656
689
|
downloading: "Downloader…",
|
|
657
690
|
downloadFailed: "Download mislykkedes. Prøv igen.",
|
|
@@ -759,6 +792,17 @@ const TRANSLATIONS = {
|
|
|
759
792
|
officeDocuments: "Office-Dokumente",
|
|
760
793
|
creatingDocuments: "Dokumente werden erstellt…",
|
|
761
794
|
noFilesGenerated: "Es wurden keine Dateien erstellt.",
|
|
795
|
+
codeExecution: "Codeausführung",
|
|
796
|
+
codeExecutionSteps: "Schritte",
|
|
797
|
+
earlierStepNotShown: "früherer Schritt nicht angezeigt",
|
|
798
|
+
earlierStepsNotShown: "frühere Schritte nicht angezeigt",
|
|
799
|
+
partialResultWarning: "Das Ergebnis ist möglicherweise unvollständig",
|
|
800
|
+
exitCode: "Exit-Code",
|
|
801
|
+
partial: "teilweise",
|
|
802
|
+
stepCommand: "Befehl",
|
|
803
|
+
stepFileCreate: "Datei erstellt",
|
|
804
|
+
stepFileEdit: "Datei bearbeitet",
|
|
805
|
+
stepFileView: "Datei angezeigt",
|
|
762
806
|
download: "Herunterladen",
|
|
763
807
|
downloading: "Wird heruntergeladen…",
|
|
764
808
|
downloadFailed: "Download fehlgeschlagen. Bitte erneut versuchen.",
|
|
@@ -867,6 +911,17 @@ const TRANSLATIONS = {
|
|
|
867
911
|
officeDocuments: "Documentos de Office",
|
|
868
912
|
creatingDocuments: "Creando documentos…",
|
|
869
913
|
noFilesGenerated: "No se generaron archivos.",
|
|
914
|
+
codeExecution: "Ejecución de código",
|
|
915
|
+
codeExecutionSteps: "Pasos",
|
|
916
|
+
earlierStepNotShown: "paso anterior no mostrado",
|
|
917
|
+
earlierStepsNotShown: "pasos anteriores no mostrados",
|
|
918
|
+
partialResultWarning: "El resultado puede estar incompleto",
|
|
919
|
+
exitCode: "Código de salida",
|
|
920
|
+
partial: "parcial",
|
|
921
|
+
stepCommand: "Comando",
|
|
922
|
+
stepFileCreate: "Archivo creado",
|
|
923
|
+
stepFileEdit: "Archivo editado",
|
|
924
|
+
stepFileView: "Archivo consultado",
|
|
870
925
|
download: "Descargar",
|
|
871
926
|
downloading: "Descargando…",
|
|
872
927
|
downloadFailed: "No se pudo descargar. Inténtalo de nuevo.",
|
|
@@ -974,6 +1029,17 @@ const TRANSLATIONS = {
|
|
|
974
1029
|
officeDocuments: "Documents Office",
|
|
975
1030
|
creatingDocuments: "Création des documents…",
|
|
976
1031
|
noFilesGenerated: "Aucun fichier n’a été généré.",
|
|
1032
|
+
codeExecution: "Exécution de code",
|
|
1033
|
+
codeExecutionSteps: "Étapes",
|
|
1034
|
+
earlierStepNotShown: "étape précédente non affichée",
|
|
1035
|
+
earlierStepsNotShown: "étapes précédentes non affichées",
|
|
1036
|
+
partialResultWarning: "Le résultat peut être incomplet",
|
|
1037
|
+
exitCode: "Code de sortie",
|
|
1038
|
+
partial: "partiel",
|
|
1039
|
+
stepCommand: "Commande",
|
|
1040
|
+
stepFileCreate: "Fichier créé",
|
|
1041
|
+
stepFileEdit: "Fichier modifié",
|
|
1042
|
+
stepFileView: "Fichier consulté",
|
|
977
1043
|
download: "Télécharger",
|
|
978
1044
|
downloading: "Téléchargement…",
|
|
979
1045
|
downloadFailed: "Échec du téléchargement. Réessayez.",
|
|
@@ -1081,6 +1147,17 @@ const TRANSLATIONS = {
|
|
|
1081
1147
|
officeDocuments: "Documenti Office",
|
|
1082
1148
|
creatingDocuments: "Creazione dei documenti…",
|
|
1083
1149
|
noFilesGenerated: "Nessun file generato.",
|
|
1150
|
+
codeExecution: "Esecuzione del codice",
|
|
1151
|
+
codeExecutionSteps: "Passaggi",
|
|
1152
|
+
earlierStepNotShown: "passaggio precedente non mostrato",
|
|
1153
|
+
earlierStepsNotShown: "passaggi precedenti non mostrati",
|
|
1154
|
+
partialResultWarning: "Il risultato potrebbe essere incompleto",
|
|
1155
|
+
exitCode: "Codice di uscita",
|
|
1156
|
+
partial: "parziale",
|
|
1157
|
+
stepCommand: "Comando",
|
|
1158
|
+
stepFileCreate: "File creato",
|
|
1159
|
+
stepFileEdit: "File modificato",
|
|
1160
|
+
stepFileView: "File visualizzato",
|
|
1084
1161
|
download: "Scarica",
|
|
1085
1162
|
downloading: "Download in corso…",
|
|
1086
1163
|
downloadFailed: "Download non riuscito. Riprova.",
|
|
@@ -1188,6 +1265,17 @@ const TRANSLATIONS = {
|
|
|
1188
1265
|
officeDocuments: "Office-dokumenter",
|
|
1189
1266
|
creatingDocuments: "Oppretter dokumenter…",
|
|
1190
1267
|
noFilesGenerated: "Ingen filer ble generert.",
|
|
1268
|
+
codeExecution: "Kodekjøring",
|
|
1269
|
+
codeExecutionSteps: "Trinn",
|
|
1270
|
+
earlierStepNotShown: "tidligere trinn vises ikke",
|
|
1271
|
+
earlierStepsNotShown: "tidligere trinn vises ikke",
|
|
1272
|
+
partialResultWarning: "Resultatet kan være ufullstendig",
|
|
1273
|
+
exitCode: "Avslutningskode",
|
|
1274
|
+
partial: "delvis",
|
|
1275
|
+
stepCommand: "Kommando",
|
|
1276
|
+
stepFileCreate: "Fil opprettet",
|
|
1277
|
+
stepFileEdit: "Fil redigert",
|
|
1278
|
+
stepFileView: "Fil vist",
|
|
1191
1279
|
download: "Last ned",
|
|
1192
1280
|
downloading: "Laster ned…",
|
|
1193
1281
|
downloadFailed: "Nedlastingen mislyktes. Prøv igjen.",
|
|
@@ -1295,6 +1383,17 @@ const TRANSLATIONS = {
|
|
|
1295
1383
|
officeDocuments: "Documentos do Office",
|
|
1296
1384
|
creatingDocuments: "A criar documentos…",
|
|
1297
1385
|
noFilesGenerated: "Não foram gerados ficheiros.",
|
|
1386
|
+
codeExecution: "Execução de código",
|
|
1387
|
+
codeExecutionSteps: "Passos",
|
|
1388
|
+
earlierStepNotShown: "passo anterior não apresentado",
|
|
1389
|
+
earlierStepsNotShown: "passos anteriores não apresentados",
|
|
1390
|
+
partialResultWarning: "O resultado pode estar incompleto",
|
|
1391
|
+
exitCode: "Código de saída",
|
|
1392
|
+
partial: "parcial",
|
|
1393
|
+
stepCommand: "Comando",
|
|
1394
|
+
stepFileCreate: "Ficheiro criado",
|
|
1395
|
+
stepFileEdit: "Ficheiro editado",
|
|
1396
|
+
stepFileView: "Ficheiro consultado",
|
|
1298
1397
|
download: "Transferir",
|
|
1299
1398
|
downloading: "A transferir…",
|
|
1300
1399
|
downloadFailed: "Não foi possível transferir. Tente novamente.",
|
|
@@ -1402,6 +1501,17 @@ const TRANSLATIONS = {
|
|
|
1402
1501
|
officeDocuments: "Office-dokument",
|
|
1403
1502
|
creatingDocuments: "Skapar dokument…",
|
|
1404
1503
|
noFilesGenerated: "Inga filer genererades.",
|
|
1504
|
+
codeExecution: "Kodkörning",
|
|
1505
|
+
codeExecutionSteps: "Steg",
|
|
1506
|
+
earlierStepNotShown: "tidigare steg visas inte",
|
|
1507
|
+
earlierStepsNotShown: "tidigare steg visas inte",
|
|
1508
|
+
partialResultWarning: "Resultatet kan vara ofullständigt",
|
|
1509
|
+
exitCode: "Slutkod",
|
|
1510
|
+
partial: "delvis",
|
|
1511
|
+
stepCommand: "Kommando",
|
|
1512
|
+
stepFileCreate: "Fil skapad",
|
|
1513
|
+
stepFileEdit: "Fil redigerad",
|
|
1514
|
+
stepFileView: "Fil visad",
|
|
1405
1515
|
download: "Ladda ned",
|
|
1406
1516
|
downloading: "Laddar ned…",
|
|
1407
1517
|
downloadFailed: "Nedladdningen misslyckades. Försök igen.",
|
|
@@ -3456,6 +3566,322 @@ function ToolResultBrowserCard({ part, className, locale }) {
|
|
|
3456
3566
|
});
|
|
3457
3567
|
}
|
|
3458
3568
|
|
|
3569
|
+
//#endregion
|
|
3570
|
+
//#region src/components/internal/download-file.ts
|
|
3571
|
+
/**
|
|
3572
|
+
* Single entry point for downloading a chat file.
|
|
3573
|
+
*
|
|
3574
|
+
* Fetches the bytes and saves them under the file name, so the browser neither
|
|
3575
|
+
* navigates nor opens a tab. That read needs the file host to allow this origin
|
|
3576
|
+
* (CORS); when it does not, the URL opens in a new tab instead. An HTTP error
|
|
3577
|
+
* (expired, deleted or private object) rejects so the caller can say so.
|
|
3578
|
+
*/
|
|
3579
|
+
async function downloadFile(file) {
|
|
3580
|
+
let response;
|
|
3581
|
+
try {
|
|
3582
|
+
response = await fetch(file.url, { credentials: "omit" });
|
|
3583
|
+
} catch {
|
|
3584
|
+
openInNewTab(file.url);
|
|
3585
|
+
return;
|
|
3586
|
+
}
|
|
3587
|
+
if (!response.ok) throw new Error(`Download failed with status ${response.status}`);
|
|
3588
|
+
saveBlob(await response.blob(), file.name || getFilenameFromUrl(file.url) || "download");
|
|
3589
|
+
}
|
|
3590
|
+
function saveBlob(blob, fileName) {
|
|
3591
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
3592
|
+
const anchor = document.createElement("a");
|
|
3593
|
+
anchor.href = objectUrl;
|
|
3594
|
+
anchor.download = fileName;
|
|
3595
|
+
anchor.rel = "noopener";
|
|
3596
|
+
anchor.style.display = "none";
|
|
3597
|
+
document.body.appendChild(anchor);
|
|
3598
|
+
anchor.click();
|
|
3599
|
+
anchor.remove();
|
|
3600
|
+
window.setTimeout(() => URL.revokeObjectURL(objectUrl), 1e3);
|
|
3601
|
+
}
|
|
3602
|
+
function openInNewTab(url) {
|
|
3603
|
+
window.open(url, "_blank", "noopener,noreferrer");
|
|
3604
|
+
}
|
|
3605
|
+
|
|
3606
|
+
//#endregion
|
|
3607
|
+
//#region src/components/internal/file-download-button.tsx
|
|
3608
|
+
function FileDownloadButton({ file, label, copy, className }) {
|
|
3609
|
+
const [state, setState] = useState("idle");
|
|
3610
|
+
const isDownloading = state === "downloading";
|
|
3611
|
+
const handleClick = async (event) => {
|
|
3612
|
+
event.stopPropagation();
|
|
3613
|
+
if (isDownloading) return;
|
|
3614
|
+
setState("downloading");
|
|
3615
|
+
try {
|
|
3616
|
+
await downloadFile(file);
|
|
3617
|
+
setState("idle");
|
|
3618
|
+
} catch {
|
|
3619
|
+
setState("error");
|
|
3620
|
+
}
|
|
3621
|
+
};
|
|
3622
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
3623
|
+
className: "ml-auto flex shrink-0 items-center gap-2",
|
|
3624
|
+
children: [state === "error" ? /* @__PURE__ */ jsx("span", {
|
|
3625
|
+
role: "alert",
|
|
3626
|
+
className: "text-xs text-danger",
|
|
3627
|
+
children: copy.downloadFailed
|
|
3628
|
+
}) : null, /* @__PURE__ */ jsx("button", {
|
|
3629
|
+
type: "button",
|
|
3630
|
+
onClick: handleClick,
|
|
3631
|
+
disabled: isDownloading,
|
|
3632
|
+
"aria-label": `${isDownloading ? copy.downloading : copy.download}: ${label}`,
|
|
3633
|
+
title: isDownloading ? copy.downloading : copy.download,
|
|
3634
|
+
className: joinClasses("inline-flex h-8 w-8 items-center justify-center rounded-md border border-border bg-surface text-strong transition-colors hover:bg-surface-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:cursor-wait disabled:opacity-60", className),
|
|
3635
|
+
children: isDownloading ? /* @__PURE__ */ jsx(LoaderCircle, {
|
|
3636
|
+
className: "h-4 w-4 animate-spin",
|
|
3637
|
+
"aria-hidden": "true"
|
|
3638
|
+
}) : /* @__PURE__ */ jsx(Download, {
|
|
3639
|
+
className: "h-4 w-4",
|
|
3640
|
+
"aria-hidden": "true"
|
|
3641
|
+
})
|
|
3642
|
+
})]
|
|
3643
|
+
});
|
|
3644
|
+
}
|
|
3645
|
+
|
|
3646
|
+
//#endregion
|
|
3647
|
+
//#region src/components/internal/generated-files.tsx
|
|
3648
|
+
/** Keeps the entries of `metadata.media_files` that look like a media file. */
|
|
3649
|
+
function getGeneratedFiles(files) {
|
|
3650
|
+
return Array.isArray(files) ? files.filter((file) => Boolean(file) && typeof file === "object" && typeof file.id === "string") : [];
|
|
3651
|
+
}
|
|
3652
|
+
function getGeneratedFileExtension(file) {
|
|
3653
|
+
return getFileExtension(file.name ?? file.pathname, file.content_type);
|
|
3654
|
+
}
|
|
3655
|
+
function getGeneratedFileLabel(file) {
|
|
3656
|
+
return file.name ?? file.pathname ?? file.id;
|
|
3657
|
+
}
|
|
3658
|
+
/** A generated file with its extension and a download button, for a sheet. */
|
|
3659
|
+
function GeneratedFileRow({ file, copy }) {
|
|
3660
|
+
const extension = getGeneratedFileExtension(file);
|
|
3661
|
+
const label = getGeneratedFileLabel(file);
|
|
3662
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3663
|
+
className: "flex items-center gap-3 rounded-lg border border-border bg-surface p-3",
|
|
3664
|
+
children: [
|
|
3665
|
+
/* @__PURE__ */ jsx(File, {
|
|
3666
|
+
className: joinClasses("h-8 w-8 shrink-0", getFileIconClass(extension)),
|
|
3667
|
+
"aria-hidden": "true"
|
|
3668
|
+
}),
|
|
3669
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3670
|
+
className: "min-w-0",
|
|
3671
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
3672
|
+
className: "truncate text-sm font-medium",
|
|
3673
|
+
children: label
|
|
3674
|
+
}), extension ? /* @__PURE__ */ jsx("p", {
|
|
3675
|
+
className: "text-[11px] uppercase text-muted",
|
|
3676
|
+
children: extension
|
|
3677
|
+
}) : null]
|
|
3678
|
+
}),
|
|
3679
|
+
file.url ? /* @__PURE__ */ jsx(FileDownloadButton, {
|
|
3680
|
+
file: {
|
|
3681
|
+
url: file.url,
|
|
3682
|
+
name: file.name
|
|
3683
|
+
},
|
|
3684
|
+
label,
|
|
3685
|
+
copy
|
|
3686
|
+
}) : null
|
|
3687
|
+
]
|
|
3688
|
+
});
|
|
3689
|
+
}
|
|
3690
|
+
|
|
3691
|
+
//#endregion
|
|
3692
|
+
//#region src/components/tool-result-code-execution-card.tsx
|
|
3693
|
+
const STEP_ICONS = {
|
|
3694
|
+
command: Terminal,
|
|
3695
|
+
file_create: FilePlus2,
|
|
3696
|
+
file_edit: FilePen,
|
|
3697
|
+
file_view: Eye
|
|
3698
|
+
};
|
|
3699
|
+
const STEP_LABELS = {
|
|
3700
|
+
command: "stepCommand",
|
|
3701
|
+
file_create: "stepFileCreate",
|
|
3702
|
+
file_edit: "stepFileEdit",
|
|
3703
|
+
file_view: "stepFileView"
|
|
3704
|
+
};
|
|
3705
|
+
function isStepKind(value) {
|
|
3706
|
+
return typeof value === "string" && value in STEP_ICONS;
|
|
3707
|
+
}
|
|
3708
|
+
function getSteps(part) {
|
|
3709
|
+
const steps = part.metadata?.steps;
|
|
3710
|
+
if (!Array.isArray(steps)) return [];
|
|
3711
|
+
return steps.flatMap((step) => {
|
|
3712
|
+
if (!step || typeof step !== "object" || !isStepKind(step.kind)) return [];
|
|
3713
|
+
return [{
|
|
3714
|
+
kind: step.kind,
|
|
3715
|
+
input: typeof step.input === "string" ? step.input : "",
|
|
3716
|
+
output: typeof step.output === "string" ? step.output : "",
|
|
3717
|
+
exit_code: typeof step.exit_code === "number" ? step.exit_code : null
|
|
3718
|
+
}];
|
|
3719
|
+
});
|
|
3720
|
+
}
|
|
3721
|
+
function getStatus(part) {
|
|
3722
|
+
if (part.state === "error") return "error";
|
|
3723
|
+
const status = part.metadata?.status;
|
|
3724
|
+
return status === "partial" || status === "error" ? status : "success";
|
|
3725
|
+
}
|
|
3726
|
+
function getErrorMessage(part) {
|
|
3727
|
+
const message = part.metadata?.error_details?.error_message;
|
|
3728
|
+
if (typeof message === "string" && message.trim()) return message;
|
|
3729
|
+
return formatToolErrorDetails(part.errorDetails);
|
|
3730
|
+
}
|
|
3731
|
+
function ToolResultCodeExecutionCard({ part, className, locale }) {
|
|
3732
|
+
const copy = getUiCopy(locale);
|
|
3733
|
+
const files = getGeneratedFiles(part.metadata?.media_files);
|
|
3734
|
+
const steps = getSteps(part);
|
|
3735
|
+
const stepsOmitted = part.metadata?.steps_omitted;
|
|
3736
|
+
const omitted = typeof stepsOmitted === "number" && stepsOmitted > 0 ? stepsOmitted : 0;
|
|
3737
|
+
const pending = part.state === "pending";
|
|
3738
|
+
const status = pending ? null : getStatus(part);
|
|
3739
|
+
const errorMessage = status === "error" ? getErrorMessage(part) : null;
|
|
3740
|
+
const fileLabel = files.length === 1 ? copy.file : copy.files;
|
|
3741
|
+
const summary = pending ? copy.pending : status === "error" ? copy.error : status === "partial" ? copy.partial : files.length > 0 ? `${files.length} ${fileLabel}` : copy.completed;
|
|
3742
|
+
return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsx(SheetTrigger, {
|
|
3743
|
+
"aria-label": `${copy.codeExecution}: ${summary}`,
|
|
3744
|
+
"data-status": status ?? "pending",
|
|
3745
|
+
className: joinClasses("plai-tool-result-code-execution-card w-full overflow-hidden rounded-lg border border-border bg-surface text-left font-normal text-foreground transition-colors hover:bg-surface-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring", className),
|
|
3746
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
3747
|
+
className: "flex items-center gap-2 px-3 py-2 text-sm",
|
|
3748
|
+
children: [
|
|
3749
|
+
/* @__PURE__ */ jsx(Terminal, {
|
|
3750
|
+
className: "h-4 w-4 shrink-0 text-muted",
|
|
3751
|
+
"aria-hidden": "true"
|
|
3752
|
+
}),
|
|
3753
|
+
/* @__PURE__ */ jsx("span", {
|
|
3754
|
+
className: "truncate font-medium",
|
|
3755
|
+
children: copy.codeExecution
|
|
3756
|
+
}),
|
|
3757
|
+
/* @__PURE__ */ jsx("span", {
|
|
3758
|
+
className: "min-w-0 truncate border-border-strong border px-2 py-0.5 rounded-md text-xs text-muted",
|
|
3759
|
+
children: summary
|
|
3760
|
+
}),
|
|
3761
|
+
/* @__PURE__ */ jsx("span", {
|
|
3762
|
+
className: joinClasses("ml-auto shrink-0", status === "error" ? "text-danger" : status === "partial" ? "text-warning" : "text-success"),
|
|
3763
|
+
children: status === "error" ? /* @__PURE__ */ jsx(XCircle, {
|
|
3764
|
+
className: "h-4 w-4",
|
|
3765
|
+
"aria-hidden": "true"
|
|
3766
|
+
}) : status === "partial" ? /* @__PURE__ */ jsx(TriangleAlert, {
|
|
3767
|
+
className: "h-4 w-4",
|
|
3768
|
+
"aria-hidden": "true"
|
|
3769
|
+
}) : status === "success" ? /* @__PURE__ */ jsx(CheckCircle2, {
|
|
3770
|
+
className: "h-4 w-4",
|
|
3771
|
+
"aria-hidden": "true"
|
|
3772
|
+
}) : null
|
|
3773
|
+
})
|
|
3774
|
+
]
|
|
3775
|
+
})
|
|
3776
|
+
}), /* @__PURE__ */ jsxs(SheetContent, {
|
|
3777
|
+
locale,
|
|
3778
|
+
children: [/* @__PURE__ */ jsx(SheetHeader, {
|
|
3779
|
+
className: "pr-10",
|
|
3780
|
+
children: /* @__PURE__ */ jsx(SheetTitle, { children: copy.codeExecution })
|
|
3781
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
3782
|
+
className: "mt-6 space-y-6",
|
|
3783
|
+
children: [
|
|
3784
|
+
status === "partial" ? /* @__PURE__ */ jsxs("output", {
|
|
3785
|
+
className: "flex items-center gap-2 rounded border border-warning-border bg-warning-subtle px-3 py-2 text-xs text-warning-strong",
|
|
3786
|
+
children: [/* @__PURE__ */ jsx(TriangleAlert, {
|
|
3787
|
+
className: "h-4 w-4 shrink-0",
|
|
3788
|
+
"aria-hidden": "true"
|
|
3789
|
+
}), copy.partialResultWarning]
|
|
3790
|
+
}) : null,
|
|
3791
|
+
errorMessage ? /* @__PURE__ */ jsxs("p", {
|
|
3792
|
+
role: "alert",
|
|
3793
|
+
className: "rounded border border-danger-border bg-danger-subtle px-3 py-2 text-xs text-danger-strong",
|
|
3794
|
+
children: [
|
|
3795
|
+
/* @__PURE__ */ jsxs("span", {
|
|
3796
|
+
className: "font-semibold",
|
|
3797
|
+
children: [copy.errorDetails, ":"]
|
|
3798
|
+
}),
|
|
3799
|
+
" ",
|
|
3800
|
+
errorMessage
|
|
3801
|
+
]
|
|
3802
|
+
}) : null,
|
|
3803
|
+
files.length > 0 || status === "success" ? /* @__PURE__ */ jsxs("section", {
|
|
3804
|
+
className: "space-y-3",
|
|
3805
|
+
"aria-label": copy.generatedFiles,
|
|
3806
|
+
children: [files.map((file) => /* @__PURE__ */ jsx(GeneratedFileRow, {
|
|
3807
|
+
file,
|
|
3808
|
+
copy
|
|
3809
|
+
}, file.id)), files.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
3810
|
+
className: "text-sm text-secondary",
|
|
3811
|
+
children: copy.noFilesGenerated
|
|
3812
|
+
}) : null]
|
|
3813
|
+
}) : null,
|
|
3814
|
+
steps.length > 0 ? /* @__PURE__ */ jsxs("section", {
|
|
3815
|
+
className: "space-y-3",
|
|
3816
|
+
"aria-label": copy.codeExecutionSteps,
|
|
3817
|
+
children: [
|
|
3818
|
+
/* @__PURE__ */ jsx("h3", {
|
|
3819
|
+
className: "text-xs font-semibold uppercase tracking-wide text-muted",
|
|
3820
|
+
children: copy.codeExecutionSteps
|
|
3821
|
+
}),
|
|
3822
|
+
omitted > 0 ? /* @__PURE__ */ jsxs("p", {
|
|
3823
|
+
className: "text-xs text-muted",
|
|
3824
|
+
children: [
|
|
3825
|
+
omitted,
|
|
3826
|
+
" ",
|
|
3827
|
+
omitted === 1 ? copy.earlierStepNotShown : copy.earlierStepsNotShown
|
|
3828
|
+
]
|
|
3829
|
+
}) : null,
|
|
3830
|
+
/* @__PURE__ */ jsx("ol", {
|
|
3831
|
+
className: "space-y-2",
|
|
3832
|
+
children: steps.map((step, index) => /* @__PURE__ */ jsx(CodeExecutionStepItem, {
|
|
3833
|
+
step,
|
|
3834
|
+
copy
|
|
3835
|
+
}, index))
|
|
3836
|
+
})
|
|
3837
|
+
]
|
|
3838
|
+
}) : null
|
|
3839
|
+
]
|
|
3840
|
+
})]
|
|
3841
|
+
})] });
|
|
3842
|
+
}
|
|
3843
|
+
function CodeExecutionStepItem({ step, copy }) {
|
|
3844
|
+
const Icon = STEP_ICONS[step.kind];
|
|
3845
|
+
const label = copy[STEP_LABELS[step.kind]];
|
|
3846
|
+
const failed = step.exit_code !== null && step.exit_code !== 0;
|
|
3847
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
3848
|
+
"data-step-kind": step.kind,
|
|
3849
|
+
"data-step-failed": failed ? "true" : void 0,
|
|
3850
|
+
className: joinClasses("space-y-2 rounded-lg border bg-surface p-3", failed ? "border-danger-border" : "border-border"),
|
|
3851
|
+
children: [
|
|
3852
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3853
|
+
className: "flex items-center gap-2 text-xs text-muted",
|
|
3854
|
+
children: [
|
|
3855
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
3856
|
+
className: "h-4 w-4 shrink-0",
|
|
3857
|
+
"aria-hidden": "true"
|
|
3858
|
+
}),
|
|
3859
|
+
/* @__PURE__ */ jsx("span", {
|
|
3860
|
+
className: "font-medium",
|
|
3861
|
+
children: label
|
|
3862
|
+
}),
|
|
3863
|
+
failed ? /* @__PURE__ */ jsxs("span", {
|
|
3864
|
+
className: "ml-auto rounded border border-danger-border bg-danger-subtle px-2 py-0.5 text-danger-strong",
|
|
3865
|
+
children: [
|
|
3866
|
+
copy.exitCode,
|
|
3867
|
+
" ",
|
|
3868
|
+
step.exit_code
|
|
3869
|
+
]
|
|
3870
|
+
}) : null
|
|
3871
|
+
]
|
|
3872
|
+
}),
|
|
3873
|
+
step.input ? /* @__PURE__ */ jsx("pre", {
|
|
3874
|
+
className: "overflow-x-auto whitespace-pre-wrap break-words rounded-md border border-border bg-surface-muted p-2 font-mono text-xs leading-5",
|
|
3875
|
+
children: step.input
|
|
3876
|
+
}) : null,
|
|
3877
|
+
step.output ? /* @__PURE__ */ jsx("pre", {
|
|
3878
|
+
className: joinClasses("max-h-40 overflow-auto whitespace-pre-wrap break-words rounded-md p-2 font-mono text-xs leading-5", failed ? "border border-danger-border bg-danger-subtle text-danger-strong" : "bg-inverse text-inverse-foreground"),
|
|
3879
|
+
children: step.output
|
|
3880
|
+
}) : null
|
|
3881
|
+
]
|
|
3882
|
+
});
|
|
3883
|
+
}
|
|
3884
|
+
|
|
3459
3885
|
//#endregion
|
|
3460
3886
|
//#region src/components/tool-result-email-send-card.tsx
|
|
3461
3887
|
function asObject(value) {
|
|
@@ -4062,94 +4488,16 @@ function ToolResultMcpCard({ part, className, locale }) {
|
|
|
4062
4488
|
})] });
|
|
4063
4489
|
}
|
|
4064
4490
|
|
|
4065
|
-
//#endregion
|
|
4066
|
-
//#region src/components/internal/download-file.ts
|
|
4067
|
-
/**
|
|
4068
|
-
* Single entry point for downloading a chat file.
|
|
4069
|
-
*
|
|
4070
|
-
* Fetches the bytes and saves them under the file name, so the browser neither
|
|
4071
|
-
* navigates nor opens a tab. That read needs the file host to allow this origin
|
|
4072
|
-
* (CORS); when it does not, the URL opens in a new tab instead. An HTTP error
|
|
4073
|
-
* (expired, deleted or private object) rejects so the caller can say so.
|
|
4074
|
-
*/
|
|
4075
|
-
async function downloadFile(file) {
|
|
4076
|
-
let response;
|
|
4077
|
-
try {
|
|
4078
|
-
response = await fetch(file.url, { credentials: "omit" });
|
|
4079
|
-
} catch {
|
|
4080
|
-
openInNewTab(file.url);
|
|
4081
|
-
return;
|
|
4082
|
-
}
|
|
4083
|
-
if (!response.ok) throw new Error(`Download failed with status ${response.status}`);
|
|
4084
|
-
saveBlob(await response.blob(), file.name || getFilenameFromUrl(file.url) || "download");
|
|
4085
|
-
}
|
|
4086
|
-
function saveBlob(blob, fileName) {
|
|
4087
|
-
const objectUrl = URL.createObjectURL(blob);
|
|
4088
|
-
const anchor = document.createElement("a");
|
|
4089
|
-
anchor.href = objectUrl;
|
|
4090
|
-
anchor.download = fileName;
|
|
4091
|
-
anchor.rel = "noopener";
|
|
4092
|
-
anchor.style.display = "none";
|
|
4093
|
-
document.body.appendChild(anchor);
|
|
4094
|
-
anchor.click();
|
|
4095
|
-
anchor.remove();
|
|
4096
|
-
window.setTimeout(() => URL.revokeObjectURL(objectUrl), 1e3);
|
|
4097
|
-
}
|
|
4098
|
-
function openInNewTab(url) {
|
|
4099
|
-
window.open(url, "_blank", "noopener,noreferrer");
|
|
4100
|
-
}
|
|
4101
|
-
|
|
4102
|
-
//#endregion
|
|
4103
|
-
//#region src/components/internal/file-download-button.tsx
|
|
4104
|
-
function FileDownloadButton({ file, label, copy, className }) {
|
|
4105
|
-
const [state, setState] = useState("idle");
|
|
4106
|
-
const isDownloading = state === "downloading";
|
|
4107
|
-
const handleClick = async (event) => {
|
|
4108
|
-
event.stopPropagation();
|
|
4109
|
-
if (isDownloading) return;
|
|
4110
|
-
setState("downloading");
|
|
4111
|
-
try {
|
|
4112
|
-
await downloadFile(file);
|
|
4113
|
-
setState("idle");
|
|
4114
|
-
} catch {
|
|
4115
|
-
setState("error");
|
|
4116
|
-
}
|
|
4117
|
-
};
|
|
4118
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
4119
|
-
className: "ml-auto flex shrink-0 items-center gap-2",
|
|
4120
|
-
children: [state === "error" ? /* @__PURE__ */ jsx("span", {
|
|
4121
|
-
role: "alert",
|
|
4122
|
-
className: "text-xs text-danger",
|
|
4123
|
-
children: copy.downloadFailed
|
|
4124
|
-
}) : null, /* @__PURE__ */ jsx("button", {
|
|
4125
|
-
type: "button",
|
|
4126
|
-
onClick: handleClick,
|
|
4127
|
-
disabled: isDownloading,
|
|
4128
|
-
"aria-label": `${isDownloading ? copy.downloading : copy.download}: ${label}`,
|
|
4129
|
-
title: isDownloading ? copy.downloading : copy.download,
|
|
4130
|
-
className: joinClasses("inline-flex h-8 w-8 items-center justify-center rounded-md border border-border bg-surface text-strong transition-colors hover:bg-surface-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:cursor-wait disabled:opacity-60", className),
|
|
4131
|
-
children: isDownloading ? /* @__PURE__ */ jsx(LoaderCircle, {
|
|
4132
|
-
className: "h-4 w-4 animate-spin",
|
|
4133
|
-
"aria-hidden": "true"
|
|
4134
|
-
}) : /* @__PURE__ */ jsx(Download, {
|
|
4135
|
-
className: "h-4 w-4",
|
|
4136
|
-
"aria-hidden": "true"
|
|
4137
|
-
})
|
|
4138
|
-
})]
|
|
4139
|
-
});
|
|
4140
|
-
}
|
|
4141
|
-
|
|
4142
4491
|
//#endregion
|
|
4143
4492
|
//#region src/components/tool-result-office-documents-card.tsx
|
|
4144
4493
|
function getFiles(part) {
|
|
4145
|
-
|
|
4146
|
-
return Array.isArray(files) ? files.filter((file) => Boolean(file) && typeof file === "object" && typeof file.id === "string") : [];
|
|
4494
|
+
return getGeneratedFiles(part.metadata?.media_files);
|
|
4147
4495
|
}
|
|
4148
4496
|
function getExtension(file) {
|
|
4149
|
-
return
|
|
4497
|
+
return getGeneratedFileExtension(file);
|
|
4150
4498
|
}
|
|
4151
4499
|
function getLabel(file) {
|
|
4152
|
-
return file
|
|
4500
|
+
return getGeneratedFileLabel(file);
|
|
4153
4501
|
}
|
|
4154
4502
|
function ToolResultOfficeDocumentsCard({ part, className, locale }) {
|
|
4155
4503
|
const copy = getUiCopy(locale);
|
|
@@ -4232,37 +4580,10 @@ function ToolResultOfficeDocumentsCard({ part, className, locale }) {
|
|
|
4232
4580
|
className: "mt-6 space-y-3",
|
|
4233
4581
|
"aria-label": copy.generatedFiles,
|
|
4234
4582
|
children: [
|
|
4235
|
-
files.map((file) => {
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
className: "flex items-center gap-3 rounded-lg border border-border bg-surface p-3",
|
|
4240
|
-
children: [
|
|
4241
|
-
/* @__PURE__ */ jsx(File, {
|
|
4242
|
-
className: joinClasses("h-8 w-8 shrink-0", getFileIconClass(extension)),
|
|
4243
|
-
"aria-hidden": "true"
|
|
4244
|
-
}),
|
|
4245
|
-
/* @__PURE__ */ jsxs("div", {
|
|
4246
|
-
className: "min-w-0",
|
|
4247
|
-
children: [/* @__PURE__ */ jsx("p", {
|
|
4248
|
-
className: "truncate text-sm font-medium",
|
|
4249
|
-
children: label
|
|
4250
|
-
}), extension ? /* @__PURE__ */ jsx("p", {
|
|
4251
|
-
className: "text-[11px] uppercase text-muted",
|
|
4252
|
-
children: extension
|
|
4253
|
-
}) : null]
|
|
4254
|
-
}),
|
|
4255
|
-
file.url ? /* @__PURE__ */ jsx(FileDownloadButton, {
|
|
4256
|
-
file: {
|
|
4257
|
-
url: file.url,
|
|
4258
|
-
name: file.name
|
|
4259
|
-
},
|
|
4260
|
-
label,
|
|
4261
|
-
copy
|
|
4262
|
-
}) : null
|
|
4263
|
-
]
|
|
4264
|
-
}, file.id);
|
|
4265
|
-
}),
|
|
4583
|
+
files.map((file) => /* @__PURE__ */ jsx(GeneratedFileRow, {
|
|
4584
|
+
file,
|
|
4585
|
+
copy
|
|
4586
|
+
}, file.id)),
|
|
4266
4587
|
files.length === 0 && part.state === "pending" ? /* @__PURE__ */ jsx("p", {
|
|
4267
4588
|
className: "text-sm text-secondary",
|
|
4268
4589
|
children: copy.creatingDocuments
|
|
@@ -5739,16 +6060,28 @@ function expiryText(state, serverOffsetMs, now, copy) {
|
|
|
5739
6060
|
function saveLabel(operation, copy) {
|
|
5740
6061
|
return operation === "send" ? copy.saveAndSend : copy.saveAndConfirm;
|
|
5741
6062
|
}
|
|
5742
|
-
|
|
6063
|
+
const HIGHLIGHT = [
|
|
6064
|
+
"ring-2",
|
|
6065
|
+
"ring-border-strong",
|
|
6066
|
+
"transition-shadow"
|
|
6067
|
+
];
|
|
6068
|
+
/**
|
|
6069
|
+
* Scrolls to the card of another version of the same action and flashes it, so the eye finds
|
|
6070
|
+
* it. Returns whether that card is on screen (it may not be, e.g. older history not loaded).
|
|
6071
|
+
*/
|
|
5743
6072
|
function showAction(actionId) {
|
|
5744
|
-
if (typeof document === "undefined") return;
|
|
5745
|
-
for (const element of document.querySelectorAll("[data-confirmation-action]"))
|
|
6073
|
+
if (typeof document === "undefined") return false;
|
|
6074
|
+
for (const element of document.querySelectorAll("[data-confirmation-action]")) {
|
|
6075
|
+
if (element.getAttribute("data-confirmation-action") !== actionId) continue;
|
|
5746
6076
|
element.scrollIntoView?.({
|
|
5747
6077
|
block: "center",
|
|
5748
6078
|
behavior: "smooth"
|
|
5749
6079
|
});
|
|
5750
|
-
|
|
6080
|
+
element.classList.add(...HIGHLIGHT);
|
|
6081
|
+
setTimeout(() => element.classList.remove(...HIGHLIGHT), 1600);
|
|
6082
|
+
return true;
|
|
5751
6083
|
}
|
|
6084
|
+
return false;
|
|
5752
6085
|
}
|
|
5753
6086
|
/**
|
|
5754
6087
|
* Footer of a held action. Without `toolConfirmation` it keeps the text hint
|
|
@@ -6536,8 +6869,46 @@ function ToolResultPersonalConnectorCard({ part, locale, className, toolConfirma
|
|
|
6536
6869
|
const Icon = isCalendar(connector) ? CalendarDays : Mail;
|
|
6537
6870
|
const total = headerCount(view, copy);
|
|
6538
6871
|
const isPending = view.kind === "pending-mail" || view.kind === "pending-event";
|
|
6872
|
+
if (pending && confirmationState?.status === "superseded") {
|
|
6873
|
+
const summary = text(pending.action.subject) ?? text(pending.action.title) ?? copy.noSubject;
|
|
6874
|
+
return /* @__PURE__ */ jsx("section", {
|
|
6875
|
+
className: joinClasses("plai-tool-result-personal-connector-card plai-superseded overflow-hidden rounded-lg border border-border bg-surface text-foreground", className),
|
|
6876
|
+
"data-tool-call-id": part.id,
|
|
6877
|
+
"data-tool-call-state": part.state,
|
|
6878
|
+
"data-connector-action": view.kind,
|
|
6879
|
+
"data-confirmation-action": pending.action_id,
|
|
6880
|
+
"data-confirmation-status": "superseded",
|
|
6881
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
6882
|
+
className: "flex flex-wrap items-center gap-x-2 gap-y-1 px-3 py-2 text-xs text-secondary",
|
|
6883
|
+
children: [
|
|
6884
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
6885
|
+
className: "h-4 w-4 shrink-0 text-muted",
|
|
6886
|
+
"aria-hidden": "true"
|
|
6887
|
+
}),
|
|
6888
|
+
/* @__PURE__ */ jsx("span", {
|
|
6889
|
+
className: "shrink-0 font-medium text-muted",
|
|
6890
|
+
children: connector?.label
|
|
6891
|
+
}),
|
|
6892
|
+
/* @__PURE__ */ jsx("span", {
|
|
6893
|
+
className: "min-w-0 flex-1 truncate text-muted",
|
|
6894
|
+
children: summary
|
|
6895
|
+
}),
|
|
6896
|
+
/* @__PURE__ */ jsx("span", {
|
|
6897
|
+
className: "shrink-0 text-muted",
|
|
6898
|
+
children: copy.statusSuperseded
|
|
6899
|
+
}),
|
|
6900
|
+
confirmationState.supersededBy ? /* @__PURE__ */ jsx("button", {
|
|
6901
|
+
type: "button",
|
|
6902
|
+
className: "shrink-0 underline underline-offset-2 hover:text-foreground",
|
|
6903
|
+
onClick: () => showAction(confirmationState.supersededBy),
|
|
6904
|
+
children: copy.seeNewerVersion
|
|
6905
|
+
}) : null
|
|
6906
|
+
]
|
|
6907
|
+
})
|
|
6908
|
+
});
|
|
6909
|
+
}
|
|
6539
6910
|
return /* @__PURE__ */ jsxs("section", {
|
|
6540
|
-
className: joinClasses("plai-tool-result-personal-connector-card overflow-hidden rounded-lg border border-border bg-surface text-foreground",
|
|
6911
|
+
className: joinClasses("plai-tool-result-personal-connector-card overflow-hidden rounded-lg border border-border bg-surface text-foreground", className),
|
|
6541
6912
|
"data-tool-call-id": part.id,
|
|
6542
6913
|
"data-tool-call-state": part.state,
|
|
6543
6914
|
"data-connector-action": view.kind,
|
|
@@ -6703,6 +7074,7 @@ function ToolResultPendingConfirmationCard({ part, locale, className, toolConfir
|
|
|
6703
7074
|
className: joinClasses("plai-tool-result-pending-confirmation-card overflow-hidden rounded-lg border border-border bg-surface text-foreground", className),
|
|
6704
7075
|
"data-tool-call-id": part.id,
|
|
6705
7076
|
"data-tool-call-state": part.state,
|
|
7077
|
+
"data-confirmation-action": pending.action_id,
|
|
6706
7078
|
children: [
|
|
6707
7079
|
/* @__PURE__ */ jsxs("header", {
|
|
6708
7080
|
className: "flex items-center gap-2 border-b border-border px-3 py-2 text-xs text-secondary",
|
|
@@ -6865,6 +7237,7 @@ function ToolResultWorkflowDispatchCard({ part, className, locale }) {
|
|
|
6865
7237
|
const TOOL_USE_ACTIONS = {
|
|
6866
7238
|
agent_invocation: "agent",
|
|
6867
7239
|
browser: "web",
|
|
7240
|
+
code_execution: "code",
|
|
6868
7241
|
datasource: "datasource",
|
|
6869
7242
|
email_send: "email",
|
|
6870
7243
|
external_datasource: "query",
|
|
@@ -6883,6 +7256,7 @@ const TOOL_USE_ACTIONS = {
|
|
|
6883
7256
|
const TOOL_USE_TRANSLATIONS = {
|
|
6884
7257
|
en: {
|
|
6885
7258
|
agent: "Running agent {{toolName}}",
|
|
7259
|
+
code: "Running code with {{toolName}}",
|
|
6886
7260
|
datasource: "Searching in datasource {{toolName}}",
|
|
6887
7261
|
documents: "Working with documents using {{toolName}}",
|
|
6888
7262
|
email: "Sending email with {{toolName}}",
|
|
@@ -6894,6 +7268,7 @@ const TOOL_USE_TRANSLATIONS = {
|
|
|
6894
7268
|
},
|
|
6895
7269
|
es: {
|
|
6896
7270
|
agent: "Ejecutando el agente {{toolName}}",
|
|
7271
|
+
code: "Ejecutando código con {{toolName}}",
|
|
6897
7272
|
datasource: "Buscando en la fuente de datos {{toolName}}",
|
|
6898
7273
|
documents: "Trabajando con documentos mediante {{toolName}}",
|
|
6899
7274
|
email: "Enviando un correo con {{toolName}}",
|
|
@@ -6905,6 +7280,7 @@ const TOOL_USE_TRANSLATIONS = {
|
|
|
6905
7280
|
},
|
|
6906
7281
|
ca: {
|
|
6907
7282
|
agent: "Executant l’agent {{toolName}}",
|
|
7283
|
+
code: "Executant codi amb {{toolName}}",
|
|
6908
7284
|
datasource: "Cercant a la font de dades {{toolName}}",
|
|
6909
7285
|
documents: "Treballant amb documents mitjançant {{toolName}}",
|
|
6910
7286
|
email: "Enviant un correu amb {{toolName}}",
|
|
@@ -6916,6 +7292,7 @@ const TOOL_USE_TRANSLATIONS = {
|
|
|
6916
7292
|
},
|
|
6917
7293
|
fr: {
|
|
6918
7294
|
agent: "Exécution de l’agent {{toolName}}",
|
|
7295
|
+
code: "Exécution du code avec {{toolName}}",
|
|
6919
7296
|
datasource: "Recherche dans la source de données {{toolName}}",
|
|
6920
7297
|
documents: "Traitement de documents avec {{toolName}}",
|
|
6921
7298
|
email: "Envoi d’un e-mail avec {{toolName}}",
|
|
@@ -6927,6 +7304,7 @@ const TOOL_USE_TRANSLATIONS = {
|
|
|
6927
7304
|
},
|
|
6928
7305
|
it: {
|
|
6929
7306
|
agent: "Esecuzione dell’agente {{toolName}}",
|
|
7307
|
+
code: "Esecuzione del codice con {{toolName}}",
|
|
6930
7308
|
datasource: "Ricerca nella fonte dati {{toolName}}",
|
|
6931
7309
|
documents: "Elaborazione di documenti con {{toolName}}",
|
|
6932
7310
|
email: "Invio di un’email con {{toolName}}",
|
|
@@ -6938,6 +7316,7 @@ const TOOL_USE_TRANSLATIONS = {
|
|
|
6938
7316
|
},
|
|
6939
7317
|
de: {
|
|
6940
7318
|
agent: "Agent {{toolName}} wird ausgeführt",
|
|
7319
|
+
code: "Code wird mit {{toolName}} ausgeführt",
|
|
6941
7320
|
datasource: "Suche in der Datenquelle {{toolName}}",
|
|
6942
7321
|
documents: "Dokumente werden mit {{toolName}} bearbeitet",
|
|
6943
7322
|
email: "E-Mail wird mit {{toolName}} gesendet",
|
|
@@ -6949,6 +7328,7 @@ const TOOL_USE_TRANSLATIONS = {
|
|
|
6949
7328
|
},
|
|
6950
7329
|
da: {
|
|
6951
7330
|
agent: "Kører agenten {{toolName}}",
|
|
7331
|
+
code: "Kører kode med {{toolName}}",
|
|
6952
7332
|
datasource: "Søger i datakilden {{toolName}}",
|
|
6953
7333
|
documents: "Arbejder med dokumenter via {{toolName}}",
|
|
6954
7334
|
email: "Sender e-mail med {{toolName}}",
|
|
@@ -6960,6 +7340,7 @@ const TOOL_USE_TRANSLATIONS = {
|
|
|
6960
7340
|
},
|
|
6961
7341
|
sv: {
|
|
6962
7342
|
agent: "Kör agenten {{toolName}}",
|
|
7343
|
+
code: "Kör kod med {{toolName}}",
|
|
6963
7344
|
datasource: "Söker i datakällan {{toolName}}",
|
|
6964
7345
|
documents: "Arbetar med dokument via {{toolName}}",
|
|
6965
7346
|
email: "Skickar e-post med {{toolName}}",
|
|
@@ -6971,6 +7352,7 @@ const TOOL_USE_TRANSLATIONS = {
|
|
|
6971
7352
|
},
|
|
6972
7353
|
no: {
|
|
6973
7354
|
agent: "Kjører agenten {{toolName}}",
|
|
7355
|
+
code: "Kjører kode med {{toolName}}",
|
|
6974
7356
|
datasource: "Søker i datakilden {{toolName}}",
|
|
6975
7357
|
documents: "Arbeider med dokumenter via {{toolName}}",
|
|
6976
7358
|
email: "Sender e-post med {{toolName}}",
|
|
@@ -6982,6 +7364,7 @@ const TOOL_USE_TRANSLATIONS = {
|
|
|
6982
7364
|
},
|
|
6983
7365
|
pt: {
|
|
6984
7366
|
agent: "Executando o agente {{toolName}}",
|
|
7367
|
+
code: "Executando código com {{toolName}}",
|
|
6985
7368
|
datasource: "Pesquisando na fonte de dados {{toolName}}",
|
|
6986
7369
|
documents: "Trabalhando com documentos usando {{toolName}}",
|
|
6987
7370
|
email: "Enviando e-mail com {{toolName}}",
|
|
@@ -7061,6 +7444,15 @@ function getDatasourceResourceLinks(part) {
|
|
|
7061
7444
|
const links = part.metadata.resource_links;
|
|
7062
7445
|
return Array.isArray(links) ? links.filter(isResourceLink) : [];
|
|
7063
7446
|
}
|
|
7447
|
+
/**
|
|
7448
|
+
* A held mail or calendar action, whichever tool reported it. The result of
|
|
7449
|
+
* `replace_pending_action` is a `tool_confirmation` result that carries the new version
|
|
7450
|
+
* with the connector's metadata: it must look exactly as preparing it did (the mail or
|
|
7451
|
+
* event card), not like an anonymous tool with its arguments as JSON.
|
|
7452
|
+
*/
|
|
7453
|
+
function isConnectorPending(part) {
|
|
7454
|
+
return part.metadata?.type === "personal_connector" && !!getPendingConfirmation(part);
|
|
7455
|
+
}
|
|
7064
7456
|
function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAgentThread, getResourceDownloadUrl, memoryProposal, toolConfirmation }) {
|
|
7065
7457
|
const copy = getUiCopy(locale);
|
|
7066
7458
|
if (part.toolType === "memory_proposal") {
|
|
@@ -7084,12 +7476,17 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
|
|
|
7084
7476
|
locale,
|
|
7085
7477
|
className
|
|
7086
7478
|
});
|
|
7479
|
+
if (part.state === "error" && part.toolType === "code_execution") return /* @__PURE__ */ jsx(ToolResultCodeExecutionCard, {
|
|
7480
|
+
part,
|
|
7481
|
+
locale,
|
|
7482
|
+
className
|
|
7483
|
+
});
|
|
7087
7484
|
if (part.state === "error") return /* @__PURE__ */ jsx(ToolError, {
|
|
7088
7485
|
part,
|
|
7089
7486
|
locale,
|
|
7090
7487
|
className
|
|
7091
7488
|
});
|
|
7092
|
-
if (part.toolType !== "personal_connector" && getPendingConfirmation(part)) return /* @__PURE__ */ jsx(ToolResultPendingConfirmationCard, {
|
|
7489
|
+
if (part.toolType !== "personal_connector" && !isConnectorPending(part) && getPendingConfirmation(part)) return /* @__PURE__ */ jsx(ToolResultPendingConfirmationCard, {
|
|
7093
7490
|
part,
|
|
7094
7491
|
locale,
|
|
7095
7492
|
className,
|
|
@@ -7114,6 +7511,11 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
|
|
|
7114
7511
|
locale,
|
|
7115
7512
|
className
|
|
7116
7513
|
});
|
|
7514
|
+
if (part.toolType === "code_execution") return /* @__PURE__ */ jsx(ToolResultCodeExecutionCard, {
|
|
7515
|
+
part,
|
|
7516
|
+
locale,
|
|
7517
|
+
className
|
|
7518
|
+
});
|
|
7117
7519
|
if (part.toolType === "external_datasource") return /* @__PURE__ */ jsx(ToolResultExternalDatasourceCard, {
|
|
7118
7520
|
part,
|
|
7119
7521
|
locale,
|
|
@@ -7134,7 +7536,7 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
|
|
|
7134
7536
|
locale,
|
|
7135
7537
|
className
|
|
7136
7538
|
});
|
|
7137
|
-
if (part.toolType === "personal_connector" && hasPersonalConnectorView(part)) return /* @__PURE__ */ jsx(ToolResultPersonalConnectorCard, {
|
|
7539
|
+
if ((part.toolType === "personal_connector" || isConnectorPending(part)) && hasPersonalConnectorView(part)) return /* @__PURE__ */ jsx(ToolResultPersonalConnectorCard, {
|
|
7138
7540
|
part,
|
|
7139
7541
|
locale,
|
|
7140
7542
|
className,
|
|
@@ -8244,9 +8646,9 @@ function getFileKey(url) {
|
|
|
8244
8646
|
}
|
|
8245
8647
|
/**
|
|
8246
8648
|
* Collects the files of the loaded messages, in conversation order: the user's
|
|
8247
|
-
* attachments and the files produced by office_documents
|
|
8248
|
-
* without a URL are skipped; a file seen twice is listed
|
|
8249
|
-
* history omits media file ids, so files are matched by URL.
|
|
8649
|
+
* attachments and the files produced by office_documents and code_execution
|
|
8650
|
+
* tool calls. Files without a URL are skipped; a file seen twice is listed
|
|
8651
|
+
* once. Persisted history omits media file ids, so files are matched by URL.
|
|
8250
8652
|
*/
|
|
8251
8653
|
function getConversationFiles(messages) {
|
|
8252
8654
|
const uploaded = [];
|
|
@@ -8282,7 +8684,7 @@ function getConversationFiles(messages) {
|
|
|
8282
8684
|
extension: getFileExtension(name),
|
|
8283
8685
|
messageId: message.id
|
|
8284
8686
|
});
|
|
8285
|
-
} else if (part.type === "tool-call" && part.toolType === "office_documents") {
|
|
8687
|
+
} else if (part.type === "tool-call" && (part.toolType === "office_documents" || part.toolType === "code_execution")) {
|
|
8286
8688
|
const mediaFiles = part.metadata?.media_files;
|
|
8287
8689
|
if (!Array.isArray(mediaFiles)) continue;
|
|
8288
8690
|
for (const file of mediaFiles) {
|
|
@@ -8407,5 +8809,5 @@ function ConversationFilesSheet({ messages, locale, className, open, onOpenChang
|
|
|
8407
8809
|
}
|
|
8408
8810
|
|
|
8409
8811
|
//#endregion
|
|
8410
|
-
export { AggregatedSourceResults, ArrowUp, AssistantMessage, ChatError, Clipboard, ConversationFilesList, ConversationFilesSheet, DatasourceFolderCard, DatasourceToolResources, DatasourceToolResultCard, Loader, MemoryProposalCard, Message, MessageAvatar, MessageContent, MessageFooter, MessageHeader, MessageParts, MessageRoot, 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, ToolResultPendingConfirmationCard, ToolResultPersonalConnectorCard, ToolResultToolConfirmationCard, ToolResultWebSearchCard, ToolResultWorkflowDispatchCard, ToolUseIndicator, UserMessage, X, dummyTranscribeAudio, getConversationFiles, getLocalizedOpenGraphValue, getResourceDescription, getResourceIcon, getResourceOpenGraphImage, getResourceOpenGraphType, getResourceTitle, getResourceType, getResourceUrl, getToolUseLabel, isAllowedPromptFormFile, partitionPromptFormFiles, useChat, useChatRegistryBusy, useOwnedChatRegistry, useRegistryChat, useSpeechToText, useStreamCoordinator, useToolConfirmationSync, useToolConfirmations };
|
|
8812
|
+
export { AggregatedSourceResults, ArrowUp, AssistantMessage, ChatError, Clipboard, ConversationFilesList, ConversationFilesSheet, DatasourceFolderCard, DatasourceToolResources, DatasourceToolResultCard, Loader, MemoryProposalCard, Message, MessageAvatar, MessageContent, MessageFooter, MessageHeader, MessageParts, MessageRoot, 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, ToolResultCodeExecutionCard, ToolResultExternalDatasourceCard, ToolResultHttpRequestCard, ToolResultMcpCard, ToolResultOfficeDocumentsCard, ToolResultPendingConfirmationCard, ToolResultPersonalConnectorCard, ToolResultToolConfirmationCard, ToolResultWebSearchCard, ToolResultWorkflowDispatchCard, ToolUseIndicator, UserMessage, X, dummyTranscribeAudio, getConversationFiles, getLocalizedOpenGraphValue, getResourceDescription, getResourceIcon, getResourceOpenGraphImage, getResourceOpenGraphType, getResourceTitle, getResourceType, getResourceUrl, getToolUseLabel, isAllowedPromptFormFile, partitionPromptFormFiles, useChat, useChatRegistryBusy, useOwnedChatRegistry, useRegistryChat, useSpeechToText, useStreamCoordinator, useToolConfirmationSync, useToolConfirmations };
|
|
8411
8813
|
//# sourceMappingURL=index.js.map
|