@plaisolutions/react 0.16.0 → 0.17.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 +130 -6
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +424 -44
- package/dist/components/index.js.map +1 -1
- package/dist/index.d.ts +65 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +494 -44
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,8 +1,73 @@
|
|
|
1
|
-
import { HttpStatusError, PlaiChat } from "@plaisolutions/client";
|
|
1
|
+
import { HttpStatusError, OPEN_TOOL_CONFIRMATION_STATUSES, PlaiChat, isHiddenMessage, pendingActionIds, toolConfirmationAt } from "@plaisolutions/client";
|
|
2
2
|
import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
3
3
|
import { Bot, Brain, CalendarDays, Check, CheckCircle2, ChevronDown, CircleAlert, CircleX, Clock, Copy, Database, ExternalLink, File, FileText, Globe, LoaderCircle, Mail, MessageSquare, Minus, Plug, Plus, RotateCcw, ThumbsDown, ThumbsUp, Video, Workflow, XCircle } from "lucide-react";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
|
|
6
|
+
//#region src/use-tool-confirmations.ts
|
|
7
|
+
/** State of the chat's actions awaiting confirmation, for the cards. */
|
|
8
|
+
function useToolConfirmations(chat) {
|
|
9
|
+
const subscribe = useCallback((onStoreChange) => chat.toolConfirmations.subscribe(onStoreChange), [chat]);
|
|
10
|
+
const getSnapshot = useCallback(() => chat.toolConfirmations.getSnapshot(), [chat]);
|
|
11
|
+
return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Keeps the cards' state in line with the server: on mount and history loads,
|
|
15
|
+
* when the tab regains focus or the connection, and periodically while some
|
|
16
|
+
* action can still change. A stream already updates the store by itself.
|
|
17
|
+
*/
|
|
18
|
+
function useToolConfirmationSync(chat, { enabled = true, intervalMs = 15e3 } = {}) {
|
|
19
|
+
const [error, setError] = useState(null);
|
|
20
|
+
const inFlight = useRef(null);
|
|
21
|
+
const snapshot = useToolConfirmations(chat);
|
|
22
|
+
const shownIds = pendingActionIds(useSyncExternalStore(useCallback((onStoreChange) => chat.subscribe(onStoreChange), [chat]), useCallback(() => chat.getState().messages, [chat]), useCallback(() => chat.getInitialState().messages, [chat]))).join(",");
|
|
23
|
+
const refresh = useCallback(async () => {
|
|
24
|
+
if (!enabled) return;
|
|
25
|
+
if (inFlight.current) return inFlight.current;
|
|
26
|
+
const run = chat.refreshToolConfirmations().then(() => setError(null)).catch((reason) => setError(reason)).finally(() => {
|
|
27
|
+
inFlight.current = null;
|
|
28
|
+
});
|
|
29
|
+
inFlight.current = run;
|
|
30
|
+
return run;
|
|
31
|
+
}, [chat, enabled]);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (shownIds) refresh();
|
|
34
|
+
}, [refresh, shownIds]);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!enabled || typeof window === "undefined") return;
|
|
37
|
+
const onVisible = () => {
|
|
38
|
+
if (document.visibilityState === "visible") refresh();
|
|
39
|
+
};
|
|
40
|
+
const onOnline = () => void refresh();
|
|
41
|
+
window.addEventListener("focus", onOnline);
|
|
42
|
+
window.addEventListener("online", onOnline);
|
|
43
|
+
document.addEventListener("visibilitychange", onVisible);
|
|
44
|
+
return () => {
|
|
45
|
+
window.removeEventListener("focus", onOnline);
|
|
46
|
+
window.removeEventListener("online", onOnline);
|
|
47
|
+
document.removeEventListener("visibilitychange", onVisible);
|
|
48
|
+
};
|
|
49
|
+
}, [enabled, refresh]);
|
|
50
|
+
const hasOpen = shownIds.length > 0 && shownIds.split(",").some((actionId) => {
|
|
51
|
+
const item = snapshot.items[actionId];
|
|
52
|
+
return !item || OPEN_TOOL_CONFIRMATION_STATUSES.has(item.status);
|
|
53
|
+
});
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (!enabled || !hasOpen || intervalMs <= 0) return;
|
|
56
|
+
const timer = setInterval(() => void refresh(), intervalMs);
|
|
57
|
+
return () => clearInterval(timer);
|
|
58
|
+
}, [
|
|
59
|
+
enabled,
|
|
60
|
+
hasOpen,
|
|
61
|
+
intervalMs,
|
|
62
|
+
refresh
|
|
63
|
+
]);
|
|
64
|
+
return {
|
|
65
|
+
error,
|
|
66
|
+
refresh
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
6
71
|
//#region src/use-chat.ts
|
|
7
72
|
function useChat(options) {
|
|
8
73
|
const optionsRef = useRef(options);
|
|
@@ -25,6 +90,7 @@ function useChat(options) {
|
|
|
25
90
|
]);
|
|
26
91
|
const chat = external ?? owned;
|
|
27
92
|
const state = useSyncExternalStore(useCallback((onStoreChange) => chat.subscribe(onStoreChange), [chat]), useCallback(() => chat.getState(), [chat]), useCallback(() => chat.getInitialState(), [chat]));
|
|
93
|
+
const toolConfirmations = useToolConfirmations(chat);
|
|
28
94
|
useEffect(() => {
|
|
29
95
|
if (!owned) return;
|
|
30
96
|
return () => {
|
|
@@ -33,6 +99,8 @@ function useChat(options) {
|
|
|
33
99
|
}, [owned]);
|
|
34
100
|
const actions = useMemo(() => ({
|
|
35
101
|
sendMessage: chat.sendMessage.bind(chat),
|
|
102
|
+
decideToolActions: chat.decideToolActions.bind(chat),
|
|
103
|
+
refreshToolConfirmations: chat.refreshToolConfirmations.bind(chat),
|
|
36
104
|
rateMessage: chat.rateMessage.bind(chat),
|
|
37
105
|
getMemoryProposal: chat.getMemoryProposal.bind(chat),
|
|
38
106
|
acceptMemoryProposal: chat.acceptMemoryProposal.bind(chat),
|
|
@@ -47,11 +115,13 @@ function useChat(options) {
|
|
|
47
115
|
clearError: chat.clearError.bind(chat)
|
|
48
116
|
}), [chat]);
|
|
49
117
|
return {
|
|
118
|
+
chat,
|
|
50
119
|
messages: state.messages,
|
|
51
120
|
status: state.status,
|
|
52
121
|
error: state.error,
|
|
53
122
|
usage: state.usage,
|
|
54
123
|
uploadState: state.uploadState,
|
|
124
|
+
toolConfirmations,
|
|
55
125
|
...actions
|
|
56
126
|
};
|
|
57
127
|
}
|
|
@@ -4021,7 +4091,29 @@ const ENGLISH = {
|
|
|
4021
4091
|
actionFailed: "Failed",
|
|
4022
4092
|
openEmail: "Open email",
|
|
4023
4093
|
openEvent: "Open event",
|
|
4024
|
-
replyInThread: "Reply in the same thread"
|
|
4094
|
+
replyInThread: "Reply in the same thread",
|
|
4095
|
+
confirmSend: "Send",
|
|
4096
|
+
confirmCreate: "Create",
|
|
4097
|
+
confirmUpdate: "Save changes",
|
|
4098
|
+
confirmDelete: "Delete",
|
|
4099
|
+
confirmGeneric: "Confirm",
|
|
4100
|
+
cancel: "Cancel",
|
|
4101
|
+
confirming: "Confirming…",
|
|
4102
|
+
cancelling: "Cancelling…",
|
|
4103
|
+
verifying: "Checking status…",
|
|
4104
|
+
expiresIn: "Expires in {{minutes}} min",
|
|
4105
|
+
expiresSoon: "Expires in less than a minute",
|
|
4106
|
+
statusExecuting: "Running…",
|
|
4107
|
+
statusExecuted: "Done",
|
|
4108
|
+
statusRejected: "Cancelled",
|
|
4109
|
+
statusExpired: "Expired: ask again in the chat",
|
|
4110
|
+
statusSuperseded: "Replaced by a newer version",
|
|
4111
|
+
statusInvalidated: "Can no longer run: ask again",
|
|
4112
|
+
statusFailed: "Failed",
|
|
4113
|
+
statusUnknown: "Outcome unknown: check before trying again",
|
|
4114
|
+
statusNotFound: "Not available in this conversation",
|
|
4115
|
+
toolUnavailable: "The tool for this action isn’t available right now",
|
|
4116
|
+
decisionError: "Your decision couldn’t be sent. Try again."
|
|
4025
4117
|
};
|
|
4026
4118
|
const COPY = {
|
|
4027
4119
|
en: {},
|
|
@@ -4073,7 +4165,29 @@ const COPY = {
|
|
|
4073
4165
|
actionFailed: "Error",
|
|
4074
4166
|
openEmail: "Abrir correo",
|
|
4075
4167
|
openEvent: "Abrir evento",
|
|
4076
|
-
replyInThread: "Respuesta en el mismo hilo"
|
|
4168
|
+
replyInThread: "Respuesta en el mismo hilo",
|
|
4169
|
+
confirmSend: "Enviar",
|
|
4170
|
+
confirmCreate: "Crear",
|
|
4171
|
+
confirmUpdate: "Guardar cambios",
|
|
4172
|
+
confirmDelete: "Eliminar",
|
|
4173
|
+
confirmGeneric: "Confirmar",
|
|
4174
|
+
cancel: "Cancelar",
|
|
4175
|
+
confirming: "Confirmando…",
|
|
4176
|
+
cancelling: "Cancelando…",
|
|
4177
|
+
verifying: "Comprobando el estado…",
|
|
4178
|
+
expiresIn: "Caduca en {{minutes}} min",
|
|
4179
|
+
expiresSoon: "Caduca en menos de un minuto",
|
|
4180
|
+
statusExecuting: "Ejecutando…",
|
|
4181
|
+
statusExecuted: "Hecho",
|
|
4182
|
+
statusRejected: "Cancelada",
|
|
4183
|
+
statusExpired: "Caducada: pídelo de nuevo en el chat",
|
|
4184
|
+
statusSuperseded: "Sustituida por una versión más reciente",
|
|
4185
|
+
statusInvalidated: "Ya no se puede ejecutar: pídelo de nuevo",
|
|
4186
|
+
statusFailed: "No se pudo completar",
|
|
4187
|
+
statusUnknown: "Resultado desconocido: compruébalo antes de repetirlo",
|
|
4188
|
+
statusNotFound: "No disponible en esta conversación",
|
|
4189
|
+
toolUnavailable: "La herramienta de esta acción no está disponible ahora",
|
|
4190
|
+
decisionError: "No se pudo enviar tu decisión. Inténtalo de nuevo."
|
|
4077
4191
|
},
|
|
4078
4192
|
ca: {
|
|
4079
4193
|
searchingMail: "Cercant a {{service}}",
|
|
@@ -4123,7 +4237,29 @@ const COPY = {
|
|
|
4123
4237
|
actionFailed: "Error",
|
|
4124
4238
|
openEmail: "Obre el correu",
|
|
4125
4239
|
openEvent: "Obre l’esdeveniment",
|
|
4126
|
-
replyInThread: "Resposta al mateix fil"
|
|
4240
|
+
replyInThread: "Resposta al mateix fil",
|
|
4241
|
+
confirmSend: "Envia",
|
|
4242
|
+
confirmCreate: "Crea",
|
|
4243
|
+
confirmUpdate: "Desa els canvis",
|
|
4244
|
+
confirmDelete: "Elimina",
|
|
4245
|
+
confirmGeneric: "Confirma",
|
|
4246
|
+
cancel: "Cancel·la",
|
|
4247
|
+
confirming: "Confirmant…",
|
|
4248
|
+
cancelling: "Cancel·lant…",
|
|
4249
|
+
verifying: "Comprovant l’estat…",
|
|
4250
|
+
expiresIn: "Caduca d’aquí a {{minutes}} min",
|
|
4251
|
+
expiresSoon: "Caduca en menys d’un minut",
|
|
4252
|
+
statusExecuting: "Executant…",
|
|
4253
|
+
statusExecuted: "Fet",
|
|
4254
|
+
statusRejected: "Cancel·lada",
|
|
4255
|
+
statusExpired: "Caducada: torna-ho a demanar al xat",
|
|
4256
|
+
statusSuperseded: "Substituïda per una versió més recent",
|
|
4257
|
+
statusInvalidated: "Ja no es pot executar: torna-ho a demanar",
|
|
4258
|
+
statusFailed: "No s’ha pogut completar",
|
|
4259
|
+
statusUnknown: "Resultat desconegut: comprova-ho abans de repetir-ho",
|
|
4260
|
+
statusNotFound: "No disponible en aquesta conversa",
|
|
4261
|
+
toolUnavailable: "L’eina d’aquesta acció no està disponible ara",
|
|
4262
|
+
decisionError: "No s’ha pogut enviar la teva decisió. Torna-ho a provar."
|
|
4127
4263
|
},
|
|
4128
4264
|
fr: {
|
|
4129
4265
|
searchingMail: "Recherche dans {{service}}",
|
|
@@ -4173,7 +4309,29 @@ const COPY = {
|
|
|
4173
4309
|
actionFailed: "Échec",
|
|
4174
4310
|
openEmail: "Ouvrir l’e-mail",
|
|
4175
4311
|
openEvent: "Ouvrir l’événement",
|
|
4176
|
-
replyInThread: "Réponse dans le même fil"
|
|
4312
|
+
replyInThread: "Réponse dans le même fil",
|
|
4313
|
+
confirmSend: "Envoyer",
|
|
4314
|
+
confirmCreate: "Créer",
|
|
4315
|
+
confirmUpdate: "Enregistrer les modifications",
|
|
4316
|
+
confirmDelete: "Supprimer",
|
|
4317
|
+
confirmGeneric: "Confirmer",
|
|
4318
|
+
cancel: "Annuler",
|
|
4319
|
+
confirming: "Confirmation…",
|
|
4320
|
+
cancelling: "Annulation…",
|
|
4321
|
+
verifying: "Vérification de l’état…",
|
|
4322
|
+
expiresIn: "Expire dans {{minutes}} min",
|
|
4323
|
+
expiresSoon: "Expire dans moins d’une minute",
|
|
4324
|
+
statusExecuting: "En cours…",
|
|
4325
|
+
statusExecuted: "Terminé",
|
|
4326
|
+
statusRejected: "Annulée",
|
|
4327
|
+
statusExpired: "Expirée : redemandez-la dans le chat",
|
|
4328
|
+
statusSuperseded: "Remplacée par une version plus récente",
|
|
4329
|
+
statusInvalidated: "Ne peut plus être exécutée : redemandez-la",
|
|
4330
|
+
statusFailed: "Échec",
|
|
4331
|
+
statusUnknown: "Résultat inconnu : vérifiez avant de réessayer",
|
|
4332
|
+
statusNotFound: "Indisponible dans cette conversation",
|
|
4333
|
+
toolUnavailable: "L’outil de cette action n’est pas disponible pour le moment",
|
|
4334
|
+
decisionError: "Impossible d’envoyer votre décision. Réessayez."
|
|
4177
4335
|
},
|
|
4178
4336
|
it: {
|
|
4179
4337
|
searchingMail: "Ricerca in {{service}}",
|
|
@@ -4223,7 +4381,29 @@ const COPY = {
|
|
|
4223
4381
|
actionFailed: "Errore",
|
|
4224
4382
|
openEmail: "Apri email",
|
|
4225
4383
|
openEvent: "Apri evento",
|
|
4226
|
-
replyInThread: "Risposta nello stesso thread"
|
|
4384
|
+
replyInThread: "Risposta nello stesso thread",
|
|
4385
|
+
confirmSend: "Invia",
|
|
4386
|
+
confirmCreate: "Crea",
|
|
4387
|
+
confirmUpdate: "Salva modifiche",
|
|
4388
|
+
confirmDelete: "Elimina",
|
|
4389
|
+
confirmGeneric: "Conferma",
|
|
4390
|
+
cancel: "Annulla",
|
|
4391
|
+
confirming: "Conferma in corso…",
|
|
4392
|
+
cancelling: "Annullamento in corso…",
|
|
4393
|
+
verifying: "Verifica dello stato…",
|
|
4394
|
+
expiresIn: "Scade tra {{minutes}} min",
|
|
4395
|
+
expiresSoon: "Scade tra meno di un minuto",
|
|
4396
|
+
statusExecuting: "In esecuzione…",
|
|
4397
|
+
statusExecuted: "Fatto",
|
|
4398
|
+
statusRejected: "Annullata",
|
|
4399
|
+
statusExpired: "Scaduta: richiedila di nuovo nella chat",
|
|
4400
|
+
statusSuperseded: "Sostituita da una versione più recente",
|
|
4401
|
+
statusInvalidated: "Non può più essere eseguita: richiedila di nuovo",
|
|
4402
|
+
statusFailed: "Non riuscita",
|
|
4403
|
+
statusUnknown: "Esito sconosciuto: verifica prima di riprovare",
|
|
4404
|
+
statusNotFound: "Non disponibile in questa conversazione",
|
|
4405
|
+
toolUnavailable: "Lo strumento di questa azione non è disponibile ora",
|
|
4406
|
+
decisionError: "Impossibile inviare la tua decisione. Riprova."
|
|
4227
4407
|
},
|
|
4228
4408
|
de: {
|
|
4229
4409
|
searchingMail: "Suche in {{service}}",
|
|
@@ -4273,7 +4453,29 @@ const COPY = {
|
|
|
4273
4453
|
actionFailed: "Fehlgeschlagen",
|
|
4274
4454
|
openEmail: "E-Mail öffnen",
|
|
4275
4455
|
openEvent: "Termin öffnen",
|
|
4276
|
-
replyInThread: "Antwort im selben Verlauf"
|
|
4456
|
+
replyInThread: "Antwort im selben Verlauf",
|
|
4457
|
+
confirmSend: "Senden",
|
|
4458
|
+
confirmCreate: "Erstellen",
|
|
4459
|
+
confirmUpdate: "Änderungen speichern",
|
|
4460
|
+
confirmDelete: "Löschen",
|
|
4461
|
+
confirmGeneric: "Bestätigen",
|
|
4462
|
+
cancel: "Abbrechen",
|
|
4463
|
+
confirming: "Wird bestätigt…",
|
|
4464
|
+
cancelling: "Wird abgebrochen…",
|
|
4465
|
+
verifying: "Status wird geprüft…",
|
|
4466
|
+
expiresIn: "Läuft in {{minutes}} Min. ab",
|
|
4467
|
+
expiresSoon: "Läuft in weniger als einer Minute ab",
|
|
4468
|
+
statusExecuting: "Wird ausgeführt…",
|
|
4469
|
+
statusExecuted: "Erledigt",
|
|
4470
|
+
statusRejected: "Abgebrochen",
|
|
4471
|
+
statusExpired: "Abgelaufen: bitte im Chat erneut anfragen",
|
|
4472
|
+
statusSuperseded: "Durch eine neuere Version ersetzt",
|
|
4473
|
+
statusInvalidated: "Kann nicht mehr ausgeführt werden: bitte erneut anfragen",
|
|
4474
|
+
statusFailed: "Fehlgeschlagen",
|
|
4475
|
+
statusUnknown: "Ergebnis unbekannt: vor dem Wiederholen prüfen",
|
|
4476
|
+
statusNotFound: "In dieser Unterhaltung nicht verfügbar",
|
|
4477
|
+
toolUnavailable: "Das Tool für diese Aktion ist gerade nicht verfügbar",
|
|
4478
|
+
decisionError: "Deine Entscheidung konnte nicht gesendet werden. Versuche es erneut."
|
|
4277
4479
|
},
|
|
4278
4480
|
da: {
|
|
4279
4481
|
searchingMail: "Søger i {{service}}",
|
|
@@ -4323,7 +4525,29 @@ const COPY = {
|
|
|
4323
4525
|
actionFailed: "Mislykkedes",
|
|
4324
4526
|
openEmail: "Åbn e-mail",
|
|
4325
4527
|
openEvent: "Åbn begivenhed",
|
|
4326
|
-
replyInThread: "Svar i samme tråd"
|
|
4528
|
+
replyInThread: "Svar i samme tråd",
|
|
4529
|
+
confirmSend: "Send",
|
|
4530
|
+
confirmCreate: "Opret",
|
|
4531
|
+
confirmUpdate: "Gem ændringer",
|
|
4532
|
+
confirmDelete: "Slet",
|
|
4533
|
+
confirmGeneric: "Bekræft",
|
|
4534
|
+
cancel: "Annuller",
|
|
4535
|
+
confirming: "Bekræfter…",
|
|
4536
|
+
cancelling: "Annullerer…",
|
|
4537
|
+
verifying: "Tjekker status…",
|
|
4538
|
+
expiresIn: "Udløber om {{minutes}} min.",
|
|
4539
|
+
expiresSoon: "Udløber om under et minut",
|
|
4540
|
+
statusExecuting: "Kører…",
|
|
4541
|
+
statusExecuted: "Udført",
|
|
4542
|
+
statusRejected: "Annulleret",
|
|
4543
|
+
statusExpired: "Udløbet: bed om det igen i chatten",
|
|
4544
|
+
statusSuperseded: "Erstattet af en nyere version",
|
|
4545
|
+
statusInvalidated: "Kan ikke længere udføres: bed om det igen",
|
|
4546
|
+
statusFailed: "Mislykkedes",
|
|
4547
|
+
statusUnknown: "Ukendt resultat: tjek før du prøver igen",
|
|
4548
|
+
statusNotFound: "Ikke tilgængelig i denne samtale",
|
|
4549
|
+
toolUnavailable: "Værktøjet til denne handling er ikke tilgængeligt lige nu",
|
|
4550
|
+
decisionError: "Din beslutning kunne ikke sendes. Prøv igen."
|
|
4327
4551
|
},
|
|
4328
4552
|
sv: {
|
|
4329
4553
|
searchingMail: "Söker i {{service}}",
|
|
@@ -4373,7 +4597,29 @@ const COPY = {
|
|
|
4373
4597
|
actionFailed: "Misslyckades",
|
|
4374
4598
|
openEmail: "Öppna mejl",
|
|
4375
4599
|
openEvent: "Öppna händelse",
|
|
4376
|
-
replyInThread: "Svar i samma tråd"
|
|
4600
|
+
replyInThread: "Svar i samma tråd",
|
|
4601
|
+
confirmSend: "Skicka",
|
|
4602
|
+
confirmCreate: "Skapa",
|
|
4603
|
+
confirmUpdate: "Spara ändringar",
|
|
4604
|
+
confirmDelete: "Ta bort",
|
|
4605
|
+
confirmGeneric: "Bekräfta",
|
|
4606
|
+
cancel: "Avbryt",
|
|
4607
|
+
confirming: "Bekräftar…",
|
|
4608
|
+
cancelling: "Avbryter…",
|
|
4609
|
+
verifying: "Kontrollerar status…",
|
|
4610
|
+
expiresIn: "Går ut om {{minutes}} min",
|
|
4611
|
+
expiresSoon: "Går ut om mindre än en minut",
|
|
4612
|
+
statusExecuting: "Körs…",
|
|
4613
|
+
statusExecuted: "Klart",
|
|
4614
|
+
statusRejected: "Avbruten",
|
|
4615
|
+
statusExpired: "Utgången: be om det igen i chatten",
|
|
4616
|
+
statusSuperseded: "Ersatt av en nyare version",
|
|
4617
|
+
statusInvalidated: "Kan inte längre köras: be om det igen",
|
|
4618
|
+
statusFailed: "Misslyckades",
|
|
4619
|
+
statusUnknown: "Okänt resultat: kontrollera innan du försöker igen",
|
|
4620
|
+
statusNotFound: "Inte tillgänglig i den här konversationen",
|
|
4621
|
+
toolUnavailable: "Verktyget för den här åtgärden är inte tillgängligt just nu",
|
|
4622
|
+
decisionError: "Ditt beslut kunde inte skickas. Försök igen."
|
|
4377
4623
|
},
|
|
4378
4624
|
no: {
|
|
4379
4625
|
searchingMail: "Søker i {{service}}",
|
|
@@ -4423,7 +4669,29 @@ const COPY = {
|
|
|
4423
4669
|
actionFailed: "Mislyktes",
|
|
4424
4670
|
openEmail: "Åpne e-post",
|
|
4425
4671
|
openEvent: "Åpne hendelse",
|
|
4426
|
-
replyInThread: "Svar i samme tråd"
|
|
4672
|
+
replyInThread: "Svar i samme tråd",
|
|
4673
|
+
confirmSend: "Send",
|
|
4674
|
+
confirmCreate: "Opprett",
|
|
4675
|
+
confirmUpdate: "Lagre endringer",
|
|
4676
|
+
confirmDelete: "Slett",
|
|
4677
|
+
confirmGeneric: "Bekreft",
|
|
4678
|
+
cancel: "Avbryt",
|
|
4679
|
+
confirming: "Bekrefter…",
|
|
4680
|
+
cancelling: "Avbryter…",
|
|
4681
|
+
verifying: "Sjekker status…",
|
|
4682
|
+
expiresIn: "Utløper om {{minutes}} min",
|
|
4683
|
+
expiresSoon: "Utløper om under ett minutt",
|
|
4684
|
+
statusExecuting: "Kjører…",
|
|
4685
|
+
statusExecuted: "Fullført",
|
|
4686
|
+
statusRejected: "Avbrutt",
|
|
4687
|
+
statusExpired: "Utløpt: be om det igjen i chatten",
|
|
4688
|
+
statusSuperseded: "Erstattet av en nyere versjon",
|
|
4689
|
+
statusInvalidated: "Kan ikke lenger utføres: be om det igjen",
|
|
4690
|
+
statusFailed: "Mislyktes",
|
|
4691
|
+
statusUnknown: "Ukjent resultat: sjekk før du prøver igjen",
|
|
4692
|
+
statusNotFound: "Ikke tilgjengelig i denne samtalen",
|
|
4693
|
+
toolUnavailable: "Verktøyet for denne handlingen er ikke tilgjengelig nå",
|
|
4694
|
+
decisionError: "Beslutningen din kunne ikke sendes. Prøv igjen."
|
|
4427
4695
|
},
|
|
4428
4696
|
pt: {
|
|
4429
4697
|
searchingMail: "Pesquisando no {{service}}",
|
|
@@ -4473,7 +4741,29 @@ const COPY = {
|
|
|
4473
4741
|
actionFailed: "Falhou",
|
|
4474
4742
|
openEmail: "Abrir e-mail",
|
|
4475
4743
|
openEvent: "Abrir evento",
|
|
4476
|
-
replyInThread: "Resposta na mesma conversa"
|
|
4744
|
+
replyInThread: "Resposta na mesma conversa",
|
|
4745
|
+
confirmSend: "Enviar",
|
|
4746
|
+
confirmCreate: "Criar",
|
|
4747
|
+
confirmUpdate: "Salvar alterações",
|
|
4748
|
+
confirmDelete: "Excluir",
|
|
4749
|
+
confirmGeneric: "Confirmar",
|
|
4750
|
+
cancel: "Cancelar",
|
|
4751
|
+
confirming: "Confirmando…",
|
|
4752
|
+
cancelling: "Cancelando…",
|
|
4753
|
+
verifying: "Verificando o status…",
|
|
4754
|
+
expiresIn: "Expira em {{minutes}} min",
|
|
4755
|
+
expiresSoon: "Expira em menos de um minuto",
|
|
4756
|
+
statusExecuting: "Executando…",
|
|
4757
|
+
statusExecuted: "Concluído",
|
|
4758
|
+
statusRejected: "Cancelada",
|
|
4759
|
+
statusExpired: "Expirada: peça novamente no chat",
|
|
4760
|
+
statusSuperseded: "Substituída por uma versão mais recente",
|
|
4761
|
+
statusInvalidated: "Não pode mais ser executada: peça novamente",
|
|
4762
|
+
statusFailed: "Falhou",
|
|
4763
|
+
statusUnknown: "Resultado desconhecido: verifique antes de tentar de novo",
|
|
4764
|
+
statusNotFound: "Indisponível nesta conversa",
|
|
4765
|
+
toolUnavailable: "A ferramenta desta ação não está disponível agora",
|
|
4766
|
+
decisionError: "Não foi possível enviar sua decisão. Tente novamente."
|
|
4477
4767
|
}
|
|
4478
4768
|
};
|
|
4479
4769
|
function getPersonalConnectorCopy(locale) {
|
|
@@ -4486,6 +4776,153 @@ function fillCopy(template, values) {
|
|
|
4486
4776
|
return template.replace(/\{\{(\w+)\}\}/g, (match, key) => key in values ? String(values[key]) : match);
|
|
4487
4777
|
}
|
|
4488
4778
|
|
|
4779
|
+
//#endregion
|
|
4780
|
+
//#region src/components/tool-confirmation-controls.tsx
|
|
4781
|
+
const MINUTE = 6e4;
|
|
4782
|
+
/** Re-renders every `intervalMs` while `active`, for countdowns. */
|
|
4783
|
+
function useNow(active, intervalMs = 15e3) {
|
|
4784
|
+
const [now, setNow] = useState(() => Date.now());
|
|
4785
|
+
useEffect(() => {
|
|
4786
|
+
if (!active) return;
|
|
4787
|
+
setNow(Date.now());
|
|
4788
|
+
const timer = setInterval(() => setNow(Date.now()), intervalMs);
|
|
4789
|
+
return () => clearInterval(timer);
|
|
4790
|
+
}, [active, intervalMs]);
|
|
4791
|
+
return now;
|
|
4792
|
+
}
|
|
4793
|
+
/** Server state of a held action, with expiry kept current. */
|
|
4794
|
+
function useToolConfirmationState(pending, toolConfirmation) {
|
|
4795
|
+
const now = useNow((pending ? toolConfirmation?.states.items[pending.action_id] : void 0)?.status === "pending");
|
|
4796
|
+
return toolConfirmation && pending ? toolConfirmationAt(toolConfirmation.states, pending.action_id, now) : void 0;
|
|
4797
|
+
}
|
|
4798
|
+
function verbFor(operation, copy) {
|
|
4799
|
+
switch (operation) {
|
|
4800
|
+
case "send": return copy.confirmSend;
|
|
4801
|
+
case "create": return copy.confirmCreate;
|
|
4802
|
+
case "update": return copy.confirmUpdate;
|
|
4803
|
+
case "delete": return copy.confirmDelete;
|
|
4804
|
+
default: return copy.confirmGeneric;
|
|
4805
|
+
}
|
|
4806
|
+
}
|
|
4807
|
+
const STATUS_COPY = {
|
|
4808
|
+
executing: "statusExecuting",
|
|
4809
|
+
executed: "statusExecuted",
|
|
4810
|
+
rejected: "statusRejected",
|
|
4811
|
+
expired: "statusExpired",
|
|
4812
|
+
superseded: "statusSuperseded",
|
|
4813
|
+
invalidated: "statusInvalidated",
|
|
4814
|
+
failed: "statusFailed",
|
|
4815
|
+
unknown: "statusUnknown",
|
|
4816
|
+
not_found: "statusNotFound"
|
|
4817
|
+
};
|
|
4818
|
+
function statusLabel(status, copy) {
|
|
4819
|
+
const key = STATUS_COPY[status];
|
|
4820
|
+
return key ? copy[key] : null;
|
|
4821
|
+
}
|
|
4822
|
+
const BADGE_TONE = {
|
|
4823
|
+
pending: "border-amber-200 bg-amber-50 text-amber-800",
|
|
4824
|
+
executing: "border-sky-200 bg-sky-50 text-sky-800",
|
|
4825
|
+
executed: "border-emerald-200 bg-emerald-50 text-emerald-800",
|
|
4826
|
+
failed: "border-rose-200 bg-rose-50 text-rose-800",
|
|
4827
|
+
unknown: "border-amber-300 bg-amber-50 text-amber-900"
|
|
4828
|
+
};
|
|
4829
|
+
/** Header badge of a held action: "Awaiting your confirmation" or its outcome. */
|
|
4830
|
+
function ConfirmationBadge({ state, copy }) {
|
|
4831
|
+
const status = state?.status ?? "pending";
|
|
4832
|
+
const label = status === "pending" ? copy.awaitingConfirmation : statusLabel(status, copy);
|
|
4833
|
+
const Icon = status === "executed" ? CheckCircle2 : status === "failed" ? XCircle : status === "executing" ? LoaderCircle : Clock;
|
|
4834
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
4835
|
+
className: joinClasses("ml-auto inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 font-medium", BADGE_TONE[status] ?? "border-neutral-200 bg-neutral-50 text-neutral-700"),
|
|
4836
|
+
"data-confirmation-status": status,
|
|
4837
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
4838
|
+
className: joinClasses("h-3 w-3", status === "executing" ? "animate-spin" : void 0),
|
|
4839
|
+
"aria-hidden": "true"
|
|
4840
|
+
}), label]
|
|
4841
|
+
});
|
|
4842
|
+
}
|
|
4843
|
+
function expiryText(state, serverOffsetMs, now, copy) {
|
|
4844
|
+
if (!state.expiresAt) return null;
|
|
4845
|
+
const left = Date.parse(state.expiresAt) - (now + serverOffsetMs);
|
|
4846
|
+
if (Number.isNaN(left) || left <= 0) return null;
|
|
4847
|
+
return left < MINUTE ? copy.expiresSoon : fillCopy(copy.expiresIn, { minutes: Math.floor(left / MINUTE) });
|
|
4848
|
+
}
|
|
4849
|
+
/**
|
|
4850
|
+
* Footer of a held action. Without `toolConfirmation` it keeps the text hint
|
|
4851
|
+
* (reply "yes"); with it, buttons once the server state is known.
|
|
4852
|
+
*/
|
|
4853
|
+
function PendingConfirmationFooter({ pending, toolConfirmation, copy }) {
|
|
4854
|
+
const state = useToolConfirmationState(pending, toolConfirmation);
|
|
4855
|
+
const now = useNow(state?.status === "pending");
|
|
4856
|
+
const [sending, setSending] = useState(null);
|
|
4857
|
+
const [failed, setFailed] = useState(false);
|
|
4858
|
+
if (!toolConfirmation) return /* @__PURE__ */ jsx("p", {
|
|
4859
|
+
className: "border-t border-amber-100 bg-amber-50/60 px-3 py-2 text-xs text-neutral-700",
|
|
4860
|
+
children: copy.confirmHint
|
|
4861
|
+
});
|
|
4862
|
+
if (!state) return /* @__PURE__ */ jsx("p", {
|
|
4863
|
+
className: "border-t border-neutral-100 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",
|
|
4864
|
+
"aria-live": "polite",
|
|
4865
|
+
children: copy.verifying
|
|
4866
|
+
});
|
|
4867
|
+
if (state.status !== "pending") {
|
|
4868
|
+
const label = statusLabel(state.status, copy);
|
|
4869
|
+
return label ? /* @__PURE__ */ jsxs("p", {
|
|
4870
|
+
className: "border-t border-neutral-100 bg-neutral-50 px-3 py-2 text-xs text-neutral-700",
|
|
4871
|
+
"aria-live": "polite",
|
|
4872
|
+
children: [label, state.status === "failed" && state.error ? `: ${state.error}` : null]
|
|
4873
|
+
}) : null;
|
|
4874
|
+
}
|
|
4875
|
+
const decide = async (decision) => {
|
|
4876
|
+
setSending(decision);
|
|
4877
|
+
setFailed(false);
|
|
4878
|
+
try {
|
|
4879
|
+
await toolConfirmation.decide([{
|
|
4880
|
+
action_id: pending.action_id,
|
|
4881
|
+
decision
|
|
4882
|
+
}]);
|
|
4883
|
+
} catch {
|
|
4884
|
+
setFailed(true);
|
|
4885
|
+
} finally {
|
|
4886
|
+
setSending(null);
|
|
4887
|
+
}
|
|
4888
|
+
};
|
|
4889
|
+
const disabled = Boolean(toolConfirmation.disabled) || sending !== null;
|
|
4890
|
+
const destructive = pending.operation === "delete";
|
|
4891
|
+
const expiry = expiryText(state, toolConfirmation.states.serverOffsetMs, now, copy);
|
|
4892
|
+
const unavailable = state.error === "tool_unavailable";
|
|
4893
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
4894
|
+
className: "flex flex-wrap items-center gap-2 border-t border-amber-100 bg-amber-50/60 px-3 py-2",
|
|
4895
|
+
"data-confirmation-actions": pending.action_id,
|
|
4896
|
+
children: [
|
|
4897
|
+
state.canConfirm ? /* @__PURE__ */ jsxs("button", {
|
|
4898
|
+
type: "button",
|
|
4899
|
+
disabled,
|
|
4900
|
+
onClick: () => void decide("confirm"),
|
|
4901
|
+
className: joinClasses("inline-flex items-center rounded-md px-3 py-1.5 text-xs font-medium text-white disabled:opacity-50", destructive ? "bg-rose-600 hover:bg-rose-700" : "bg-neutral-900 hover:bg-neutral-800"),
|
|
4902
|
+
children: [sending === "confirm" ? /* @__PURE__ */ jsx(LoaderCircle, {
|
|
4903
|
+
className: "mr-2 size-3 animate-spin",
|
|
4904
|
+
"aria-hidden": "true"
|
|
4905
|
+
}) : null, sending === "confirm" ? copy.confirming : verbFor(pending.operation, copy)]
|
|
4906
|
+
}) : null,
|
|
4907
|
+
state.canReject ? /* @__PURE__ */ jsxs("button", {
|
|
4908
|
+
type: "button",
|
|
4909
|
+
disabled,
|
|
4910
|
+
onClick: () => void decide("reject"),
|
|
4911
|
+
className: "inline-flex items-center rounded-md border border-neutral-300 bg-white px-3 py-1.5 text-xs font-medium text-neutral-800 hover:bg-neutral-50 disabled:opacity-50",
|
|
4912
|
+
children: [sending === "reject" ? /* @__PURE__ */ jsx(LoaderCircle, {
|
|
4913
|
+
className: "mr-2 size-3 animate-spin",
|
|
4914
|
+
"aria-hidden": "true"
|
|
4915
|
+
}) : null, sending === "reject" ? copy.cancelling : copy.cancel]
|
|
4916
|
+
}) : null,
|
|
4917
|
+
/* @__PURE__ */ jsx("span", {
|
|
4918
|
+
className: "ml-auto text-xs text-neutral-600",
|
|
4919
|
+
"aria-live": "polite",
|
|
4920
|
+
children: failed ? copy.decisionError : unavailable ? copy.toolUnavailable : expiry
|
|
4921
|
+
})
|
|
4922
|
+
]
|
|
4923
|
+
});
|
|
4924
|
+
}
|
|
4925
|
+
|
|
4489
4926
|
//#endregion
|
|
4490
4927
|
//#region src/components/tool-result-personal-connector-card.tsx
|
|
4491
4928
|
const COLLAPSED_ITEMS = 5;
|
|
@@ -5084,28 +5521,15 @@ function PendingEventView({ operation, pending, locale, copy }) {
|
|
|
5084
5521
|
]
|
|
5085
5522
|
});
|
|
5086
5523
|
}
|
|
5087
|
-
function PendingBadge({ copy }) {
|
|
5088
|
-
return /* @__PURE__ */ jsxs("span", {
|
|
5089
|
-
className: "ml-auto inline-flex shrink-0 items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 font-medium text-amber-800",
|
|
5090
|
-
children: [/* @__PURE__ */ jsx(Clock, {
|
|
5091
|
-
className: "h-3 w-3",
|
|
5092
|
-
"aria-hidden": "true"
|
|
5093
|
-
}), copy.awaitingConfirmation]
|
|
5094
|
-
});
|
|
5095
|
-
}
|
|
5096
|
-
function PendingFooter({ copy }) {
|
|
5097
|
-
return /* @__PURE__ */ jsx("p", {
|
|
5098
|
-
className: "border-t border-amber-100 bg-amber-50/60 px-3 py-2 text-xs text-neutral-700",
|
|
5099
|
-
children: copy.confirmHint
|
|
5100
|
-
});
|
|
5101
|
-
}
|
|
5102
5524
|
function headerCount(view, copy) {
|
|
5103
5525
|
if (view.kind === "mail-list") return count(copy, view.messages.length, copy.emailCountOne, copy.emailCountOther);
|
|
5104
5526
|
if (view.kind === "events") return count(copy, view.events.length, copy.eventCountOne, copy.eventCountOther);
|
|
5105
5527
|
return null;
|
|
5106
5528
|
}
|
|
5107
|
-
function ToolResultPersonalConnectorCard({ part, locale, className }) {
|
|
5529
|
+
function ToolResultPersonalConnectorCard({ part, locale, className, toolConfirmation }) {
|
|
5108
5530
|
const view = getView(part);
|
|
5531
|
+
const pending = view?.kind === "pending-mail" || view?.kind === "pending-event" ? view.pending : null;
|
|
5532
|
+
const confirmationState = useToolConfirmationState(pending, toolConfirmation);
|
|
5109
5533
|
if (!view) return null;
|
|
5110
5534
|
const copy = getPersonalConnectorCopy(locale);
|
|
5111
5535
|
const connector = getConnector(part);
|
|
@@ -5133,7 +5557,10 @@ function ToolResultPersonalConnectorCard({ part, locale, className }) {
|
|
|
5133
5557
|
className: "min-w-0 truncate border-neutral-500 border px-2 py-0.5 rounded-md text-xs text-neutral-500",
|
|
5134
5558
|
children: connector.account_email
|
|
5135
5559
|
}) : null,
|
|
5136
|
-
isPending ? /* @__PURE__ */ jsx(
|
|
5560
|
+
isPending ? /* @__PURE__ */ jsx(ConfirmationBadge, {
|
|
5561
|
+
state: confirmationState,
|
|
5562
|
+
copy
|
|
5563
|
+
}) : total ? /* @__PURE__ */ jsx("span", {
|
|
5137
5564
|
className: "ml-auto shrink-0",
|
|
5138
5565
|
children: total
|
|
5139
5566
|
}) : null
|
|
@@ -5164,7 +5591,11 @@ function ToolResultPersonalConnectorCard({ part, locale, className }) {
|
|
|
5164
5591
|
view,
|
|
5165
5592
|
copy
|
|
5166
5593
|
}),
|
|
5167
|
-
|
|
5594
|
+
pending ? /* @__PURE__ */ jsx(PendingConfirmationFooter, {
|
|
5595
|
+
pending,
|
|
5596
|
+
toolConfirmation,
|
|
5597
|
+
copy
|
|
5598
|
+
}) : null
|
|
5168
5599
|
]
|
|
5169
5600
|
});
|
|
5170
5601
|
}
|
|
@@ -5188,24 +5619,31 @@ function ConfirmedActionRow({ action, copy }) {
|
|
|
5188
5619
|
const operation = typeof metadata?.action === "string" ? metadata.action : "";
|
|
5189
5620
|
const doneKey = DONE_LABELS[operation];
|
|
5190
5621
|
const failed = action.status === "failed";
|
|
5191
|
-
const
|
|
5622
|
+
const executed = action.status === "executed";
|
|
5623
|
+
const label = doneKey ? copy[doneKey] : fillCopy(copy.actionDone, { tool: action.tool_name ?? "" });
|
|
5192
5624
|
const link = text(asRecord(metadata?.result)?.link);
|
|
5625
|
+
const outcome = action.error === "tool_unavailable" ? copy.toolUnavailable : statusLabel(action.status, copy);
|
|
5626
|
+
const title = executed ? label : failed ? `${copy.actionFailed}: ${label}` : action.tool_name ? `${outcome}: ${action.tool_name}` : outcome;
|
|
5193
5627
|
return /* @__PURE__ */ jsxs("li", {
|
|
5194
5628
|
className: "flex items-start gap-2 px-3 py-2",
|
|
5629
|
+
"data-confirmation-status": action.status,
|
|
5195
5630
|
children: [
|
|
5196
5631
|
failed ? /* @__PURE__ */ jsx(XCircle, {
|
|
5197
5632
|
className: "mt-0.5 h-4 w-4 shrink-0 text-rose-600",
|
|
5198
5633
|
"aria-hidden": "true"
|
|
5199
|
-
}) : /* @__PURE__ */ jsx(CheckCircle2, {
|
|
5634
|
+
}) : executed ? /* @__PURE__ */ jsx(CheckCircle2, {
|
|
5200
5635
|
className: "mt-0.5 h-4 w-4 shrink-0 text-emerald-600",
|
|
5201
5636
|
"aria-hidden": "true"
|
|
5637
|
+
}) : /* @__PURE__ */ jsx(Clock, {
|
|
5638
|
+
className: "mt-0.5 h-4 w-4 shrink-0 text-neutral-500",
|
|
5639
|
+
"aria-hidden": "true"
|
|
5202
5640
|
}),
|
|
5203
5641
|
/* @__PURE__ */ jsxs("div", {
|
|
5204
5642
|
className: "min-w-0 flex-1 space-y-0.5",
|
|
5205
5643
|
children: [
|
|
5206
5644
|
/* @__PURE__ */ jsx("p", {
|
|
5207
5645
|
className: "text-sm font-medium text-neutral-950",
|
|
5208
|
-
children:
|
|
5646
|
+
children: title
|
|
5209
5647
|
}),
|
|
5210
5648
|
connector ? /* @__PURE__ */ jsxs("div", {
|
|
5211
5649
|
className: "flex items-center gap-2 truncate text-xs text-neutral-500",
|
|
@@ -5220,7 +5658,7 @@ function ConfirmedActionRow({ action, copy }) {
|
|
|
5220
5658
|
}) : null
|
|
5221
5659
|
]
|
|
5222
5660
|
}),
|
|
5223
|
-
|
|
5661
|
+
executed && link ? /* @__PURE__ */ jsx(ExternalAnchor, {
|
|
5224
5662
|
href: link,
|
|
5225
5663
|
className: "shrink-0",
|
|
5226
5664
|
children: operation === "send" ? copy.openEmail : copy.openEvent
|
|
@@ -5251,8 +5689,9 @@ function formatValue(value) {
|
|
|
5251
5689
|
return JSON.stringify(value, null, 2);
|
|
5252
5690
|
}
|
|
5253
5691
|
/** Generic preview of a held tool call: its name and the exact arguments. */
|
|
5254
|
-
function ToolResultPendingConfirmationCard({ part, locale, className }) {
|
|
5692
|
+
function ToolResultPendingConfirmationCard({ part, locale, className, toolConfirmation }) {
|
|
5255
5693
|
const pending = getPendingConfirmation(part);
|
|
5694
|
+
const confirmationState = useToolConfirmationState(pending, toolConfirmation);
|
|
5256
5695
|
if (!pending) return null;
|
|
5257
5696
|
const copy = getPersonalConnectorCopy(locale);
|
|
5258
5697
|
const entries = Object.entries(pending.action).filter(([key, value]) => key !== "operation" && value !== null && value !== void 0);
|
|
@@ -5266,7 +5705,10 @@ function ToolResultPendingConfirmationCard({ part, locale, className }) {
|
|
|
5266
5705
|
children: [/* @__PURE__ */ jsx("span", {
|
|
5267
5706
|
className: "truncate font-mono font-medium text-neutral-900",
|
|
5268
5707
|
children: part.name
|
|
5269
|
-
}), /* @__PURE__ */ jsx(
|
|
5708
|
+
}), /* @__PURE__ */ jsx(ConfirmationBadge, {
|
|
5709
|
+
state: confirmationState,
|
|
5710
|
+
copy
|
|
5711
|
+
})]
|
|
5270
5712
|
}),
|
|
5271
5713
|
entries.length > 0 ? /* @__PURE__ */ jsx("dl", {
|
|
5272
5714
|
className: "space-y-1.5 px-3 py-3",
|
|
@@ -5278,7 +5720,11 @@ function ToolResultPendingConfirmationCard({ part, locale, className }) {
|
|
|
5278
5720
|
})
|
|
5279
5721
|
}, key))
|
|
5280
5722
|
}) : null,
|
|
5281
|
-
/* @__PURE__ */ jsx(
|
|
5723
|
+
/* @__PURE__ */ jsx(PendingConfirmationFooter, {
|
|
5724
|
+
pending,
|
|
5725
|
+
toolConfirmation,
|
|
5726
|
+
copy
|
|
5727
|
+
})
|
|
5282
5728
|
]
|
|
5283
5729
|
});
|
|
5284
5730
|
}
|
|
@@ -5606,7 +6052,7 @@ function getDatasourceResources$1(part) {
|
|
|
5606
6052
|
const resources = part.metadata.resources;
|
|
5607
6053
|
return Array.isArray(resources) ? resources.filter(isDatasourceResource) : [];
|
|
5608
6054
|
}
|
|
5609
|
-
function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAgentThread, getResourceDownloadUrl, memoryProposal }) {
|
|
6055
|
+
function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAgentThread, getResourceDownloadUrl, memoryProposal, toolConfirmation }) {
|
|
5610
6056
|
const copy = getUiCopy(locale);
|
|
5611
6057
|
if (part.toolType === "memory_proposal") {
|
|
5612
6058
|
const proposal = part.metadata?.proposal;
|
|
@@ -5637,7 +6083,8 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
|
|
|
5637
6083
|
if (part.toolType !== "personal_connector" && getPendingConfirmation(part)) return /* @__PURE__ */ jsx(ToolResultPendingConfirmationCard, {
|
|
5638
6084
|
part,
|
|
5639
6085
|
locale,
|
|
5640
|
-
className
|
|
6086
|
+
className,
|
|
6087
|
+
toolConfirmation
|
|
5641
6088
|
});
|
|
5642
6089
|
const officeMediaFiles = getOfficeDocumentMediaFiles(part);
|
|
5643
6090
|
const datasourceResources = getDatasourceResources$1(part);
|
|
@@ -5680,7 +6127,8 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
|
|
|
5680
6127
|
if (part.toolType === "personal_connector" && hasPersonalConnectorView(part)) return /* @__PURE__ */ jsx(ToolResultPersonalConnectorCard, {
|
|
5681
6128
|
part,
|
|
5682
6129
|
locale,
|
|
5683
|
-
className
|
|
6130
|
+
className,
|
|
6131
|
+
toolConfirmation
|
|
5684
6132
|
});
|
|
5685
6133
|
if (part.toolType === "workflow_dispatch") return /* @__PURE__ */ jsx(ToolResultWorkflowDispatchCard, {
|
|
5686
6134
|
part,
|
|
@@ -5905,7 +6353,7 @@ function getMessageTextClassName(role) {
|
|
|
5905
6353
|
function getMessageTextAlignmentClassName(role) {
|
|
5906
6354
|
return role === "user" ? "text-right" : "text-left";
|
|
5907
6355
|
}
|
|
5908
|
-
function renderPart(part, index, message, isStreaming, onOpenAgentThread, getResourceDownloadUrl, locale, memoryProposal, renderText, renderToolCall, renderThinking, thinkingLabel, completedThinkingLabel, textClassName) {
|
|
6356
|
+
function renderPart(part, index, message, isStreaming, onOpenAgentThread, getResourceDownloadUrl, locale, memoryProposal, renderText, renderToolCall, renderThinking, thinkingLabel, completedThinkingLabel, textClassName, toolConfirmation) {
|
|
5909
6357
|
const copy = getUiCopy(locale);
|
|
5910
6358
|
if (part.type === "text") {
|
|
5911
6359
|
if (renderText) return /* @__PURE__ */ jsx("div", { children: renderText(part, {
|
|
@@ -5964,7 +6412,8 @@ function renderPart(part, index, message, isStreaming, onOpenAgentThread, getRes
|
|
|
5964
6412
|
locale,
|
|
5965
6413
|
onOpenAgentThread,
|
|
5966
6414
|
getResourceDownloadUrl,
|
|
5967
|
-
memoryProposal
|
|
6415
|
+
memoryProposal,
|
|
6416
|
+
toolConfirmation
|
|
5968
6417
|
}, `tool-${part.id}-${index}`);
|
|
5969
6418
|
}
|
|
5970
6419
|
if (part.type === "thinking") {
|
|
@@ -6021,7 +6470,7 @@ function aggregateSourceToolParts(parts, position) {
|
|
|
6021
6470
|
...remainingParts.slice(insertionIndex)
|
|
6022
6471
|
];
|
|
6023
6472
|
}
|
|
6024
|
-
function MessageParts({ message, collapseThreshold = DEFAULT_COLLAPSE_THRESHOLD, sourceToolResultsLayout = "aggregated", sourceToolResultsPosition, maxVisibleSourceCards = 3, datasourceToolResultsPosition, onOpenAgentThread, getResourceDownloadUrl, locale, memoryProposal, renderText, renderToolCall, renderThinking, isStreaming = false, thinkingLabel, completedThinkingLabel, readMoreLabel, readLessLabel, className,...props }) {
|
|
6473
|
+
function MessageParts({ message, collapseThreshold = DEFAULT_COLLAPSE_THRESHOLD, sourceToolResultsLayout = "aggregated", sourceToolResultsPosition, maxVisibleSourceCards = 3, datasourceToolResultsPosition, onOpenAgentThread, getResourceDownloadUrl, locale, memoryProposal, toolConfirmation, renderText, renderToolCall, renderThinking, isStreaming = false, thinkingLabel, completedThinkingLabel, readMoreLabel, readLessLabel, className,...props }) {
|
|
6025
6474
|
const copy = getUiCopy(locale);
|
|
6026
6475
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
6027
6476
|
const textContent = useMemo(() => message.parts.filter((part) => part.type === "text").map((part) => part.text).join("\n"), [message.parts]);
|
|
@@ -6052,7 +6501,7 @@ function MessageParts({ message, collapseThreshold = DEFAULT_COLLAPSE_THRESHOLD,
|
|
|
6052
6501
|
locale,
|
|
6053
6502
|
maxVisible: maxVisibleSourceCards,
|
|
6054
6503
|
getResourceDownloadUrl
|
|
6055
|
-
}, `source-results-${item.index}`) : renderPart(item.part, item.index, message, isStreaming, onOpenAgentThread, getResourceDownloadUrl, locale, memoryProposal, renderText, renderToolCall, renderThinking, thinkingLabel, completedThinkingLabel, textClassName)), canCollapse ? /* @__PURE__ */ jsx("button", {
|
|
6504
|
+
}, `source-results-${item.index}`) : renderPart(item.part, item.index, message, isStreaming, onOpenAgentThread, getResourceDownloadUrl, locale, memoryProposal, renderText, renderToolCall, renderThinking, thinkingLabel, completedThinkingLabel, textClassName, toolConfirmation)), canCollapse ? /* @__PURE__ */ jsx("button", {
|
|
6056
6505
|
type: "button",
|
|
6057
6506
|
className: "text-xs font-medium text-slate-600 hover:text-slate-900",
|
|
6058
6507
|
onClick: () => setIsExpanded((previous) => !previous),
|
|
@@ -6142,6 +6591,7 @@ function isRoutedMessageProps(props) {
|
|
|
6142
6591
|
function Message(props) {
|
|
6143
6592
|
if (!isRoutedMessageProps(props)) return /* @__PURE__ */ jsx(MessageRoot, { ...props });
|
|
6144
6593
|
const { message, avatar, footer, messageClassName, contentClassName, partsClassName, toolResultsClassName, toolPartsClassName, messagePartsProps, getResourceDownloadUrl, className,...rootProps } = props;
|
|
6594
|
+
if (isHiddenMessage(message)) return null;
|
|
6145
6595
|
const routedMessagePartsProps = getResourceDownloadUrl ? {
|
|
6146
6596
|
...messagePartsProps,
|
|
6147
6597
|
getResourceDownloadUrl
|
|
@@ -6782,5 +7232,5 @@ async function dummyTranscribeAudio(_audio, signal) {
|
|
|
6782
7232
|
}
|
|
6783
7233
|
|
|
6784
7234
|
//#endregion
|
|
6785
|
-
export { AggregatedSourceResults, ArrowUp, AssistantMessage, ChatError, Clipboard, 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, getLocalizedOpenGraphValue, getResourceDescription, getResourceIcon, getResourceOpenGraphImage, getResourceOpenGraphType, getResourceTitle, getResourceType, getResourceUrl, getToolUseLabel, isAllowedPromptFormFile, partitionPromptFormFiles, useChat, useChatRegistryBusy, useOwnedChatRegistry, useRegistryChat, useSpeechToText, useStreamCoordinator };
|
|
7235
|
+
export { AggregatedSourceResults, ArrowUp, AssistantMessage, ChatError, Clipboard, 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, getLocalizedOpenGraphValue, getResourceDescription, getResourceIcon, getResourceOpenGraphImage, getResourceOpenGraphType, getResourceTitle, getResourceType, getResourceUrl, getToolUseLabel, isAllowedPromptFormFile, partitionPromptFormFiles, useChat, useChatRegistryBusy, useOwnedChatRegistry, useRegistryChat, useSpeechToText, useStreamCoordinator, useToolConfirmationSync, useToolConfirmations };
|
|
6786
7236
|
//# sourceMappingURL=index.js.map
|