@plaisolutions/react 0.19.0 → 0.21.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.
@@ -1,7 +1,7 @@
1
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";
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
- import { HttpStatusError, isHiddenMessage, toolConfirmationAt } from "@plaisolutions/client";
4
+ import { HttpStatusError, ToolDecisionRejectedError, isHiddenMessage, toolConfirmationAt } from "@plaisolutions/client";
5
5
 
6
6
  //#region src/components/internal/join-classes.ts
7
7
  function joinClasses(...classes) {
@@ -2036,12 +2036,42 @@ function isDatasourceResource(value) {
2036
2036
  const datasource = value.datasource;
2037
2037
  return typeof value.id === "string" && typeof value.name === "string" && typeof value.type === "string" && (value.url === null || typeof value.url === "string") && (value.external_url === null || typeof value.external_url === "string") && isObject(value.metadata) && isObject(value.extra_info) && (folder === null || isObject(folder) && typeof folder.id === "string" && typeof folder.name === "string" && isObject(folder.extra_info)) && (datasource === null || isObject(datasource) && typeof datasource.type === "string" && (datasource.description === null || typeof datasource.description === "string") && (datasource.summary === null || typeof datasource.summary === "string"));
2038
2038
  }
2039
- function getDatasourceResourceCards(resources, locale, getResourceDownloadUrl) {
2039
+ function isResourceLink(value) {
2040
+ return isObject(value) && typeof value.id === "string" && typeof value.resource_id === "string" && typeof value.url === "string" && (value.title === null || typeof value.title === "string") && (value.favicon === null || typeof value.favicon === "string");
2041
+ }
2042
+ function getDatasourceResourceCards(resources, locale, getResourceDownloadUrl, resourceLinks = []) {
2040
2043
  const folderGroups = /* @__PURE__ */ new Map();
2041
2044
  const ungroupedResources = [];
2045
+ const linkCards = [];
2042
2046
  const seenUrls = /* @__PURE__ */ new Set();
2047
+ const linksByResource = /* @__PURE__ */ new Map();
2048
+ for (const link of resourceLinks) {
2049
+ const group = linksByResource.get(link.resource_id);
2050
+ if (group) group.push(link);
2051
+ else linksByResource.set(link.resource_id, [link]);
2052
+ }
2043
2053
  for (const resource of resources) {
2044
2054
  if (resource.extra_info.public === false) continue;
2055
+ const links = linksByResource.get(resource.id);
2056
+ if (resource.type === "WEBPAGE" && links?.length) {
2057
+ for (const link of links) {
2058
+ if (seenUrls.has(link.url)) continue;
2059
+ seenUrls.add(link.url);
2060
+ linkCards.push({
2061
+ kind: "resource",
2062
+ key: `resource-link-${link.id}`,
2063
+ props: {
2064
+ icon: link.favicon ?? void 0,
2065
+ type: getResourceType(resource, locale),
2066
+ title: link.title?.trim() || link.url,
2067
+ url: link.url,
2068
+ resourceId: resource.id,
2069
+ locale
2070
+ }
2071
+ });
2072
+ }
2073
+ continue;
2074
+ }
2045
2075
  const resourceUrl = getResourceUrl(resource, locale);
2046
2076
  if (resourceUrl) {
2047
2077
  if (seenUrls.has(resourceUrl)) continue;
@@ -2058,15 +2088,19 @@ function getDatasourceResourceCards(resources, locale, getResourceDownloadUrl) {
2058
2088
  resources: [resource]
2059
2089
  });
2060
2090
  }
2061
- return [...Array.from(folderGroups.values()).map(({ folder, resources: group }) => ({
2062
- kind: "folder",
2063
- key: `folder-${folder.id}`,
2064
- props: toFolderCardProps(folder, group, locale, getResourceDownloadUrl)
2065
- })), ...ungroupedResources.map((resource) => ({
2066
- kind: "resource",
2067
- key: `resource-${resource.id}`,
2068
- props: toResourceCardProps(resource, locale, getResourceDownloadUrl)
2069
- }))];
2091
+ return [
2092
+ ...Array.from(folderGroups.values()).map(({ folder, resources: group }) => ({
2093
+ kind: "folder",
2094
+ key: `folder-${folder.id}`,
2095
+ props: toFolderCardProps(folder, group, locale, getResourceDownloadUrl)
2096
+ })),
2097
+ ...ungroupedResources.map((resource) => ({
2098
+ kind: "resource",
2099
+ key: `resource-${resource.id}`,
2100
+ props: toResourceCardProps(resource, locale, getResourceDownloadUrl)
2101
+ })),
2102
+ ...linkCards
2103
+ ];
2070
2104
  }
2071
2105
  function DatasourceResourceCardView({ card, variant = "card" }) {
2072
2106
  if (card.kind === "folder") return /* @__PURE__ */ jsx(DatasourceFolderCard, {
@@ -2078,8 +2112,8 @@ function DatasourceResourceCardView({ card, variant = "card" }) {
2078
2112
  variant
2079
2113
  });
2080
2114
  }
2081
- function DatasourceToolResources({ resources, locale, className, getResourceDownloadUrl }) {
2082
- const cards = getDatasourceResourceCards(resources, locale, getResourceDownloadUrl);
2115
+ function DatasourceToolResources({ resources, resourceLinks, locale, className, getResourceDownloadUrl }) {
2116
+ const cards = getDatasourceResourceCards(resources, locale, getResourceDownloadUrl, resourceLinks);
2083
2117
  return /* @__PURE__ */ jsx("section", {
2084
2118
  "aria-label": getUiCopy(locale).datasourceResources,
2085
2119
  className: joinClasses("flex flex-wrap gap-3", className),
@@ -2347,8 +2381,12 @@ function getDatasourceResources$2(part) {
2347
2381
  const resources = part.metadata?.resources;
2348
2382
  return Array.isArray(resources) ? resources.filter(isDatasourceResource) : [];
2349
2383
  }
2384
+ function getDatasourceResourceLinks$1(part) {
2385
+ const links = part.metadata?.resource_links;
2386
+ return Array.isArray(links) ? links.filter(isResourceLink) : [];
2387
+ }
2350
2388
  function getAggregatedCards(parts, locale, getResourceDownloadUrl) {
2351
- const datasourceCards = parts.filter((part) => part.toolType === "datasource").flatMap((part) => getDatasourceResourceCards(getDatasourceResources$2(part), locale, getResourceDownloadUrl).map((card) => ({
2389
+ const datasourceCards = parts.filter((part) => part.toolType === "datasource").flatMap((part) => getDatasourceResourceCards(getDatasourceResources$2(part), locale, getResourceDownloadUrl, getDatasourceResourceLinks$1(part)).map((card) => ({
2352
2390
  kind: "datasource",
2353
2391
  key: `${part.id}-${card.key}`,
2354
2392
  card
@@ -4129,7 +4167,25 @@ const ENGLISH = {
4129
4167
  statusUnknown: "Outcome unknown: check before trying again",
4130
4168
  statusNotFound: "Not available in this conversation",
4131
4169
  toolUnavailable: "The tool for this action isn’t available right now",
4132
- decisionError: "Your decision couldn’t be sent. Try again."
4170
+ decisionError: "Your decision couldn’t be sent. Try again.",
4171
+ edit: "Edit",
4172
+ saveAndSend: "Save and send",
4173
+ saveAndConfirm: "Save and confirm",
4174
+ discardEdit: "Discard changes",
4175
+ fieldBody: "Message",
4176
+ fieldStart: "Starts",
4177
+ fieldEnd: "Ends",
4178
+ addressesHint: "Separate addresses with commas",
4179
+ timeZoneNote: "Time zone: {{zone}}",
4180
+ errorRequired: "This field can’t be empty",
4181
+ errorNoRecipients: "Add at least one recipient",
4182
+ errorInvalidAddress: "Enter valid email addresses",
4183
+ errorInvalidDateTime: "Enter a valid date and time",
4184
+ errorAmbiguousTime: "This time doesn’t exist or happens twice in {{zone}}. Pick another time.",
4185
+ errorEndBeforeStart: "The end must be after the start",
4186
+ editNoLongerApplies: "Your changes no longer apply to this action. Review them and try again.",
4187
+ editedLabel: "Edited",
4188
+ seeNewerVersion: "See the newer version"
4133
4189
  };
4134
4190
  const COPY = {
4135
4191
  en: {},
@@ -4203,7 +4259,25 @@ const COPY = {
4203
4259
  statusUnknown: "Resultado desconocido: compruébalo antes de repetirlo",
4204
4260
  statusNotFound: "No disponible en esta conversación",
4205
4261
  toolUnavailable: "La herramienta de esta acción no está disponible ahora",
4206
- decisionError: "No se pudo enviar tu decisión. Inténtalo de nuevo."
4262
+ decisionError: "No se pudo enviar tu decisión. Inténtalo de nuevo.",
4263
+ edit: "Editar",
4264
+ saveAndSend: "Guardar y enviar",
4265
+ saveAndConfirm: "Guardar y confirmar",
4266
+ discardEdit: "Descartar cambios",
4267
+ fieldBody: "Mensaje",
4268
+ fieldStart: "Empieza",
4269
+ fieldEnd: "Termina",
4270
+ addressesHint: "Separa las direcciones con comas",
4271
+ timeZoneNote: "Zona horaria: {{zone}}",
4272
+ errorRequired: "Este campo no puede estar vacío",
4273
+ errorNoRecipients: "Añade al menos un destinatario",
4274
+ errorInvalidAddress: "Introduce direcciones de correo válidas",
4275
+ errorInvalidDateTime: "Introduce una fecha y hora válidas",
4276
+ errorAmbiguousTime: "Esta hora no existe o se repite en {{zone}}. Elige otra hora.",
4277
+ errorEndBeforeStart: "El final debe ser posterior al inicio",
4278
+ editNoLongerApplies: "Tus cambios ya no se aplican a esta acción. Revísalos e inténtalo de nuevo.",
4279
+ editedLabel: "Editada",
4280
+ seeNewerVersion: "Ver la versión más reciente"
4207
4281
  },
4208
4282
  ca: {
4209
4283
  searchingMail: "Cercant a {{service}}",
@@ -4275,7 +4349,25 @@ const COPY = {
4275
4349
  statusUnknown: "Resultat desconegut: comprova-ho abans de repetir-ho",
4276
4350
  statusNotFound: "No disponible en aquesta conversa",
4277
4351
  toolUnavailable: "L’eina d’aquesta acció no està disponible ara",
4278
- decisionError: "No s’ha pogut enviar la teva decisió. Torna-ho a provar."
4352
+ decisionError: "No s’ha pogut enviar la teva decisió. Torna-ho a provar.",
4353
+ edit: "Edita",
4354
+ saveAndSend: "Desa i envia",
4355
+ saveAndConfirm: "Desa i confirma",
4356
+ discardEdit: "Descarta els canvis",
4357
+ fieldBody: "Missatge",
4358
+ fieldStart: "Comença",
4359
+ fieldEnd: "Acaba",
4360
+ addressesHint: "Separa les adreces amb comes",
4361
+ timeZoneNote: "Zona horària: {{zone}}",
4362
+ errorRequired: "Aquest camp no pot estar buit",
4363
+ errorNoRecipients: "Afegeix com a mínim un destinatari",
4364
+ errorInvalidAddress: "Introdueix adreces de correu vàlides",
4365
+ errorInvalidDateTime: "Introdueix una data i hora vàlides",
4366
+ errorAmbiguousTime: "Aquesta hora no existeix o es repeteix a {{zone}}. Tria una altra hora.",
4367
+ errorEndBeforeStart: "El final ha de ser posterior a l’inici",
4368
+ editNoLongerApplies: "Els teus canvis ja no s’apliquen a aquesta acció. Revisa’ls i torna-ho a provar.",
4369
+ editedLabel: "Editada",
4370
+ seeNewerVersion: "Mostra la versió més recent"
4279
4371
  },
4280
4372
  fr: {
4281
4373
  searchingMail: "Recherche dans {{service}}",
@@ -4347,7 +4439,25 @@ const COPY = {
4347
4439
  statusUnknown: "Résultat inconnu : vérifiez avant de réessayer",
4348
4440
  statusNotFound: "Indisponible dans cette conversation",
4349
4441
  toolUnavailable: "L’outil de cette action n’est pas disponible pour le moment",
4350
- decisionError: "Impossible d’envoyer votre décision. Réessayez."
4442
+ decisionError: "Impossible d’envoyer votre décision. Réessayez.",
4443
+ edit: "Modifier",
4444
+ saveAndSend: "Enregistrer et envoyer",
4445
+ saveAndConfirm: "Enregistrer et confirmer",
4446
+ discardEdit: "Annuler les modifications",
4447
+ fieldBody: "Message",
4448
+ fieldStart: "Début",
4449
+ fieldEnd: "Fin",
4450
+ addressesHint: "Séparez les adresses par des virgules",
4451
+ timeZoneNote: "Fuseau horaire : {{zone}}",
4452
+ errorRequired: "Ce champ ne peut pas être vide",
4453
+ errorNoRecipients: "Ajoutez au moins un destinataire",
4454
+ errorInvalidAddress: "Saisissez des adresses e-mail valides",
4455
+ errorInvalidDateTime: "Saisissez une date et une heure valides",
4456
+ errorAmbiguousTime: "Cette heure n’existe pas ou se répète en {{zone}}. Choisissez une autre heure.",
4457
+ errorEndBeforeStart: "La fin doit être postérieure au début",
4458
+ editNoLongerApplies: "Vos modifications ne s’appliquent plus à cette action. Vérifiez-les et réessayez.",
4459
+ editedLabel: "Modifiée",
4460
+ seeNewerVersion: "Voir la version la plus récente"
4351
4461
  },
4352
4462
  it: {
4353
4463
  searchingMail: "Ricerca in {{service}}",
@@ -4419,7 +4529,25 @@ const COPY = {
4419
4529
  statusUnknown: "Esito sconosciuto: verifica prima di riprovare",
4420
4530
  statusNotFound: "Non disponibile in questa conversazione",
4421
4531
  toolUnavailable: "Lo strumento di questa azione non è disponibile ora",
4422
- decisionError: "Impossibile inviare la tua decisione. Riprova."
4532
+ decisionError: "Impossibile inviare la tua decisione. Riprova.",
4533
+ edit: "Modifica",
4534
+ saveAndSend: "Salva e invia",
4535
+ saveAndConfirm: "Salva e conferma",
4536
+ discardEdit: "Annulla le modifiche",
4537
+ fieldBody: "Messaggio",
4538
+ fieldStart: "Inizio",
4539
+ fieldEnd: "Fine",
4540
+ addressesHint: "Separa gli indirizzi con virgole",
4541
+ timeZoneNote: "Fuso orario: {{zone}}",
4542
+ errorRequired: "Questo campo non può essere vuoto",
4543
+ errorNoRecipients: "Aggiungi almeno un destinatario",
4544
+ errorInvalidAddress: "Inserisci indirizzi e-mail validi",
4545
+ errorInvalidDateTime: "Inserisci una data e un’ora valide",
4546
+ errorAmbiguousTime: "Questo orario non esiste o si ripete in {{zone}}. Scegli un altro orario.",
4547
+ errorEndBeforeStart: "La fine deve essere successiva all’inizio",
4548
+ editNoLongerApplies: "Le tue modifiche non si applicano più a questa azione. Controllale e riprova.",
4549
+ editedLabel: "Modificata",
4550
+ seeNewerVersion: "Vedi la versione più recente"
4423
4551
  },
4424
4552
  de: {
4425
4553
  searchingMail: "Suche in {{service}}",
@@ -4491,7 +4619,25 @@ const COPY = {
4491
4619
  statusUnknown: "Ergebnis unbekannt: vor dem Wiederholen prüfen",
4492
4620
  statusNotFound: "In dieser Unterhaltung nicht verfügbar",
4493
4621
  toolUnavailable: "Das Tool für diese Aktion ist gerade nicht verfügbar",
4494
- decisionError: "Deine Entscheidung konnte nicht gesendet werden. Versuche es erneut."
4622
+ decisionError: "Deine Entscheidung konnte nicht gesendet werden. Versuche es erneut.",
4623
+ edit: "Bearbeiten",
4624
+ saveAndSend: "Speichern und senden",
4625
+ saveAndConfirm: "Speichern und bestätigen",
4626
+ discardEdit: "Änderungen verwerfen",
4627
+ fieldBody: "Nachricht",
4628
+ fieldStart: "Beginn",
4629
+ fieldEnd: "Ende",
4630
+ addressesHint: "Adressen durch Kommas trennen",
4631
+ timeZoneNote: "Zeitzone: {{zone}}",
4632
+ errorRequired: "Dieses Feld darf nicht leer sein",
4633
+ errorNoRecipients: "Füge mindestens einen Empfänger hinzu",
4634
+ errorInvalidAddress: "Gib gültige E-Mail-Adressen ein",
4635
+ errorInvalidDateTime: "Gib ein gültiges Datum und eine gültige Uhrzeit ein",
4636
+ errorAmbiguousTime: "Diese Uhrzeit existiert in {{zone}} nicht oder kommt doppelt vor. Wähle eine andere Uhrzeit.",
4637
+ errorEndBeforeStart: "Das Ende muss nach dem Beginn liegen",
4638
+ editNoLongerApplies: "Deine Änderungen gelten für diese Aktion nicht mehr. Prüfe sie und versuche es erneut.",
4639
+ editedLabel: "Bearbeitet",
4640
+ seeNewerVersion: "Neuere Version ansehen"
4495
4641
  },
4496
4642
  da: {
4497
4643
  searchingMail: "Søger i {{service}}",
@@ -4563,7 +4709,25 @@ const COPY = {
4563
4709
  statusUnknown: "Ukendt resultat: tjek før du prøver igen",
4564
4710
  statusNotFound: "Ikke tilgængelig i denne samtale",
4565
4711
  toolUnavailable: "Værktøjet til denne handling er ikke tilgængeligt lige nu",
4566
- decisionError: "Din beslutning kunne ikke sendes. Prøv igen."
4712
+ decisionError: "Din beslutning kunne ikke sendes. Prøv igen.",
4713
+ edit: "Rediger",
4714
+ saveAndSend: "Gem og send",
4715
+ saveAndConfirm: "Gem og bekræft",
4716
+ discardEdit: "Kassér ændringer",
4717
+ fieldBody: "Besked",
4718
+ fieldStart: "Starter",
4719
+ fieldEnd: "Slutter",
4720
+ addressesHint: "Adskil adresser med komma",
4721
+ timeZoneNote: "Tidszone: {{zone}}",
4722
+ errorRequired: "Feltet må ikke være tomt",
4723
+ errorNoRecipients: "Tilføj mindst én modtager",
4724
+ errorInvalidAddress: "Angiv gyldige mailadresser",
4725
+ errorInvalidDateTime: "Angiv en gyldig dato og tid",
4726
+ errorAmbiguousTime: "Dette tidspunkt findes ikke eller forekommer to gange i {{zone}}. Vælg et andet tidspunkt.",
4727
+ errorEndBeforeStart: "Slutningen skal være efter starten",
4728
+ editNoLongerApplies: "Dine ændringer gælder ikke længere for denne handling. Gennemgå dem og prøv igen.",
4729
+ editedLabel: "Redigeret",
4730
+ seeNewerVersion: "Se den nyere version"
4567
4731
  },
4568
4732
  sv: {
4569
4733
  searchingMail: "Söker i {{service}}",
@@ -4635,7 +4799,25 @@ const COPY = {
4635
4799
  statusUnknown: "Okänt resultat: kontrollera innan du försöker igen",
4636
4800
  statusNotFound: "Inte tillgänglig i den här konversationen",
4637
4801
  toolUnavailable: "Verktyget för den här åtgärden är inte tillgängligt just nu",
4638
- decisionError: "Ditt beslut kunde inte skickas. Försök igen."
4802
+ decisionError: "Ditt beslut kunde inte skickas. Försök igen.",
4803
+ edit: "Redigera",
4804
+ saveAndSend: "Spara och skicka",
4805
+ saveAndConfirm: "Spara och bekräfta",
4806
+ discardEdit: "Ignorera ändringar",
4807
+ fieldBody: "Meddelande",
4808
+ fieldStart: "Börjar",
4809
+ fieldEnd: "Slutar",
4810
+ addressesHint: "Separera adresser med kommatecken",
4811
+ timeZoneNote: "Tidszon: {{zone}}",
4812
+ errorRequired: "Fältet får inte vara tomt",
4813
+ errorNoRecipients: "Lägg till minst en mottagare",
4814
+ errorInvalidAddress: "Ange giltiga e-postadresser",
4815
+ errorInvalidDateTime: "Ange ett giltigt datum och en giltig tid",
4816
+ errorAmbiguousTime: "Den här tiden finns inte eller inträffar två gånger i {{zone}}. Välj en annan tid.",
4817
+ errorEndBeforeStart: "Slutet måste vara efter starten",
4818
+ editNoLongerApplies: "Dina ändringar gäller inte längre för den här åtgärden. Granska dem och försök igen.",
4819
+ editedLabel: "Redigerad",
4820
+ seeNewerVersion: "Se den nyare versionen"
4639
4821
  },
4640
4822
  no: {
4641
4823
  searchingMail: "Søker i {{service}}",
@@ -4707,7 +4889,25 @@ const COPY = {
4707
4889
  statusUnknown: "Ukjent resultat: sjekk før du prøver igjen",
4708
4890
  statusNotFound: "Ikke tilgjengelig i denne samtalen",
4709
4891
  toolUnavailable: "Verktøyet for denne handlingen er ikke tilgjengelig nå",
4710
- decisionError: "Beslutningen din kunne ikke sendes. Prøv igjen."
4892
+ decisionError: "Beslutningen din kunne ikke sendes. Prøv igjen.",
4893
+ edit: "Rediger",
4894
+ saveAndSend: "Lagre og send",
4895
+ saveAndConfirm: "Lagre og bekreft",
4896
+ discardEdit: "Forkast endringer",
4897
+ fieldBody: "Melding",
4898
+ fieldStart: "Starter",
4899
+ fieldEnd: "Slutter",
4900
+ addressesHint: "Skill adresser med komma",
4901
+ timeZoneNote: "Tidssone: {{zone}}",
4902
+ errorRequired: "Feltet kan ikke være tomt",
4903
+ errorNoRecipients: "Legg til minst én mottaker",
4904
+ errorInvalidAddress: "Skriv inn gyldige e-postadresser",
4905
+ errorInvalidDateTime: "Skriv inn en gyldig dato og tid",
4906
+ errorAmbiguousTime: "Dette tidspunktet finnes ikke eller forekommer to ganger i {{zone}}. Velg et annet tidspunkt.",
4907
+ errorEndBeforeStart: "Slutten må være etter starten",
4908
+ editNoLongerApplies: "Endringene dine gjelder ikke lenger for denne handlingen. Gå gjennom dem og prøv igjen.",
4909
+ editedLabel: "Redigert",
4910
+ seeNewerVersion: "Se den nyere versjonen"
4711
4911
  },
4712
4912
  pt: {
4713
4913
  searchingMail: "Pesquisando no {{service}}",
@@ -4779,7 +4979,25 @@ const COPY = {
4779
4979
  statusUnknown: "Resultado desconhecido: verifique antes de tentar de novo",
4780
4980
  statusNotFound: "Indisponível nesta conversa",
4781
4981
  toolUnavailable: "A ferramenta desta ação não está disponível agora",
4782
- decisionError: "Não foi possível enviar sua decisão. Tente novamente."
4982
+ decisionError: "Não foi possível enviar sua decisão. Tente novamente.",
4983
+ edit: "Editar",
4984
+ saveAndSend: "Salvar e enviar",
4985
+ saveAndConfirm: "Salvar e confirmar",
4986
+ discardEdit: "Descartar alterações",
4987
+ fieldBody: "Mensagem",
4988
+ fieldStart: "Início",
4989
+ fieldEnd: "Fim",
4990
+ addressesHint: "Separe os endereços com vírgulas",
4991
+ timeZoneNote: "Fuso horário: {{zone}}",
4992
+ errorRequired: "Este campo não pode ficar vazio",
4993
+ errorNoRecipients: "Adicione pelo menos um destinatário",
4994
+ errorInvalidAddress: "Informe endereços de e-mail válidos",
4995
+ errorInvalidDateTime: "Informe uma data e hora válidas",
4996
+ errorAmbiguousTime: "Este horário não existe ou se repete em {{zone}}. Escolha outro horário.",
4997
+ errorEndBeforeStart: "O fim deve ser posterior ao início",
4998
+ editNoLongerApplies: "Suas alterações não se aplicam mais a esta ação. Revise-as e tente novamente.",
4999
+ editedLabel: "Editada",
5000
+ seeNewerVersion: "Ver a versão mais recente"
4783
5001
  }
4784
5002
  };
4785
5003
  function getPersonalConnectorCopy(locale) {
@@ -4792,6 +5010,325 @@ function fillCopy(template, values) {
4792
5010
  return template.replace(/\{\{(\w+)\}\}/g, (match, key) => key in values ? String(values[key]) : match);
4793
5011
  }
4794
5012
 
5013
+ //#endregion
5014
+ //#region src/components/internal/tool-confirmation-edit.ts
5015
+ const FIELD_KINDS = {
5016
+ to: "addresses",
5017
+ cc: "addresses",
5018
+ attendees: "addresses",
5019
+ subject: "text",
5020
+ title: "text",
5021
+ location: "text",
5022
+ body: "textarea",
5023
+ start: "datetime",
5024
+ end: "datetime"
5025
+ };
5026
+ /** Editable fields in the order the form shows them. */
5027
+ const FIELD_ORDER = [
5028
+ "to",
5029
+ "cc",
5030
+ "subject",
5031
+ "body",
5032
+ "title",
5033
+ "start",
5034
+ "end",
5035
+ "location",
5036
+ "attendees"
5037
+ ];
5038
+ /** Fields of this action the card can show a control for. */
5039
+ function editableFields(pending) {
5040
+ const allowed = new Set(pending.editable ?? []);
5041
+ return FIELD_ORDER.filter((field) => allowed.has(field));
5042
+ }
5043
+ const OFFSET_SUFFIX = /(Z|[+-]\d{2}:?\d{2})$/i;
5044
+ function parseOffsetMinutes(value) {
5045
+ const match = OFFSET_SUFFIX.exec(value.trim());
5046
+ if (!match) return null;
5047
+ const text$2 = match[1].toUpperCase();
5048
+ if (text$2 === "Z") return 0;
5049
+ const sign = text$2[0] === "-" ? -1 : 1;
5050
+ const digits = text$2.slice(1).replace(":", "");
5051
+ return sign * (Number(digits.slice(0, 2)) * 60 + Number(digits.slice(2, 4)));
5052
+ }
5053
+ function formatOffset(minutes) {
5054
+ const sign = minutes < 0 ? "-" : "+";
5055
+ const abs = Math.abs(minutes);
5056
+ return `${sign}${String(Math.floor(abs / 60)).padStart(2, "0")}:${String(abs % 60).padStart(2, "0")}`;
5057
+ }
5058
+ function isValidZone(name) {
5059
+ try {
5060
+ new Intl.DateTimeFormat("en-US", { timeZone: name });
5061
+ return true;
5062
+ } catch {
5063
+ return false;
5064
+ }
5065
+ }
5066
+ /**
5067
+ * The zone of the action: its own `time_zone`, else the offset its dates were
5068
+ * prepared with, else UTC (how the server reads a date without offset).
5069
+ */
5070
+ function actionZone(action) {
5071
+ const named = action.time_zone;
5072
+ if (typeof named === "string" && isValidZone(named)) return {
5073
+ kind: "iana",
5074
+ name: named
5075
+ };
5076
+ for (const field of ["start", "end"]) {
5077
+ const value = action[field];
5078
+ const minutes = typeof value === "string" ? parseOffsetMinutes(value) : null;
5079
+ if (minutes !== null) return {
5080
+ kind: "offset",
5081
+ minutes,
5082
+ label: `UTC${formatOffset(minutes)}`
5083
+ };
5084
+ }
5085
+ return {
5086
+ kind: "offset",
5087
+ minutes: 0,
5088
+ label: "UTC"
5089
+ };
5090
+ }
5091
+ function zoneLabel(zone) {
5092
+ return zone.kind === "iana" ? zone.name : zone.label;
5093
+ }
5094
+ const formatters = /* @__PURE__ */ new Map();
5095
+ /** Wall clock of an instant in `zone`, as if it were UTC (ms). */
5096
+ function wallClockMs(instant, name) {
5097
+ let formatter = formatters.get(name);
5098
+ if (!formatter) {
5099
+ formatter = new Intl.DateTimeFormat("en-US", {
5100
+ timeZone: name,
5101
+ hourCycle: "h23",
5102
+ year: "numeric",
5103
+ month: "2-digit",
5104
+ day: "2-digit",
5105
+ hour: "2-digit",
5106
+ minute: "2-digit",
5107
+ second: "2-digit"
5108
+ });
5109
+ formatters.set(name, formatter);
5110
+ }
5111
+ const parts = {};
5112
+ for (const part of formatter.formatToParts(new Date(instant))) if (part.type !== "literal") parts[part.type] = Number(part.value);
5113
+ return Date.UTC(parts.year, parts.month - 1, parts.day, parts.hour === 24 ? 0 : parts.hour, parts.minute, parts.second);
5114
+ }
5115
+ /** Offset of `name` at `instant`, in minutes east of UTC. */
5116
+ function offsetMinutesAt(instant, name) {
5117
+ return Math.round((wallClockMs(instant, name) - instant) / 6e4);
5118
+ }
5119
+ const LOCAL_INPUT = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/;
5120
+ function pad(value) {
5121
+ return String(value).padStart(2, "0");
5122
+ }
5123
+ function toInputValue(wallMs) {
5124
+ const date = new Date(wallMs);
5125
+ return `${date.getUTCFullYear()}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())}T${pad(date.getUTCHours())}:${pad(date.getUTCMinutes())}`;
5126
+ }
5127
+ /** `YYYY-MM-DDTHH:mm` (a `datetime-local` value) of an ISO date, in `zone`. */
5128
+ function isoToLocalInput(iso, zone) {
5129
+ const text$2 = iso.trim();
5130
+ if (!OFFSET_SUFFIX.test(text$2)) {
5131
+ const naive = LOCAL_INPUT.exec(text$2);
5132
+ return naive ? `${naive[1]}-${naive[2]}-${naive[3]}T${naive[4]}:${naive[5]}` : null;
5133
+ }
5134
+ const instant = Date.parse(text$2);
5135
+ if (Number.isNaN(instant)) return null;
5136
+ return toInputValue(zone.kind === "iana" ? wallClockMs(instant, zone.name) : instant + zone.minutes * 6e4);
5137
+ }
5138
+ /**
5139
+ * ISO 8601 with the UTC offset `zone` has at that wall clock time. A time that
5140
+ * happens twice (clocks go back) or never (clocks go forward) has no single
5141
+ * valid offset: it is rejected so the user picks another one.
5142
+ */
5143
+ function localInputToIso(local, zone) {
5144
+ const match = LOCAL_INPUT.exec(local.trim());
5145
+ if (!match) return { error: "invalid" };
5146
+ const [, year, month, day, hour, minute] = match;
5147
+ const wall = Date.UTC(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute));
5148
+ if (Number.isNaN(wall) || toInputValue(wall) !== local.trim().slice(0, 16)) return { error: "invalid" };
5149
+ const stamp = `${year}-${month}-${day}T${hour}:${minute}:00`;
5150
+ if (zone.kind === "offset") return { iso: `${stamp}${formatOffset(zone.minutes)}` };
5151
+ const candidates = /* @__PURE__ */ new Set();
5152
+ for (const probe of [wall - 864e5, wall + 864e5]) {
5153
+ const offset$1 = offsetMinutesAt(probe, zone.name);
5154
+ if (wallClockMs(wall - offset$1 * 6e4, zone.name) === wall) candidates.add(offset$1);
5155
+ }
5156
+ if (candidates.size !== 1) return { error: "ambiguous" };
5157
+ const [offset] = candidates;
5158
+ return { iso: `${stamp}${formatOffset(offset)}` };
5159
+ }
5160
+ const EMAIL = /^[^@\s<>,;]+@[^@\s<>,;]+\.[^@\s<>,;]+$/;
5161
+ function asString(value) {
5162
+ return typeof value === "string" ? value : "";
5163
+ }
5164
+ /** What each field shows when the form opens: the prepared values. */
5165
+ function initialDraft(pending) {
5166
+ const action = pending.action;
5167
+ const zone = actionZone(action);
5168
+ const draft = {};
5169
+ for (const field of editableFields(pending)) {
5170
+ const value = action[field];
5171
+ switch (FIELD_KINDS[field]) {
5172
+ case "addresses":
5173
+ draft[field] = Array.isArray(value) ? value.filter((item) => typeof item === "string").join(", ") : "";
5174
+ break;
5175
+ case "datetime":
5176
+ draft[field] = typeof value === "string" ? isoToLocalInput(value, zone) ?? "" : "";
5177
+ break;
5178
+ default: draft[field] = asString(value);
5179
+ }
5180
+ }
5181
+ return draft;
5182
+ }
5183
+ function splitAddresses(text$2) {
5184
+ return text$2.split(/[,;\n]/).map((address) => address.trim()).filter(Boolean);
5185
+ }
5186
+ /**
5187
+ * The patch for `draft` against the prepared values, or the field errors that
5188
+ * stop it. Unchanged fields are left out so the server keeps their exact value.
5189
+ */
5190
+ function buildPatch(pending, draft, initial = initialDraft(pending)) {
5191
+ const action = pending.action;
5192
+ const zone = actionZone(action);
5193
+ const zoneName = zoneLabel(zone);
5194
+ const patch = {};
5195
+ const errors = {};
5196
+ for (const field of editableFields(pending)) {
5197
+ const value = draft[field] ?? "";
5198
+ if (value === (initial[field] ?? "")) continue;
5199
+ switch (FIELD_KINDS[field]) {
5200
+ case "addresses": {
5201
+ const addresses = splitAddresses(value);
5202
+ if (addresses.some((address) => !EMAIL.test(address))) errors[field] = { key: "invalidAddress" };
5203
+ else if (field === "to" && addresses.length === 0) errors[field] = { key: "noRecipients" };
5204
+ else patch[field] = addresses;
5205
+ break;
5206
+ }
5207
+ case "datetime": {
5208
+ const converted = localInputToIso(value, zone);
5209
+ if (converted.error === "ambiguous") errors[field] = {
5210
+ key: "ambiguousTime",
5211
+ zone: zoneName
5212
+ };
5213
+ else if (converted.error) errors[field] = { key: "invalidDateTime" };
5214
+ else patch[field] = converted.iso;
5215
+ break;
5216
+ }
5217
+ case "text":
5218
+ if (value.trim() === "") if (field === "location") patch[field] = null;
5219
+ else errors[field] = { key: "required" };
5220
+ else patch[field] = value;
5221
+ break;
5222
+ default: patch[field] = value;
5223
+ }
5224
+ }
5225
+ const start = readInstant(patch.start, action.start);
5226
+ const end = readInstant(patch.end, action.end);
5227
+ if (!errors.end && !errors.start && (patch.start !== void 0 || patch.end !== void 0) && start !== null && end !== null && start >= end) errors.end = { key: "endBeforeStart" };
5228
+ return {
5229
+ patch,
5230
+ errors
5231
+ };
5232
+ }
5233
+ function readInstant(edited, original) {
5234
+ const value = typeof edited === "string" ? edited : original;
5235
+ if (typeof value !== "string") return null;
5236
+ const parsed = Date.parse(value);
5237
+ return Number.isNaN(parsed) ? null : parsed;
5238
+ }
5239
+
5240
+ //#endregion
5241
+ //#region src/components/tool-confirmation-edit-form.tsx
5242
+ const LABELS = {
5243
+ to: "to",
5244
+ cc: "cc",
5245
+ subject: "subject",
5246
+ body: "fieldBody",
5247
+ title: "title",
5248
+ start: "fieldStart",
5249
+ end: "fieldEnd",
5250
+ location: "location",
5251
+ attendees: "attendees"
5252
+ };
5253
+ const ERROR_COPY = {
5254
+ required: "errorRequired",
5255
+ noRecipients: "errorNoRecipients",
5256
+ invalidAddress: "errorInvalidAddress",
5257
+ invalidDateTime: "errorInvalidDateTime",
5258
+ ambiguousTime: "errorAmbiguousTime",
5259
+ endBeforeStart: "errorEndBeforeStart"
5260
+ };
5261
+ const INPUT_CLASS = "w-full rounded-md border border-border-strong bg-surface px-2 py-1.5 text-xs text-foreground disabled:opacity-50 aria-[invalid=true]:border-danger";
5262
+ /**
5263
+ * Inline form to change an action before confirming it. Only the fields the
5264
+ * server declared editable are shown. The draft lives in the parent, so it
5265
+ * survives validation errors and a busy thread.
5266
+ */
5267
+ function ToolConfirmationEditForm({ pending, draft, onChange, errors, serverErrors, disabled, copy }) {
5268
+ const baseId = useId();
5269
+ const fields = editableFields(pending);
5270
+ const zone = zoneLabel(actionZone(pending.action));
5271
+ return /* @__PURE__ */ jsx("div", {
5272
+ className: "space-y-2 border-t border-border bg-surface px-3 py-3",
5273
+ "data-confirmation-edit": pending.action_id,
5274
+ children: fields.map((field) => {
5275
+ const kind = FIELD_KINDS[field];
5276
+ const id = `${baseId}-${field}`;
5277
+ const errorId = `${id}-error`;
5278
+ const clientError = errors[field];
5279
+ const message = clientError ? fillCopy(copy[ERROR_COPY[clientError.key]], { zone: clientError.zone ?? zone }) : serverErrors[field];
5280
+ const common = {
5281
+ id,
5282
+ name: field,
5283
+ value: draft[field] ?? "",
5284
+ disabled,
5285
+ "aria-invalid": message ? true : void 0,
5286
+ "aria-describedby": message ? errorId : void 0,
5287
+ className: INPUT_CLASS
5288
+ };
5289
+ return /* @__PURE__ */ jsxs("div", {
5290
+ className: "space-y-1",
5291
+ children: [
5292
+ /* @__PURE__ */ jsx("label", {
5293
+ htmlFor: id,
5294
+ className: "block text-xs font-medium text-strong",
5295
+ children: copy[LABELS[field]]
5296
+ }),
5297
+ kind === "textarea" ? /* @__PURE__ */ jsx("textarea", {
5298
+ ...common,
5299
+ rows: 5,
5300
+ onChange: (event) => onChange(field, event.target.value)
5301
+ }) : kind === "datetime" ? /* @__PURE__ */ jsx("input", {
5302
+ ...common,
5303
+ type: "datetime-local",
5304
+ step: 60,
5305
+ onChange: (event) => onChange(field, event.target.value)
5306
+ }) : /* @__PURE__ */ jsx("input", {
5307
+ ...common,
5308
+ type: "text",
5309
+ autoComplete: "off",
5310
+ onChange: (event) => onChange(field, event.target.value)
5311
+ }),
5312
+ kind === "addresses" ? /* @__PURE__ */ jsx("p", {
5313
+ className: "text-xs text-muted",
5314
+ children: copy.addressesHint
5315
+ }) : null,
5316
+ kind === "datetime" ? /* @__PURE__ */ jsx("p", {
5317
+ className: "text-xs text-muted",
5318
+ children: fillCopy(copy.timeZoneNote, { zone })
5319
+ }) : null,
5320
+ message ? /* @__PURE__ */ jsx("p", {
5321
+ id: errorId,
5322
+ role: "alert",
5323
+ className: joinClasses("text-xs text-danger-strong"),
5324
+ children: message
5325
+ }) : null
5326
+ ]
5327
+ }, field);
5328
+ })
5329
+ });
5330
+ }
5331
+
4795
5332
  //#endregion
4796
5333
  //#region src/components/tool-confirmation-controls.tsx
4797
5334
  const MINUTE = 6e4;
@@ -4862,15 +5399,36 @@ function expiryText(state, serverOffsetMs, now, copy) {
4862
5399
  if (Number.isNaN(left) || left <= 0) return null;
4863
5400
  return left < MINUTE ? copy.expiresSoon : fillCopy(copy.expiresIn, { minutes: Math.floor(left / MINUTE) });
4864
5401
  }
5402
+ /** Label of the button that saves an edit and runs the action in one step. */
5403
+ function saveLabel(operation, copy) {
5404
+ return operation === "send" ? copy.saveAndSend : copy.saveAndConfirm;
5405
+ }
5406
+ /** Scrolls to the card of another version of the same action, if it is on screen. */
5407
+ function showAction(actionId) {
5408
+ if (typeof document === "undefined") return;
5409
+ for (const element of document.querySelectorAll("[data-confirmation-action]")) if (element.getAttribute("data-confirmation-action") === actionId) {
5410
+ element.scrollIntoView?.({
5411
+ block: "center",
5412
+ behavior: "smooth"
5413
+ });
5414
+ return;
5415
+ }
5416
+ }
4865
5417
  /**
4866
5418
  * Footer of a held action. Without `toolConfirmation` it keeps the text hint
4867
- * (reply "yes"); with it, buttons once the server state is known.
5419
+ * (reply "yes"); with it, buttons once the server state is known. When the
5420
+ * server lets the user edit the action, an inline form is offered and "Save
5421
+ * and send" confirms with the changes in a single step.
4868
5422
  */
4869
5423
  function PendingConfirmationFooter({ pending, toolConfirmation, copy }) {
4870
5424
  const state = useToolConfirmationState(pending, toolConfirmation);
4871
5425
  const now = useNow(state?.status === "pending");
4872
5426
  const [sending, setSending] = useState(null);
4873
5427
  const [failed, setFailed] = useState(false);
5428
+ const [editing, setEditing] = useState(false);
5429
+ const [draft, setDraft] = useState({});
5430
+ const [fieldErrors, setFieldErrors] = useState({});
5431
+ const [serverErrors, setServerErrors] = useState({});
4874
5432
  if (!toolConfirmation) return /* @__PURE__ */ jsx("p", {
4875
5433
  className: "border-t border-border bg-warning-subtle/60 px-3 py-2 text-xs text-strong",
4876
5434
  children: copy.confirmHint
@@ -4883,47 +5441,118 @@ function PendingConfirmationFooter({ pending, toolConfirmation, copy }) {
4883
5441
  if (state.status !== "pending") {
4884
5442
  const label = statusLabel(state.status, copy);
4885
5443
  return label ? /* @__PURE__ */ jsxs("p", {
4886
- className: "border-t border-divider bg-surface-muted px-3 py-2 text-xs text-strong",
5444
+ className: "flex flex-wrap items-center gap-2 border-t border-divider bg-surface-muted px-3 py-2 text-xs text-strong",
4887
5445
  "aria-live": "polite",
4888
- children: [label, state.status === "failed" && state.error ? `: ${state.error}` : null]
5446
+ children: [
5447
+ /* @__PURE__ */ jsxs("span", { children: [label, state.status === "failed" && state.error ? `: ${state.error}` : null] }),
5448
+ state.status === "superseded" && state.supersededBy ? /* @__PURE__ */ jsx("button", {
5449
+ type: "button",
5450
+ className: "underline underline-offset-2 hover:text-foreground",
5451
+ onClick: () => showAction(state.supersededBy),
5452
+ children: copy.seeNewerVersion
5453
+ }) : null,
5454
+ state.effectiveAction ? /* @__PURE__ */ jsx("span", {
5455
+ className: "rounded-full border border-border bg-surface px-2 py-0.5 text-muted",
5456
+ children: copy.editedLabel
5457
+ }) : null
5458
+ ]
4889
5459
  }) : null;
4890
5460
  }
4891
- const decide = async (decision) => {
4892
- setSending(decision);
5461
+ const decide = async (decisions) => {
4893
5462
  setFailed(false);
4894
5463
  try {
4895
- await toolConfirmation.decide([{
4896
- action_id: pending.action_id,
4897
- decision
4898
- }]);
4899
- } catch {
4900
- setFailed(true);
4901
- } finally {
4902
- setSending(null);
5464
+ await toolConfirmation.decide(decisions);
5465
+ } catch (error) {
5466
+ if (error instanceof ToolDecisionRejectedError && error.details.actionId === pending.action_id) setServerErrors(Object.fromEntries(error.details.errors.map(({ field, message }) => [field, message])));
5467
+ else setFailed(true);
4903
5468
  }
4904
5469
  };
5470
+ const send = async (decision) => {
5471
+ setSending(decision);
5472
+ await decide([{
5473
+ action_id: pending.action_id,
5474
+ decision
5475
+ }]);
5476
+ setSending(null);
5477
+ };
5478
+ const saveAndConfirm = async () => {
5479
+ const { patch, errors } = buildPatch(pending, draft);
5480
+ setFieldErrors(errors);
5481
+ setServerErrors({});
5482
+ if (Object.keys(errors).length > 0) return;
5483
+ setSending("confirm");
5484
+ await decide([{
5485
+ action_id: pending.action_id,
5486
+ decision: "confirm",
5487
+ ...Object.keys(patch).length > 0 ? { arguments: patch } : {}
5488
+ }]);
5489
+ setSending(null);
5490
+ };
5491
+ const startEditing = () => {
5492
+ setDraft(initialDraft(pending));
5493
+ setFieldErrors({});
5494
+ setServerErrors({});
5495
+ setFailed(false);
5496
+ setEditing(true);
5497
+ };
5498
+ const stopEditing = () => {
5499
+ setEditing(false);
5500
+ setFieldErrors({});
5501
+ setServerErrors({});
5502
+ };
4905
5503
  const disabled = Boolean(toolConfirmation.disabled) || sending !== null;
4906
5504
  const destructive = pending.operation === "delete";
5505
+ const canEdit = state.canConfirm && editableFields(pending).length > 0;
4907
5506
  const expiry = expiryText(state, toolConfirmation.states.serverOffsetMs, now, copy);
4908
5507
  const unavailable = state.error === "tool_unavailable";
4909
- return /* @__PURE__ */ jsxs("div", {
5508
+ const editStale = state.error === "invalid_edit";
5509
+ return /* @__PURE__ */ jsxs(Fragment, { children: [editing && canEdit ? /* @__PURE__ */ jsx(ToolConfirmationEditForm, {
5510
+ pending,
5511
+ draft,
5512
+ onChange: (field, value) => {
5513
+ setDraft((current) => ({
5514
+ ...current,
5515
+ [field]: value
5516
+ }));
5517
+ setFieldErrors(({ [field]: _removed,...rest }) => rest);
5518
+ setServerErrors(({ [field]: _removed,...rest }) => rest);
5519
+ },
5520
+ errors: fieldErrors,
5521
+ serverErrors,
5522
+ disabled,
5523
+ copy
5524
+ }) : null, /* @__PURE__ */ jsxs("div", {
4910
5525
  className: "flex flex-wrap items-center gap-2 border-t border-border bg-warning-subtle/60 px-3 py-2",
4911
5526
  "data-confirmation-actions": pending.action_id,
4912
5527
  children: [
4913
5528
  state.canConfirm ? /* @__PURE__ */ jsxs("button", {
4914
5529
  type: "button",
4915
5530
  disabled,
4916
- onClick: () => void decide("confirm"),
5531
+ onClick: () => void (editing && canEdit ? saveAndConfirm() : send("confirm")),
4917
5532
  className: joinClasses("inline-flex items-center rounded-md px-3 py-1.5 text-xs font-medium text-inverse-foreground disabled:opacity-50", destructive ? "bg-danger hover:bg-danger-strong" : "bg-inverse hover:bg-inverse-hover"),
4918
5533
  children: [sending === "confirm" ? /* @__PURE__ */ jsx(LoaderCircle, {
4919
5534
  className: "mr-2 size-3 animate-spin",
4920
5535
  "aria-hidden": "true"
4921
- }) : null, sending === "confirm" ? copy.confirming : verbFor(pending.operation, copy)]
5536
+ }) : null, sending === "confirm" ? copy.confirming : editing && canEdit ? saveLabel(pending.operation, copy) : verbFor(pending.operation, copy)]
5537
+ }) : null,
5538
+ canEdit && !editing ? /* @__PURE__ */ jsx("button", {
5539
+ type: "button",
5540
+ disabled,
5541
+ onClick: startEditing,
5542
+ className: "inline-flex items-center rounded-md border border-border-strong bg-surface px-3 py-1.5 text-xs font-medium text-strong hover:bg-surface-muted disabled:opacity-50",
5543
+ children: copy.edit
5544
+ }) : null,
5545
+ editing && canEdit ? /* @__PURE__ */ jsx("button", {
5546
+ type: "button",
5547
+ disabled,
5548
+ onClick: stopEditing,
5549
+ className: "inline-flex items-center rounded-md border border-border-strong bg-surface px-3 py-1.5 text-xs font-medium text-strong hover:bg-surface-muted disabled:opacity-50",
5550
+ children: copy.discardEdit
4922
5551
  }) : null,
4923
5552
  state.canReject ? /* @__PURE__ */ jsxs("button", {
4924
5553
  type: "button",
4925
5554
  disabled,
4926
- onClick: () => void decide("reject"),
5555
+ onClick: () => void send("reject"),
4927
5556
  className: "inline-flex items-center rounded-md border border-border-strong bg-surface px-3 py-1.5 text-xs font-medium text-strong hover:bg-surface-muted disabled:opacity-50",
4928
5557
  children: [sending === "reject" ? /* @__PURE__ */ jsx(LoaderCircle, {
4929
5558
  className: "mr-2 size-3 animate-spin",
@@ -4933,10 +5562,10 @@ function PendingConfirmationFooter({ pending, toolConfirmation, copy }) {
4933
5562
  /* @__PURE__ */ jsx("span", {
4934
5563
  className: "ml-auto text-xs text-secondary",
4935
5564
  "aria-live": "polite",
4936
- children: failed ? copy.decisionError : unavailable ? copy.toolUnavailable : expiry
5565
+ children: failed ? copy.decisionError : unavailable ? copy.toolUnavailable : editStale ? copy.editNoLongerApplies : expiry
4937
5566
  })
4938
5567
  ]
4939
- });
5568
+ })] });
4940
5569
  }
4941
5570
 
4942
5571
  //#endregion
@@ -5543,20 +6172,28 @@ function headerCount(view, copy) {
5543
6172
  return null;
5544
6173
  }
5545
6174
  function ToolResultPersonalConnectorCard({ part, locale, className, toolConfirmation }) {
5546
- const view = getView(part);
5547
- const pending = view?.kind === "pending-mail" || view?.kind === "pending-event" ? view.pending : null;
6175
+ const prepared = getView(part);
6176
+ const pending = prepared?.kind === "pending-mail" || prepared?.kind === "pending-event" ? prepared.pending : null;
5548
6177
  const confirmationState = useToolConfirmationState(pending, toolConfirmation);
5549
- if (!view) return null;
6178
+ if (!prepared) return null;
6179
+ const view = (prepared.kind === "pending-mail" || prepared.kind === "pending-event") && confirmationState?.effectiveAction ? {
6180
+ ...prepared,
6181
+ pending: {
6182
+ ...prepared.pending,
6183
+ action: confirmationState.effectiveAction
6184
+ }
6185
+ } : prepared;
5550
6186
  const copy = getPersonalConnectorCopy(locale);
5551
6187
  const connector = getConnector(part);
5552
6188
  const Icon = isCalendar(connector) ? CalendarDays : Mail;
5553
6189
  const total = headerCount(view, copy);
5554
6190
  const isPending = view.kind === "pending-mail" || view.kind === "pending-event";
5555
6191
  return /* @__PURE__ */ jsxs("section", {
5556
- className: joinClasses("plai-tool-result-personal-connector-card overflow-hidden rounded-lg border border-border bg-surface text-foreground", className),
6192
+ className: joinClasses("plai-tool-result-personal-connector-card overflow-hidden rounded-lg border border-border bg-surface text-foreground", confirmationState?.status === "superseded" ? "opacity-60" : void 0, className),
5557
6193
  "data-tool-call-id": part.id,
5558
6194
  "data-tool-call-state": part.state,
5559
6195
  "data-connector-action": view.kind,
6196
+ "data-confirmation-action": pending?.action_id,
5560
6197
  children: [
5561
6198
  /* @__PURE__ */ jsxs("header", {
5562
6199
  className: "flex items-center gap-2 border-b border-border px-3 py-2 text-xs text-secondary",
@@ -6071,6 +6708,11 @@ function getDatasourceResources$1(part) {
6071
6708
  const resources = part.metadata.resources;
6072
6709
  return Array.isArray(resources) ? resources.filter(isDatasourceResource) : [];
6073
6710
  }
6711
+ function getDatasourceResourceLinks(part) {
6712
+ if (part.toolType !== "datasource" || !part.metadata) return [];
6713
+ const links = part.metadata.resource_links;
6714
+ return Array.isArray(links) ? links.filter(isResourceLink) : [];
6715
+ }
6074
6716
  function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAgentThread, getResourceDownloadUrl, memoryProposal, toolConfirmation }) {
6075
6717
  const copy = getUiCopy(locale);
6076
6718
  if (part.toolType === "memory_proposal") {
@@ -6107,6 +6749,7 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
6107
6749
  });
6108
6750
  const officeMediaFiles = getOfficeDocumentMediaFiles(part);
6109
6751
  const datasourceResources = getDatasourceResources$1(part);
6752
+ const datasourceResourceLinks = getDatasourceResourceLinks(part);
6110
6753
  if (part.toolType === "email_send") return /* @__PURE__ */ jsx(ToolResultEmailSendCard, {
6111
6754
  part,
6112
6755
  locale,
@@ -6161,6 +6804,7 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
6161
6804
  });
6162
6805
  if (datasourceResources.length > 0) return /* @__PURE__ */ jsx(DatasourceToolResources, {
6163
6806
  resources: datasourceResources,
6807
+ resourceLinks: datasourceResourceLinks,
6164
6808
  locale,
6165
6809
  className,
6166
6810
  getResourceDownloadUrl