@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/components/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
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";
|
|
1
|
+
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";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { HttpStatusError, ToolDecisionRejectedError, ToolSubmissionConflictError, isHiddenMessage, toolConfirmationAt } from "@plaisolutions/client";
|
|
@@ -245,6 +245,17 @@ const ENGLISH_COPY = {
|
|
|
245
245
|
officeDocuments: "Office documents",
|
|
246
246
|
creatingDocuments: "Creating documents…",
|
|
247
247
|
noFilesGenerated: "No files were generated.",
|
|
248
|
+
codeExecution: "Code execution",
|
|
249
|
+
codeExecutionSteps: "Steps",
|
|
250
|
+
earlierStepNotShown: "earlier step not shown",
|
|
251
|
+
earlierStepsNotShown: "earlier steps not shown",
|
|
252
|
+
partialResultWarning: "The result may be incomplete",
|
|
253
|
+
exitCode: "Exit code",
|
|
254
|
+
partial: "partial",
|
|
255
|
+
stepCommand: "Command",
|
|
256
|
+
stepFileCreate: "File created",
|
|
257
|
+
stepFileEdit: "File edited",
|
|
258
|
+
stepFileView: "File viewed",
|
|
248
259
|
download: "Download",
|
|
249
260
|
downloading: "Downloading…",
|
|
250
261
|
downloadFailed: "Download failed. Try again.",
|
|
@@ -353,6 +364,17 @@ const TRANSLATIONS = {
|
|
|
353
364
|
officeDocuments: "Documents d’Office",
|
|
354
365
|
creatingDocuments: "Creant documents…",
|
|
355
366
|
noFilesGenerated: "No s’han generat fitxers.",
|
|
367
|
+
codeExecution: "Execució de codi",
|
|
368
|
+
codeExecutionSteps: "Passos",
|
|
369
|
+
earlierStepNotShown: "pas anterior no mostrat",
|
|
370
|
+
earlierStepsNotShown: "passos anteriors no mostrats",
|
|
371
|
+
partialResultWarning: "El resultat pot estar incomplet",
|
|
372
|
+
exitCode: "Codi de sortida",
|
|
373
|
+
partial: "parcial",
|
|
374
|
+
stepCommand: "Ordre",
|
|
375
|
+
stepFileCreate: "Fitxer creat",
|
|
376
|
+
stepFileEdit: "Fitxer editat",
|
|
377
|
+
stepFileView: "Fitxer consultat",
|
|
356
378
|
download: "Baixa",
|
|
357
379
|
downloading: "Baixant…",
|
|
358
380
|
downloadFailed: "No s’ha pogut baixar. Torna-ho a provar.",
|
|
@@ -460,6 +482,17 @@ const TRANSLATIONS = {
|
|
|
460
482
|
officeDocuments: "Office-dokumenter",
|
|
461
483
|
creatingDocuments: "Opretter dokumenter…",
|
|
462
484
|
noFilesGenerated: "Ingen filer blev genereret.",
|
|
485
|
+
codeExecution: "Kodeudførelse",
|
|
486
|
+
codeExecutionSteps: "Trin",
|
|
487
|
+
earlierStepNotShown: "tidligere trin vises ikke",
|
|
488
|
+
earlierStepsNotShown: "tidligere trin vises ikke",
|
|
489
|
+
partialResultWarning: "Resultatet kan være ufuldstændigt",
|
|
490
|
+
exitCode: "Afslutningskode",
|
|
491
|
+
partial: "delvis",
|
|
492
|
+
stepCommand: "Kommando",
|
|
493
|
+
stepFileCreate: "Fil oprettet",
|
|
494
|
+
stepFileEdit: "Fil redigeret",
|
|
495
|
+
stepFileView: "Fil vist",
|
|
463
496
|
download: "Download",
|
|
464
497
|
downloading: "Downloader…",
|
|
465
498
|
downloadFailed: "Download mislykkedes. Prøv igen.",
|
|
@@ -567,6 +600,17 @@ const TRANSLATIONS = {
|
|
|
567
600
|
officeDocuments: "Office-Dokumente",
|
|
568
601
|
creatingDocuments: "Dokumente werden erstellt…",
|
|
569
602
|
noFilesGenerated: "Es wurden keine Dateien erstellt.",
|
|
603
|
+
codeExecution: "Codeausführung",
|
|
604
|
+
codeExecutionSteps: "Schritte",
|
|
605
|
+
earlierStepNotShown: "früherer Schritt nicht angezeigt",
|
|
606
|
+
earlierStepsNotShown: "frühere Schritte nicht angezeigt",
|
|
607
|
+
partialResultWarning: "Das Ergebnis ist möglicherweise unvollständig",
|
|
608
|
+
exitCode: "Exit-Code",
|
|
609
|
+
partial: "teilweise",
|
|
610
|
+
stepCommand: "Befehl",
|
|
611
|
+
stepFileCreate: "Datei erstellt",
|
|
612
|
+
stepFileEdit: "Datei bearbeitet",
|
|
613
|
+
stepFileView: "Datei angezeigt",
|
|
570
614
|
download: "Herunterladen",
|
|
571
615
|
downloading: "Wird heruntergeladen…",
|
|
572
616
|
downloadFailed: "Download fehlgeschlagen. Bitte erneut versuchen.",
|
|
@@ -675,6 +719,17 @@ const TRANSLATIONS = {
|
|
|
675
719
|
officeDocuments: "Documentos de Office",
|
|
676
720
|
creatingDocuments: "Creando documentos…",
|
|
677
721
|
noFilesGenerated: "No se generaron archivos.",
|
|
722
|
+
codeExecution: "Ejecución de código",
|
|
723
|
+
codeExecutionSteps: "Pasos",
|
|
724
|
+
earlierStepNotShown: "paso anterior no mostrado",
|
|
725
|
+
earlierStepsNotShown: "pasos anteriores no mostrados",
|
|
726
|
+
partialResultWarning: "El resultado puede estar incompleto",
|
|
727
|
+
exitCode: "Código de salida",
|
|
728
|
+
partial: "parcial",
|
|
729
|
+
stepCommand: "Comando",
|
|
730
|
+
stepFileCreate: "Archivo creado",
|
|
731
|
+
stepFileEdit: "Archivo editado",
|
|
732
|
+
stepFileView: "Archivo consultado",
|
|
678
733
|
download: "Descargar",
|
|
679
734
|
downloading: "Descargando…",
|
|
680
735
|
downloadFailed: "No se pudo descargar. Inténtalo de nuevo.",
|
|
@@ -782,6 +837,17 @@ const TRANSLATIONS = {
|
|
|
782
837
|
officeDocuments: "Documents Office",
|
|
783
838
|
creatingDocuments: "Création des documents…",
|
|
784
839
|
noFilesGenerated: "Aucun fichier n’a été généré.",
|
|
840
|
+
codeExecution: "Exécution de code",
|
|
841
|
+
codeExecutionSteps: "Étapes",
|
|
842
|
+
earlierStepNotShown: "étape précédente non affichée",
|
|
843
|
+
earlierStepsNotShown: "étapes précédentes non affichées",
|
|
844
|
+
partialResultWarning: "Le résultat peut être incomplet",
|
|
845
|
+
exitCode: "Code de sortie",
|
|
846
|
+
partial: "partiel",
|
|
847
|
+
stepCommand: "Commande",
|
|
848
|
+
stepFileCreate: "Fichier créé",
|
|
849
|
+
stepFileEdit: "Fichier modifié",
|
|
850
|
+
stepFileView: "Fichier consulté",
|
|
785
851
|
download: "Télécharger",
|
|
786
852
|
downloading: "Téléchargement…",
|
|
787
853
|
downloadFailed: "Échec du téléchargement. Réessayez.",
|
|
@@ -889,6 +955,17 @@ const TRANSLATIONS = {
|
|
|
889
955
|
officeDocuments: "Documenti Office",
|
|
890
956
|
creatingDocuments: "Creazione dei documenti…",
|
|
891
957
|
noFilesGenerated: "Nessun file generato.",
|
|
958
|
+
codeExecution: "Esecuzione del codice",
|
|
959
|
+
codeExecutionSteps: "Passaggi",
|
|
960
|
+
earlierStepNotShown: "passaggio precedente non mostrato",
|
|
961
|
+
earlierStepsNotShown: "passaggi precedenti non mostrati",
|
|
962
|
+
partialResultWarning: "Il risultato potrebbe essere incompleto",
|
|
963
|
+
exitCode: "Codice di uscita",
|
|
964
|
+
partial: "parziale",
|
|
965
|
+
stepCommand: "Comando",
|
|
966
|
+
stepFileCreate: "File creato",
|
|
967
|
+
stepFileEdit: "File modificato",
|
|
968
|
+
stepFileView: "File visualizzato",
|
|
892
969
|
download: "Scarica",
|
|
893
970
|
downloading: "Download in corso…",
|
|
894
971
|
downloadFailed: "Download non riuscito. Riprova.",
|
|
@@ -996,6 +1073,17 @@ const TRANSLATIONS = {
|
|
|
996
1073
|
officeDocuments: "Office-dokumenter",
|
|
997
1074
|
creatingDocuments: "Oppretter dokumenter…",
|
|
998
1075
|
noFilesGenerated: "Ingen filer ble generert.",
|
|
1076
|
+
codeExecution: "Kodekjøring",
|
|
1077
|
+
codeExecutionSteps: "Trinn",
|
|
1078
|
+
earlierStepNotShown: "tidligere trinn vises ikke",
|
|
1079
|
+
earlierStepsNotShown: "tidligere trinn vises ikke",
|
|
1080
|
+
partialResultWarning: "Resultatet kan være ufullstendig",
|
|
1081
|
+
exitCode: "Avslutningskode",
|
|
1082
|
+
partial: "delvis",
|
|
1083
|
+
stepCommand: "Kommando",
|
|
1084
|
+
stepFileCreate: "Fil opprettet",
|
|
1085
|
+
stepFileEdit: "Fil redigert",
|
|
1086
|
+
stepFileView: "Fil vist",
|
|
999
1087
|
download: "Last ned",
|
|
1000
1088
|
downloading: "Laster ned…",
|
|
1001
1089
|
downloadFailed: "Nedlastingen mislyktes. Prøv igjen.",
|
|
@@ -1103,6 +1191,17 @@ const TRANSLATIONS = {
|
|
|
1103
1191
|
officeDocuments: "Documentos do Office",
|
|
1104
1192
|
creatingDocuments: "A criar documentos…",
|
|
1105
1193
|
noFilesGenerated: "Não foram gerados ficheiros.",
|
|
1194
|
+
codeExecution: "Execução de código",
|
|
1195
|
+
codeExecutionSteps: "Passos",
|
|
1196
|
+
earlierStepNotShown: "passo anterior não apresentado",
|
|
1197
|
+
earlierStepsNotShown: "passos anteriores não apresentados",
|
|
1198
|
+
partialResultWarning: "O resultado pode estar incompleto",
|
|
1199
|
+
exitCode: "Código de saída",
|
|
1200
|
+
partial: "parcial",
|
|
1201
|
+
stepCommand: "Comando",
|
|
1202
|
+
stepFileCreate: "Ficheiro criado",
|
|
1203
|
+
stepFileEdit: "Ficheiro editado",
|
|
1204
|
+
stepFileView: "Ficheiro consultado",
|
|
1106
1205
|
download: "Transferir",
|
|
1107
1206
|
downloading: "A transferir…",
|
|
1108
1207
|
downloadFailed: "Não foi possível transferir. Tente novamente.",
|
|
@@ -1210,6 +1309,17 @@ const TRANSLATIONS = {
|
|
|
1210
1309
|
officeDocuments: "Office-dokument",
|
|
1211
1310
|
creatingDocuments: "Skapar dokument…",
|
|
1212
1311
|
noFilesGenerated: "Inga filer genererades.",
|
|
1312
|
+
codeExecution: "Kodkörning",
|
|
1313
|
+
codeExecutionSteps: "Steg",
|
|
1314
|
+
earlierStepNotShown: "tidigare steg visas inte",
|
|
1315
|
+
earlierStepsNotShown: "tidigare steg visas inte",
|
|
1316
|
+
partialResultWarning: "Resultatet kan vara ofullständigt",
|
|
1317
|
+
exitCode: "Slutkod",
|
|
1318
|
+
partial: "delvis",
|
|
1319
|
+
stepCommand: "Kommando",
|
|
1320
|
+
stepFileCreate: "Fil skapad",
|
|
1321
|
+
stepFileEdit: "Fil redigerad",
|
|
1322
|
+
stepFileView: "Fil visad",
|
|
1213
1323
|
download: "Ladda ned",
|
|
1214
1324
|
downloading: "Laddar ned…",
|
|
1215
1325
|
downloadFailed: "Nedladdningen misslyckades. Försök igen.",
|
|
@@ -3264,6 +3374,322 @@ function ToolResultBrowserCard({ part, className, locale }) {
|
|
|
3264
3374
|
});
|
|
3265
3375
|
}
|
|
3266
3376
|
|
|
3377
|
+
//#endregion
|
|
3378
|
+
//#region src/components/internal/download-file.ts
|
|
3379
|
+
/**
|
|
3380
|
+
* Single entry point for downloading a chat file.
|
|
3381
|
+
*
|
|
3382
|
+
* Fetches the bytes and saves them under the file name, so the browser neither
|
|
3383
|
+
* navigates nor opens a tab. That read needs the file host to allow this origin
|
|
3384
|
+
* (CORS); when it does not, the URL opens in a new tab instead. An HTTP error
|
|
3385
|
+
* (expired, deleted or private object) rejects so the caller can say so.
|
|
3386
|
+
*/
|
|
3387
|
+
async function downloadFile(file) {
|
|
3388
|
+
let response;
|
|
3389
|
+
try {
|
|
3390
|
+
response = await fetch(file.url, { credentials: "omit" });
|
|
3391
|
+
} catch {
|
|
3392
|
+
openInNewTab(file.url);
|
|
3393
|
+
return;
|
|
3394
|
+
}
|
|
3395
|
+
if (!response.ok) throw new Error(`Download failed with status ${response.status}`);
|
|
3396
|
+
saveBlob(await response.blob(), file.name || getFilenameFromUrl(file.url) || "download");
|
|
3397
|
+
}
|
|
3398
|
+
function saveBlob(blob, fileName) {
|
|
3399
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
3400
|
+
const anchor = document.createElement("a");
|
|
3401
|
+
anchor.href = objectUrl;
|
|
3402
|
+
anchor.download = fileName;
|
|
3403
|
+
anchor.rel = "noopener";
|
|
3404
|
+
anchor.style.display = "none";
|
|
3405
|
+
document.body.appendChild(anchor);
|
|
3406
|
+
anchor.click();
|
|
3407
|
+
anchor.remove();
|
|
3408
|
+
window.setTimeout(() => URL.revokeObjectURL(objectUrl), 1e3);
|
|
3409
|
+
}
|
|
3410
|
+
function openInNewTab(url) {
|
|
3411
|
+
window.open(url, "_blank", "noopener,noreferrer");
|
|
3412
|
+
}
|
|
3413
|
+
|
|
3414
|
+
//#endregion
|
|
3415
|
+
//#region src/components/internal/file-download-button.tsx
|
|
3416
|
+
function FileDownloadButton({ file, label, copy, className }) {
|
|
3417
|
+
const [state, setState] = useState("idle");
|
|
3418
|
+
const isDownloading = state === "downloading";
|
|
3419
|
+
const handleClick = async (event) => {
|
|
3420
|
+
event.stopPropagation();
|
|
3421
|
+
if (isDownloading) return;
|
|
3422
|
+
setState("downloading");
|
|
3423
|
+
try {
|
|
3424
|
+
await downloadFile(file);
|
|
3425
|
+
setState("idle");
|
|
3426
|
+
} catch {
|
|
3427
|
+
setState("error");
|
|
3428
|
+
}
|
|
3429
|
+
};
|
|
3430
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
3431
|
+
className: "ml-auto flex shrink-0 items-center gap-2",
|
|
3432
|
+
children: [state === "error" ? /* @__PURE__ */ jsx("span", {
|
|
3433
|
+
role: "alert",
|
|
3434
|
+
className: "text-xs text-danger",
|
|
3435
|
+
children: copy.downloadFailed
|
|
3436
|
+
}) : null, /* @__PURE__ */ jsx("button", {
|
|
3437
|
+
type: "button",
|
|
3438
|
+
onClick: handleClick,
|
|
3439
|
+
disabled: isDownloading,
|
|
3440
|
+
"aria-label": `${isDownloading ? copy.downloading : copy.download}: ${label}`,
|
|
3441
|
+
title: isDownloading ? copy.downloading : copy.download,
|
|
3442
|
+
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),
|
|
3443
|
+
children: isDownloading ? /* @__PURE__ */ jsx(LoaderCircle, {
|
|
3444
|
+
className: "h-4 w-4 animate-spin",
|
|
3445
|
+
"aria-hidden": "true"
|
|
3446
|
+
}) : /* @__PURE__ */ jsx(Download, {
|
|
3447
|
+
className: "h-4 w-4",
|
|
3448
|
+
"aria-hidden": "true"
|
|
3449
|
+
})
|
|
3450
|
+
})]
|
|
3451
|
+
});
|
|
3452
|
+
}
|
|
3453
|
+
|
|
3454
|
+
//#endregion
|
|
3455
|
+
//#region src/components/internal/generated-files.tsx
|
|
3456
|
+
/** Keeps the entries of `metadata.media_files` that look like a media file. */
|
|
3457
|
+
function getGeneratedFiles(files) {
|
|
3458
|
+
return Array.isArray(files) ? files.filter((file) => Boolean(file) && typeof file === "object" && typeof file.id === "string") : [];
|
|
3459
|
+
}
|
|
3460
|
+
function getGeneratedFileExtension(file) {
|
|
3461
|
+
return getFileExtension(file.name ?? file.pathname, file.content_type);
|
|
3462
|
+
}
|
|
3463
|
+
function getGeneratedFileLabel(file) {
|
|
3464
|
+
return file.name ?? file.pathname ?? file.id;
|
|
3465
|
+
}
|
|
3466
|
+
/** A generated file with its extension and a download button, for a sheet. */
|
|
3467
|
+
function GeneratedFileRow({ file, copy }) {
|
|
3468
|
+
const extension = getGeneratedFileExtension(file);
|
|
3469
|
+
const label = getGeneratedFileLabel(file);
|
|
3470
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3471
|
+
className: "flex items-center gap-3 rounded-lg border border-border bg-surface p-3",
|
|
3472
|
+
children: [
|
|
3473
|
+
/* @__PURE__ */ jsx(File, {
|
|
3474
|
+
className: joinClasses("h-8 w-8 shrink-0", getFileIconClass(extension)),
|
|
3475
|
+
"aria-hidden": "true"
|
|
3476
|
+
}),
|
|
3477
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3478
|
+
className: "min-w-0",
|
|
3479
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
3480
|
+
className: "truncate text-sm font-medium",
|
|
3481
|
+
children: label
|
|
3482
|
+
}), extension ? /* @__PURE__ */ jsx("p", {
|
|
3483
|
+
className: "text-[11px] uppercase text-muted",
|
|
3484
|
+
children: extension
|
|
3485
|
+
}) : null]
|
|
3486
|
+
}),
|
|
3487
|
+
file.url ? /* @__PURE__ */ jsx(FileDownloadButton, {
|
|
3488
|
+
file: {
|
|
3489
|
+
url: file.url,
|
|
3490
|
+
name: file.name
|
|
3491
|
+
},
|
|
3492
|
+
label,
|
|
3493
|
+
copy
|
|
3494
|
+
}) : null
|
|
3495
|
+
]
|
|
3496
|
+
});
|
|
3497
|
+
}
|
|
3498
|
+
|
|
3499
|
+
//#endregion
|
|
3500
|
+
//#region src/components/tool-result-code-execution-card.tsx
|
|
3501
|
+
const STEP_ICONS = {
|
|
3502
|
+
command: Terminal,
|
|
3503
|
+
file_create: FilePlus2,
|
|
3504
|
+
file_edit: FilePen,
|
|
3505
|
+
file_view: Eye
|
|
3506
|
+
};
|
|
3507
|
+
const STEP_LABELS = {
|
|
3508
|
+
command: "stepCommand",
|
|
3509
|
+
file_create: "stepFileCreate",
|
|
3510
|
+
file_edit: "stepFileEdit",
|
|
3511
|
+
file_view: "stepFileView"
|
|
3512
|
+
};
|
|
3513
|
+
function isStepKind(value) {
|
|
3514
|
+
return typeof value === "string" && value in STEP_ICONS;
|
|
3515
|
+
}
|
|
3516
|
+
function getSteps(part) {
|
|
3517
|
+
const steps = part.metadata?.steps;
|
|
3518
|
+
if (!Array.isArray(steps)) return [];
|
|
3519
|
+
return steps.flatMap((step) => {
|
|
3520
|
+
if (!step || typeof step !== "object" || !isStepKind(step.kind)) return [];
|
|
3521
|
+
return [{
|
|
3522
|
+
kind: step.kind,
|
|
3523
|
+
input: typeof step.input === "string" ? step.input : "",
|
|
3524
|
+
output: typeof step.output === "string" ? step.output : "",
|
|
3525
|
+
exit_code: typeof step.exit_code === "number" ? step.exit_code : null
|
|
3526
|
+
}];
|
|
3527
|
+
});
|
|
3528
|
+
}
|
|
3529
|
+
function getStatus(part) {
|
|
3530
|
+
if (part.state === "error") return "error";
|
|
3531
|
+
const status = part.metadata?.status;
|
|
3532
|
+
return status === "partial" || status === "error" ? status : "success";
|
|
3533
|
+
}
|
|
3534
|
+
function getErrorMessage(part) {
|
|
3535
|
+
const message = part.metadata?.error_details?.error_message;
|
|
3536
|
+
if (typeof message === "string" && message.trim()) return message;
|
|
3537
|
+
return formatToolErrorDetails(part.errorDetails);
|
|
3538
|
+
}
|
|
3539
|
+
function ToolResultCodeExecutionCard({ part, className, locale }) {
|
|
3540
|
+
const copy = getUiCopy(locale);
|
|
3541
|
+
const files = getGeneratedFiles(part.metadata?.media_files);
|
|
3542
|
+
const steps = getSteps(part);
|
|
3543
|
+
const stepsOmitted = part.metadata?.steps_omitted;
|
|
3544
|
+
const omitted = typeof stepsOmitted === "number" && stepsOmitted > 0 ? stepsOmitted : 0;
|
|
3545
|
+
const pending = part.state === "pending";
|
|
3546
|
+
const status = pending ? null : getStatus(part);
|
|
3547
|
+
const errorMessage = status === "error" ? getErrorMessage(part) : null;
|
|
3548
|
+
const fileLabel = files.length === 1 ? copy.file : copy.files;
|
|
3549
|
+
const summary = pending ? copy.pending : status === "error" ? copy.error : status === "partial" ? copy.partial : files.length > 0 ? `${files.length} ${fileLabel}` : copy.completed;
|
|
3550
|
+
return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsx(SheetTrigger, {
|
|
3551
|
+
"aria-label": `${copy.codeExecution}: ${summary}`,
|
|
3552
|
+
"data-status": status ?? "pending",
|
|
3553
|
+
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),
|
|
3554
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
3555
|
+
className: "flex items-center gap-2 px-3 py-2 text-sm",
|
|
3556
|
+
children: [
|
|
3557
|
+
/* @__PURE__ */ jsx(Terminal, {
|
|
3558
|
+
className: "h-4 w-4 shrink-0 text-muted",
|
|
3559
|
+
"aria-hidden": "true"
|
|
3560
|
+
}),
|
|
3561
|
+
/* @__PURE__ */ jsx("span", {
|
|
3562
|
+
className: "truncate font-medium",
|
|
3563
|
+
children: copy.codeExecution
|
|
3564
|
+
}),
|
|
3565
|
+
/* @__PURE__ */ jsx("span", {
|
|
3566
|
+
className: "min-w-0 truncate border-border-strong border px-2 py-0.5 rounded-md text-xs text-muted",
|
|
3567
|
+
children: summary
|
|
3568
|
+
}),
|
|
3569
|
+
/* @__PURE__ */ jsx("span", {
|
|
3570
|
+
className: joinClasses("ml-auto shrink-0", status === "error" ? "text-danger" : status === "partial" ? "text-warning" : "text-success"),
|
|
3571
|
+
children: status === "error" ? /* @__PURE__ */ jsx(XCircle, {
|
|
3572
|
+
className: "h-4 w-4",
|
|
3573
|
+
"aria-hidden": "true"
|
|
3574
|
+
}) : status === "partial" ? /* @__PURE__ */ jsx(TriangleAlert, {
|
|
3575
|
+
className: "h-4 w-4",
|
|
3576
|
+
"aria-hidden": "true"
|
|
3577
|
+
}) : status === "success" ? /* @__PURE__ */ jsx(CheckCircle2, {
|
|
3578
|
+
className: "h-4 w-4",
|
|
3579
|
+
"aria-hidden": "true"
|
|
3580
|
+
}) : null
|
|
3581
|
+
})
|
|
3582
|
+
]
|
|
3583
|
+
})
|
|
3584
|
+
}), /* @__PURE__ */ jsxs(SheetContent, {
|
|
3585
|
+
locale,
|
|
3586
|
+
children: [/* @__PURE__ */ jsx(SheetHeader, {
|
|
3587
|
+
className: "pr-10",
|
|
3588
|
+
children: /* @__PURE__ */ jsx(SheetTitle, { children: copy.codeExecution })
|
|
3589
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
3590
|
+
className: "mt-6 space-y-6",
|
|
3591
|
+
children: [
|
|
3592
|
+
status === "partial" ? /* @__PURE__ */ jsxs("output", {
|
|
3593
|
+
className: "flex items-center gap-2 rounded border border-warning-border bg-warning-subtle px-3 py-2 text-xs text-warning-strong",
|
|
3594
|
+
children: [/* @__PURE__ */ jsx(TriangleAlert, {
|
|
3595
|
+
className: "h-4 w-4 shrink-0",
|
|
3596
|
+
"aria-hidden": "true"
|
|
3597
|
+
}), copy.partialResultWarning]
|
|
3598
|
+
}) : null,
|
|
3599
|
+
errorMessage ? /* @__PURE__ */ jsxs("p", {
|
|
3600
|
+
role: "alert",
|
|
3601
|
+
className: "rounded border border-danger-border bg-danger-subtle px-3 py-2 text-xs text-danger-strong",
|
|
3602
|
+
children: [
|
|
3603
|
+
/* @__PURE__ */ jsxs("span", {
|
|
3604
|
+
className: "font-semibold",
|
|
3605
|
+
children: [copy.errorDetails, ":"]
|
|
3606
|
+
}),
|
|
3607
|
+
" ",
|
|
3608
|
+
errorMessage
|
|
3609
|
+
]
|
|
3610
|
+
}) : null,
|
|
3611
|
+
files.length > 0 || status === "success" ? /* @__PURE__ */ jsxs("section", {
|
|
3612
|
+
className: "space-y-3",
|
|
3613
|
+
"aria-label": copy.generatedFiles,
|
|
3614
|
+
children: [files.map((file) => /* @__PURE__ */ jsx(GeneratedFileRow, {
|
|
3615
|
+
file,
|
|
3616
|
+
copy
|
|
3617
|
+
}, file.id)), files.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
3618
|
+
className: "text-sm text-secondary",
|
|
3619
|
+
children: copy.noFilesGenerated
|
|
3620
|
+
}) : null]
|
|
3621
|
+
}) : null,
|
|
3622
|
+
steps.length > 0 ? /* @__PURE__ */ jsxs("section", {
|
|
3623
|
+
className: "space-y-3",
|
|
3624
|
+
"aria-label": copy.codeExecutionSteps,
|
|
3625
|
+
children: [
|
|
3626
|
+
/* @__PURE__ */ jsx("h3", {
|
|
3627
|
+
className: "text-xs font-semibold uppercase tracking-wide text-muted",
|
|
3628
|
+
children: copy.codeExecutionSteps
|
|
3629
|
+
}),
|
|
3630
|
+
omitted > 0 ? /* @__PURE__ */ jsxs("p", {
|
|
3631
|
+
className: "text-xs text-muted",
|
|
3632
|
+
children: [
|
|
3633
|
+
omitted,
|
|
3634
|
+
" ",
|
|
3635
|
+
omitted === 1 ? copy.earlierStepNotShown : copy.earlierStepsNotShown
|
|
3636
|
+
]
|
|
3637
|
+
}) : null,
|
|
3638
|
+
/* @__PURE__ */ jsx("ol", {
|
|
3639
|
+
className: "space-y-2",
|
|
3640
|
+
children: steps.map((step, index) => /* @__PURE__ */ jsx(CodeExecutionStepItem, {
|
|
3641
|
+
step,
|
|
3642
|
+
copy
|
|
3643
|
+
}, index))
|
|
3644
|
+
})
|
|
3645
|
+
]
|
|
3646
|
+
}) : null
|
|
3647
|
+
]
|
|
3648
|
+
})]
|
|
3649
|
+
})] });
|
|
3650
|
+
}
|
|
3651
|
+
function CodeExecutionStepItem({ step, copy }) {
|
|
3652
|
+
const Icon = STEP_ICONS[step.kind];
|
|
3653
|
+
const label = copy[STEP_LABELS[step.kind]];
|
|
3654
|
+
const failed = step.exit_code !== null && step.exit_code !== 0;
|
|
3655
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
3656
|
+
"data-step-kind": step.kind,
|
|
3657
|
+
"data-step-failed": failed ? "true" : void 0,
|
|
3658
|
+
className: joinClasses("space-y-2 rounded-lg border bg-surface p-3", failed ? "border-danger-border" : "border-border"),
|
|
3659
|
+
children: [
|
|
3660
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3661
|
+
className: "flex items-center gap-2 text-xs text-muted",
|
|
3662
|
+
children: [
|
|
3663
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
3664
|
+
className: "h-4 w-4 shrink-0",
|
|
3665
|
+
"aria-hidden": "true"
|
|
3666
|
+
}),
|
|
3667
|
+
/* @__PURE__ */ jsx("span", {
|
|
3668
|
+
className: "font-medium",
|
|
3669
|
+
children: label
|
|
3670
|
+
}),
|
|
3671
|
+
failed ? /* @__PURE__ */ jsxs("span", {
|
|
3672
|
+
className: "ml-auto rounded border border-danger-border bg-danger-subtle px-2 py-0.5 text-danger-strong",
|
|
3673
|
+
children: [
|
|
3674
|
+
copy.exitCode,
|
|
3675
|
+
" ",
|
|
3676
|
+
step.exit_code
|
|
3677
|
+
]
|
|
3678
|
+
}) : null
|
|
3679
|
+
]
|
|
3680
|
+
}),
|
|
3681
|
+
step.input ? /* @__PURE__ */ jsx("pre", {
|
|
3682
|
+
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",
|
|
3683
|
+
children: step.input
|
|
3684
|
+
}) : null,
|
|
3685
|
+
step.output ? /* @__PURE__ */ jsx("pre", {
|
|
3686
|
+
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"),
|
|
3687
|
+
children: step.output
|
|
3688
|
+
}) : null
|
|
3689
|
+
]
|
|
3690
|
+
});
|
|
3691
|
+
}
|
|
3692
|
+
|
|
3267
3693
|
//#endregion
|
|
3268
3694
|
//#region src/components/tool-result-email-send-card.tsx
|
|
3269
3695
|
function asObject(value) {
|
|
@@ -3870,94 +4296,16 @@ function ToolResultMcpCard({ part, className, locale }) {
|
|
|
3870
4296
|
})] });
|
|
3871
4297
|
}
|
|
3872
4298
|
|
|
3873
|
-
//#endregion
|
|
3874
|
-
//#region src/components/internal/download-file.ts
|
|
3875
|
-
/**
|
|
3876
|
-
* Single entry point for downloading a chat file.
|
|
3877
|
-
*
|
|
3878
|
-
* Fetches the bytes and saves them under the file name, so the browser neither
|
|
3879
|
-
* navigates nor opens a tab. That read needs the file host to allow this origin
|
|
3880
|
-
* (CORS); when it does not, the URL opens in a new tab instead. An HTTP error
|
|
3881
|
-
* (expired, deleted or private object) rejects so the caller can say so.
|
|
3882
|
-
*/
|
|
3883
|
-
async function downloadFile(file) {
|
|
3884
|
-
let response;
|
|
3885
|
-
try {
|
|
3886
|
-
response = await fetch(file.url, { credentials: "omit" });
|
|
3887
|
-
} catch {
|
|
3888
|
-
openInNewTab(file.url);
|
|
3889
|
-
return;
|
|
3890
|
-
}
|
|
3891
|
-
if (!response.ok) throw new Error(`Download failed with status ${response.status}`);
|
|
3892
|
-
saveBlob(await response.blob(), file.name || getFilenameFromUrl(file.url) || "download");
|
|
3893
|
-
}
|
|
3894
|
-
function saveBlob(blob, fileName) {
|
|
3895
|
-
const objectUrl = URL.createObjectURL(blob);
|
|
3896
|
-
const anchor = document.createElement("a");
|
|
3897
|
-
anchor.href = objectUrl;
|
|
3898
|
-
anchor.download = fileName;
|
|
3899
|
-
anchor.rel = "noopener";
|
|
3900
|
-
anchor.style.display = "none";
|
|
3901
|
-
document.body.appendChild(anchor);
|
|
3902
|
-
anchor.click();
|
|
3903
|
-
anchor.remove();
|
|
3904
|
-
window.setTimeout(() => URL.revokeObjectURL(objectUrl), 1e3);
|
|
3905
|
-
}
|
|
3906
|
-
function openInNewTab(url) {
|
|
3907
|
-
window.open(url, "_blank", "noopener,noreferrer");
|
|
3908
|
-
}
|
|
3909
|
-
|
|
3910
|
-
//#endregion
|
|
3911
|
-
//#region src/components/internal/file-download-button.tsx
|
|
3912
|
-
function FileDownloadButton({ file, label, copy, className }) {
|
|
3913
|
-
const [state, setState] = useState("idle");
|
|
3914
|
-
const isDownloading = state === "downloading";
|
|
3915
|
-
const handleClick = async (event) => {
|
|
3916
|
-
event.stopPropagation();
|
|
3917
|
-
if (isDownloading) return;
|
|
3918
|
-
setState("downloading");
|
|
3919
|
-
try {
|
|
3920
|
-
await downloadFile(file);
|
|
3921
|
-
setState("idle");
|
|
3922
|
-
} catch {
|
|
3923
|
-
setState("error");
|
|
3924
|
-
}
|
|
3925
|
-
};
|
|
3926
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
3927
|
-
className: "ml-auto flex shrink-0 items-center gap-2",
|
|
3928
|
-
children: [state === "error" ? /* @__PURE__ */ jsx("span", {
|
|
3929
|
-
role: "alert",
|
|
3930
|
-
className: "text-xs text-danger",
|
|
3931
|
-
children: copy.downloadFailed
|
|
3932
|
-
}) : null, /* @__PURE__ */ jsx("button", {
|
|
3933
|
-
type: "button",
|
|
3934
|
-
onClick: handleClick,
|
|
3935
|
-
disabled: isDownloading,
|
|
3936
|
-
"aria-label": `${isDownloading ? copy.downloading : copy.download}: ${label}`,
|
|
3937
|
-
title: isDownloading ? copy.downloading : copy.download,
|
|
3938
|
-
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),
|
|
3939
|
-
children: isDownloading ? /* @__PURE__ */ jsx(LoaderCircle, {
|
|
3940
|
-
className: "h-4 w-4 animate-spin",
|
|
3941
|
-
"aria-hidden": "true"
|
|
3942
|
-
}) : /* @__PURE__ */ jsx(Download, {
|
|
3943
|
-
className: "h-4 w-4",
|
|
3944
|
-
"aria-hidden": "true"
|
|
3945
|
-
})
|
|
3946
|
-
})]
|
|
3947
|
-
});
|
|
3948
|
-
}
|
|
3949
|
-
|
|
3950
4299
|
//#endregion
|
|
3951
4300
|
//#region src/components/tool-result-office-documents-card.tsx
|
|
3952
4301
|
function getFiles(part) {
|
|
3953
|
-
|
|
3954
|
-
return Array.isArray(files) ? files.filter((file) => Boolean(file) && typeof file === "object" && typeof file.id === "string") : [];
|
|
4302
|
+
return getGeneratedFiles(part.metadata?.media_files);
|
|
3955
4303
|
}
|
|
3956
4304
|
function getExtension(file) {
|
|
3957
|
-
return
|
|
4305
|
+
return getGeneratedFileExtension(file);
|
|
3958
4306
|
}
|
|
3959
4307
|
function getLabel(file) {
|
|
3960
|
-
return file
|
|
4308
|
+
return getGeneratedFileLabel(file);
|
|
3961
4309
|
}
|
|
3962
4310
|
function ToolResultOfficeDocumentsCard({ part, className, locale }) {
|
|
3963
4311
|
const copy = getUiCopy(locale);
|
|
@@ -4040,37 +4388,10 @@ function ToolResultOfficeDocumentsCard({ part, className, locale }) {
|
|
|
4040
4388
|
className: "mt-6 space-y-3",
|
|
4041
4389
|
"aria-label": copy.generatedFiles,
|
|
4042
4390
|
children: [
|
|
4043
|
-
files.map((file) => {
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
className: "flex items-center gap-3 rounded-lg border border-border bg-surface p-3",
|
|
4048
|
-
children: [
|
|
4049
|
-
/* @__PURE__ */ jsx(File, {
|
|
4050
|
-
className: joinClasses("h-8 w-8 shrink-0", getFileIconClass(extension)),
|
|
4051
|
-
"aria-hidden": "true"
|
|
4052
|
-
}),
|
|
4053
|
-
/* @__PURE__ */ jsxs("div", {
|
|
4054
|
-
className: "min-w-0",
|
|
4055
|
-
children: [/* @__PURE__ */ jsx("p", {
|
|
4056
|
-
className: "truncate text-sm font-medium",
|
|
4057
|
-
children: label
|
|
4058
|
-
}), extension ? /* @__PURE__ */ jsx("p", {
|
|
4059
|
-
className: "text-[11px] uppercase text-muted",
|
|
4060
|
-
children: extension
|
|
4061
|
-
}) : null]
|
|
4062
|
-
}),
|
|
4063
|
-
file.url ? /* @__PURE__ */ jsx(FileDownloadButton, {
|
|
4064
|
-
file: {
|
|
4065
|
-
url: file.url,
|
|
4066
|
-
name: file.name
|
|
4067
|
-
},
|
|
4068
|
-
label,
|
|
4069
|
-
copy
|
|
4070
|
-
}) : null
|
|
4071
|
-
]
|
|
4072
|
-
}, file.id);
|
|
4073
|
-
}),
|
|
4391
|
+
files.map((file) => /* @__PURE__ */ jsx(GeneratedFileRow, {
|
|
4392
|
+
file,
|
|
4393
|
+
copy
|
|
4394
|
+
}, file.id)),
|
|
4074
4395
|
files.length === 0 && part.state === "pending" ? /* @__PURE__ */ jsx("p", {
|
|
4075
4396
|
className: "text-sm text-secondary",
|
|
4076
4397
|
children: copy.creatingDocuments
|
|
@@ -5547,16 +5868,28 @@ function expiryText(state, serverOffsetMs, now, copy) {
|
|
|
5547
5868
|
function saveLabel(operation, copy) {
|
|
5548
5869
|
return operation === "send" ? copy.saveAndSend : copy.saveAndConfirm;
|
|
5549
5870
|
}
|
|
5550
|
-
|
|
5871
|
+
const HIGHLIGHT = [
|
|
5872
|
+
"ring-2",
|
|
5873
|
+
"ring-border-strong",
|
|
5874
|
+
"transition-shadow"
|
|
5875
|
+
];
|
|
5876
|
+
/**
|
|
5877
|
+
* Scrolls to the card of another version of the same action and flashes it, so the eye finds
|
|
5878
|
+
* it. Returns whether that card is on screen (it may not be, e.g. older history not loaded).
|
|
5879
|
+
*/
|
|
5551
5880
|
function showAction(actionId) {
|
|
5552
|
-
if (typeof document === "undefined") return;
|
|
5553
|
-
for (const element of document.querySelectorAll("[data-confirmation-action]"))
|
|
5881
|
+
if (typeof document === "undefined") return false;
|
|
5882
|
+
for (const element of document.querySelectorAll("[data-confirmation-action]")) {
|
|
5883
|
+
if (element.getAttribute("data-confirmation-action") !== actionId) continue;
|
|
5554
5884
|
element.scrollIntoView?.({
|
|
5555
5885
|
block: "center",
|
|
5556
5886
|
behavior: "smooth"
|
|
5557
5887
|
});
|
|
5558
|
-
|
|
5888
|
+
element.classList.add(...HIGHLIGHT);
|
|
5889
|
+
setTimeout(() => element.classList.remove(...HIGHLIGHT), 1600);
|
|
5890
|
+
return true;
|
|
5559
5891
|
}
|
|
5892
|
+
return false;
|
|
5560
5893
|
}
|
|
5561
5894
|
/**
|
|
5562
5895
|
* Footer of a held action. Without `toolConfirmation` it keeps the text hint
|
|
@@ -6344,8 +6677,46 @@ function ToolResultPersonalConnectorCard({ part, locale, className, toolConfirma
|
|
|
6344
6677
|
const Icon = isCalendar(connector) ? CalendarDays : Mail;
|
|
6345
6678
|
const total = headerCount(view, copy);
|
|
6346
6679
|
const isPending = view.kind === "pending-mail" || view.kind === "pending-event";
|
|
6680
|
+
if (pending && confirmationState?.status === "superseded") {
|
|
6681
|
+
const summary = text(pending.action.subject) ?? text(pending.action.title) ?? copy.noSubject;
|
|
6682
|
+
return /* @__PURE__ */ jsx("section", {
|
|
6683
|
+
className: joinClasses("plai-tool-result-personal-connector-card plai-superseded overflow-hidden rounded-lg border border-border bg-surface text-foreground", className),
|
|
6684
|
+
"data-tool-call-id": part.id,
|
|
6685
|
+
"data-tool-call-state": part.state,
|
|
6686
|
+
"data-connector-action": view.kind,
|
|
6687
|
+
"data-confirmation-action": pending.action_id,
|
|
6688
|
+
"data-confirmation-status": "superseded",
|
|
6689
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
6690
|
+
className: "flex flex-wrap items-center gap-x-2 gap-y-1 px-3 py-2 text-xs text-secondary",
|
|
6691
|
+
children: [
|
|
6692
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
6693
|
+
className: "h-4 w-4 shrink-0 text-muted",
|
|
6694
|
+
"aria-hidden": "true"
|
|
6695
|
+
}),
|
|
6696
|
+
/* @__PURE__ */ jsx("span", {
|
|
6697
|
+
className: "shrink-0 font-medium text-muted",
|
|
6698
|
+
children: connector?.label
|
|
6699
|
+
}),
|
|
6700
|
+
/* @__PURE__ */ jsx("span", {
|
|
6701
|
+
className: "min-w-0 flex-1 truncate text-muted",
|
|
6702
|
+
children: summary
|
|
6703
|
+
}),
|
|
6704
|
+
/* @__PURE__ */ jsx("span", {
|
|
6705
|
+
className: "shrink-0 text-muted",
|
|
6706
|
+
children: copy.statusSuperseded
|
|
6707
|
+
}),
|
|
6708
|
+
confirmationState.supersededBy ? /* @__PURE__ */ jsx("button", {
|
|
6709
|
+
type: "button",
|
|
6710
|
+
className: "shrink-0 underline underline-offset-2 hover:text-foreground",
|
|
6711
|
+
onClick: () => showAction(confirmationState.supersededBy),
|
|
6712
|
+
children: copy.seeNewerVersion
|
|
6713
|
+
}) : null
|
|
6714
|
+
]
|
|
6715
|
+
})
|
|
6716
|
+
});
|
|
6717
|
+
}
|
|
6347
6718
|
return /* @__PURE__ */ jsxs("section", {
|
|
6348
|
-
className: joinClasses("plai-tool-result-personal-connector-card overflow-hidden rounded-lg border border-border bg-surface text-foreground",
|
|
6719
|
+
className: joinClasses("plai-tool-result-personal-connector-card overflow-hidden rounded-lg border border-border bg-surface text-foreground", className),
|
|
6349
6720
|
"data-tool-call-id": part.id,
|
|
6350
6721
|
"data-tool-call-state": part.state,
|
|
6351
6722
|
"data-connector-action": view.kind,
|
|
@@ -6511,6 +6882,7 @@ function ToolResultPendingConfirmationCard({ part, locale, className, toolConfir
|
|
|
6511
6882
|
className: joinClasses("plai-tool-result-pending-confirmation-card overflow-hidden rounded-lg border border-border bg-surface text-foreground", className),
|
|
6512
6883
|
"data-tool-call-id": part.id,
|
|
6513
6884
|
"data-tool-call-state": part.state,
|
|
6885
|
+
"data-confirmation-action": pending.action_id,
|
|
6514
6886
|
children: [
|
|
6515
6887
|
/* @__PURE__ */ jsxs("header", {
|
|
6516
6888
|
className: "flex items-center gap-2 border-b border-border px-3 py-2 text-xs text-secondary",
|
|
@@ -6673,6 +7045,7 @@ function ToolResultWorkflowDispatchCard({ part, className, locale }) {
|
|
|
6673
7045
|
const TOOL_USE_ACTIONS = {
|
|
6674
7046
|
agent_invocation: "agent",
|
|
6675
7047
|
browser: "web",
|
|
7048
|
+
code_execution: "code",
|
|
6676
7049
|
datasource: "datasource",
|
|
6677
7050
|
email_send: "email",
|
|
6678
7051
|
external_datasource: "query",
|
|
@@ -6691,6 +7064,7 @@ const TOOL_USE_ACTIONS = {
|
|
|
6691
7064
|
const TOOL_USE_TRANSLATIONS = {
|
|
6692
7065
|
en: {
|
|
6693
7066
|
agent: "Running agent {{toolName}}",
|
|
7067
|
+
code: "Running code with {{toolName}}",
|
|
6694
7068
|
datasource: "Searching in datasource {{toolName}}",
|
|
6695
7069
|
documents: "Working with documents using {{toolName}}",
|
|
6696
7070
|
email: "Sending email with {{toolName}}",
|
|
@@ -6702,6 +7076,7 @@ const TOOL_USE_TRANSLATIONS = {
|
|
|
6702
7076
|
},
|
|
6703
7077
|
es: {
|
|
6704
7078
|
agent: "Ejecutando el agente {{toolName}}",
|
|
7079
|
+
code: "Ejecutando código con {{toolName}}",
|
|
6705
7080
|
datasource: "Buscando en la fuente de datos {{toolName}}",
|
|
6706
7081
|
documents: "Trabajando con documentos mediante {{toolName}}",
|
|
6707
7082
|
email: "Enviando un correo con {{toolName}}",
|
|
@@ -6713,6 +7088,7 @@ const TOOL_USE_TRANSLATIONS = {
|
|
|
6713
7088
|
},
|
|
6714
7089
|
ca: {
|
|
6715
7090
|
agent: "Executant l’agent {{toolName}}",
|
|
7091
|
+
code: "Executant codi amb {{toolName}}",
|
|
6716
7092
|
datasource: "Cercant a la font de dades {{toolName}}",
|
|
6717
7093
|
documents: "Treballant amb documents mitjançant {{toolName}}",
|
|
6718
7094
|
email: "Enviant un correu amb {{toolName}}",
|
|
@@ -6724,6 +7100,7 @@ const TOOL_USE_TRANSLATIONS = {
|
|
|
6724
7100
|
},
|
|
6725
7101
|
fr: {
|
|
6726
7102
|
agent: "Exécution de l’agent {{toolName}}",
|
|
7103
|
+
code: "Exécution du code avec {{toolName}}",
|
|
6727
7104
|
datasource: "Recherche dans la source de données {{toolName}}",
|
|
6728
7105
|
documents: "Traitement de documents avec {{toolName}}",
|
|
6729
7106
|
email: "Envoi d’un e-mail avec {{toolName}}",
|
|
@@ -6735,6 +7112,7 @@ const TOOL_USE_TRANSLATIONS = {
|
|
|
6735
7112
|
},
|
|
6736
7113
|
it: {
|
|
6737
7114
|
agent: "Esecuzione dell’agente {{toolName}}",
|
|
7115
|
+
code: "Esecuzione del codice con {{toolName}}",
|
|
6738
7116
|
datasource: "Ricerca nella fonte dati {{toolName}}",
|
|
6739
7117
|
documents: "Elaborazione di documenti con {{toolName}}",
|
|
6740
7118
|
email: "Invio di un’email con {{toolName}}",
|
|
@@ -6746,6 +7124,7 @@ const TOOL_USE_TRANSLATIONS = {
|
|
|
6746
7124
|
},
|
|
6747
7125
|
de: {
|
|
6748
7126
|
agent: "Agent {{toolName}} wird ausgeführt",
|
|
7127
|
+
code: "Code wird mit {{toolName}} ausgeführt",
|
|
6749
7128
|
datasource: "Suche in der Datenquelle {{toolName}}",
|
|
6750
7129
|
documents: "Dokumente werden mit {{toolName}} bearbeitet",
|
|
6751
7130
|
email: "E-Mail wird mit {{toolName}} gesendet",
|
|
@@ -6757,6 +7136,7 @@ const TOOL_USE_TRANSLATIONS = {
|
|
|
6757
7136
|
},
|
|
6758
7137
|
da: {
|
|
6759
7138
|
agent: "Kører agenten {{toolName}}",
|
|
7139
|
+
code: "Kører kode med {{toolName}}",
|
|
6760
7140
|
datasource: "Søger i datakilden {{toolName}}",
|
|
6761
7141
|
documents: "Arbejder med dokumenter via {{toolName}}",
|
|
6762
7142
|
email: "Sender e-mail med {{toolName}}",
|
|
@@ -6768,6 +7148,7 @@ const TOOL_USE_TRANSLATIONS = {
|
|
|
6768
7148
|
},
|
|
6769
7149
|
sv: {
|
|
6770
7150
|
agent: "Kör agenten {{toolName}}",
|
|
7151
|
+
code: "Kör kod med {{toolName}}",
|
|
6771
7152
|
datasource: "Söker i datakällan {{toolName}}",
|
|
6772
7153
|
documents: "Arbetar med dokument via {{toolName}}",
|
|
6773
7154
|
email: "Skickar e-post med {{toolName}}",
|
|
@@ -6779,6 +7160,7 @@ const TOOL_USE_TRANSLATIONS = {
|
|
|
6779
7160
|
},
|
|
6780
7161
|
no: {
|
|
6781
7162
|
agent: "Kjører agenten {{toolName}}",
|
|
7163
|
+
code: "Kjører kode med {{toolName}}",
|
|
6782
7164
|
datasource: "Søker i datakilden {{toolName}}",
|
|
6783
7165
|
documents: "Arbeider med dokumenter via {{toolName}}",
|
|
6784
7166
|
email: "Sender e-post med {{toolName}}",
|
|
@@ -6790,6 +7172,7 @@ const TOOL_USE_TRANSLATIONS = {
|
|
|
6790
7172
|
},
|
|
6791
7173
|
pt: {
|
|
6792
7174
|
agent: "Executando o agente {{toolName}}",
|
|
7175
|
+
code: "Executando código com {{toolName}}",
|
|
6793
7176
|
datasource: "Pesquisando na fonte de dados {{toolName}}",
|
|
6794
7177
|
documents: "Trabalhando com documentos usando {{toolName}}",
|
|
6795
7178
|
email: "Enviando e-mail com {{toolName}}",
|
|
@@ -6869,6 +7252,15 @@ function getDatasourceResourceLinks(part) {
|
|
|
6869
7252
|
const links = part.metadata.resource_links;
|
|
6870
7253
|
return Array.isArray(links) ? links.filter(isResourceLink) : [];
|
|
6871
7254
|
}
|
|
7255
|
+
/**
|
|
7256
|
+
* A held mail or calendar action, whichever tool reported it. The result of
|
|
7257
|
+
* `replace_pending_action` is a `tool_confirmation` result that carries the new version
|
|
7258
|
+
* with the connector's metadata: it must look exactly as preparing it did (the mail or
|
|
7259
|
+
* event card), not like an anonymous tool with its arguments as JSON.
|
|
7260
|
+
*/
|
|
7261
|
+
function isConnectorPending(part) {
|
|
7262
|
+
return part.metadata?.type === "personal_connector" && !!getPendingConfirmation(part);
|
|
7263
|
+
}
|
|
6872
7264
|
function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAgentThread, getResourceDownloadUrl, memoryProposal, toolConfirmation }) {
|
|
6873
7265
|
const copy = getUiCopy(locale);
|
|
6874
7266
|
if (part.toolType === "memory_proposal") {
|
|
@@ -6892,12 +7284,17 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
|
|
|
6892
7284
|
locale,
|
|
6893
7285
|
className
|
|
6894
7286
|
});
|
|
7287
|
+
if (part.state === "error" && part.toolType === "code_execution") return /* @__PURE__ */ jsx(ToolResultCodeExecutionCard, {
|
|
7288
|
+
part,
|
|
7289
|
+
locale,
|
|
7290
|
+
className
|
|
7291
|
+
});
|
|
6895
7292
|
if (part.state === "error") return /* @__PURE__ */ jsx(ToolError, {
|
|
6896
7293
|
part,
|
|
6897
7294
|
locale,
|
|
6898
7295
|
className
|
|
6899
7296
|
});
|
|
6900
|
-
if (part.toolType !== "personal_connector" && getPendingConfirmation(part)) return /* @__PURE__ */ jsx(ToolResultPendingConfirmationCard, {
|
|
7297
|
+
if (part.toolType !== "personal_connector" && !isConnectorPending(part) && getPendingConfirmation(part)) return /* @__PURE__ */ jsx(ToolResultPendingConfirmationCard, {
|
|
6901
7298
|
part,
|
|
6902
7299
|
locale,
|
|
6903
7300
|
className,
|
|
@@ -6922,6 +7319,11 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
|
|
|
6922
7319
|
locale,
|
|
6923
7320
|
className
|
|
6924
7321
|
});
|
|
7322
|
+
if (part.toolType === "code_execution") return /* @__PURE__ */ jsx(ToolResultCodeExecutionCard, {
|
|
7323
|
+
part,
|
|
7324
|
+
locale,
|
|
7325
|
+
className
|
|
7326
|
+
});
|
|
6925
7327
|
if (part.toolType === "external_datasource") return /* @__PURE__ */ jsx(ToolResultExternalDatasourceCard, {
|
|
6926
7328
|
part,
|
|
6927
7329
|
locale,
|
|
@@ -6942,7 +7344,7 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
|
|
|
6942
7344
|
locale,
|
|
6943
7345
|
className
|
|
6944
7346
|
});
|
|
6945
|
-
if (part.toolType === "personal_connector" && hasPersonalConnectorView(part)) return /* @__PURE__ */ jsx(ToolResultPersonalConnectorCard, {
|
|
7347
|
+
if ((part.toolType === "personal_connector" || isConnectorPending(part)) && hasPersonalConnectorView(part)) return /* @__PURE__ */ jsx(ToolResultPersonalConnectorCard, {
|
|
6946
7348
|
part,
|
|
6947
7349
|
locale,
|
|
6948
7350
|
className,
|
|
@@ -8052,9 +8454,9 @@ function getFileKey(url) {
|
|
|
8052
8454
|
}
|
|
8053
8455
|
/**
|
|
8054
8456
|
* Collects the files of the loaded messages, in conversation order: the user's
|
|
8055
|
-
* attachments and the files produced by office_documents
|
|
8056
|
-
* without a URL are skipped; a file seen twice is listed
|
|
8057
|
-
* history omits media file ids, so files are matched by URL.
|
|
8457
|
+
* attachments and the files produced by office_documents and code_execution
|
|
8458
|
+
* tool calls. Files without a URL are skipped; a file seen twice is listed
|
|
8459
|
+
* once. Persisted history omits media file ids, so files are matched by URL.
|
|
8058
8460
|
*/
|
|
8059
8461
|
function getConversationFiles(messages) {
|
|
8060
8462
|
const uploaded = [];
|
|
@@ -8090,7 +8492,7 @@ function getConversationFiles(messages) {
|
|
|
8090
8492
|
extension: getFileExtension(name),
|
|
8091
8493
|
messageId: message.id
|
|
8092
8494
|
});
|
|
8093
|
-
} else if (part.type === "tool-call" && part.toolType === "office_documents") {
|
|
8495
|
+
} else if (part.type === "tool-call" && (part.toolType === "office_documents" || part.toolType === "code_execution")) {
|
|
8094
8496
|
const mediaFiles = part.metadata?.media_files;
|
|
8095
8497
|
if (!Array.isArray(mediaFiles)) continue;
|
|
8096
8498
|
for (const file of mediaFiles) {
|
|
@@ -8215,5 +8617,5 @@ function ConversationFilesSheet({ messages, locale, className, open, onOpenChang
|
|
|
8215
8617
|
}
|
|
8216
8618
|
|
|
8217
8619
|
//#endregion
|
|
8218
|
-
export { AggregatedSourceResults, ArrowUp, AssistantMessage, ChatError, Clipboard, ConfirmationBadge, ConversationFilesList, ConversationFilesSheet, DatasourceFolderCard, DatasourceToolResources, DatasourceToolResultCard, Loader, MemoryProposalCard, Message, MessageAvatar, MessageContent, MessageFooter, MessageHeader, MessageParts, MessageRoot, Microphone, PROMPT_FORM_FILE_ACCEPT, Paperclip, PendingConfirmationFooter, 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, getPendingConfirmation, getResourceDescription, getResourceIcon, getResourceOpenGraphImage, getResourceOpenGraphType, getResourceTitle, getResourceType, getResourceUrl, getToolUseLabel, hasPersonalConnectorView, hasToolConfirmationView, isAllowedPromptFormFile, partitionPromptFormFiles, reasonLabel, useSpeechToText };
|
|
8620
|
+
export { AggregatedSourceResults, ArrowUp, AssistantMessage, ChatError, Clipboard, ConfirmationBadge, ConversationFilesList, ConversationFilesSheet, DatasourceFolderCard, DatasourceToolResources, DatasourceToolResultCard, Loader, MemoryProposalCard, Message, MessageAvatar, MessageContent, MessageFooter, MessageHeader, MessageParts, MessageRoot, Microphone, PROMPT_FORM_FILE_ACCEPT, Paperclip, PendingConfirmationFooter, 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, getPendingConfirmation, getResourceDescription, getResourceIcon, getResourceOpenGraphImage, getResourceOpenGraphType, getResourceTitle, getResourceType, getResourceUrl, getToolUseLabel, hasPersonalConnectorView, hasToolConfirmationView, isAllowedPromptFormFile, partitionPromptFormFiles, reasonLabel, useSpeechToText };
|
|
8219
8621
|
//# sourceMappingURL=index.js.map
|