@plaisolutions/react 0.11.0 → 0.12.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/README.md +57 -0
- package/dist/components/index.d.ts +29 -3
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +374 -8
- package/dist/components/index.js.map +1 -1
- package/dist/index.d.ts +32 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +377 -9
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -2
package/dist/components/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
import { Bot, Brain, Check, CheckCircle2, ChevronDown, CircleX, Copy, Database, File, FileText, Globe, LoaderCircle, MessageSquare, Minus, Plug, Plus, RotateCcw, ThumbsDown, ThumbsUp, Workflow, XCircle } from "lucide-react";
|
|
3
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { HttpStatusError } from "@plaisolutions/client";
|
|
4
5
|
|
|
5
6
|
//#region src/components/datasource-tool-result-card.tsx
|
|
6
7
|
function DatasourceIcon() {
|
|
@@ -2355,6 +2356,7 @@ const TOOL_USE_ACTIONS = {
|
|
|
2355
2356
|
external_datasource: "query",
|
|
2356
2357
|
firecrawl_search: "web",
|
|
2357
2358
|
http_request: "request",
|
|
2359
|
+
memory_proposal: "tool",
|
|
2358
2360
|
mcp_tool: "request",
|
|
2359
2361
|
office_documents: "documents",
|
|
2360
2362
|
perplexity: "web",
|
|
@@ -2493,6 +2495,357 @@ function ToolUseIndicator({ part, locale, className,...props }) {
|
|
|
2493
2495
|
});
|
|
2494
2496
|
}
|
|
2495
2497
|
|
|
2498
|
+
//#endregion
|
|
2499
|
+
//#region src/components/memory-proposal-card.tsx
|
|
2500
|
+
const COPY = {
|
|
2501
|
+
en: {
|
|
2502
|
+
title: "Memory proposal",
|
|
2503
|
+
user: "Personal memory",
|
|
2504
|
+
project: "Project learning",
|
|
2505
|
+
create: "Create",
|
|
2506
|
+
update: "Update",
|
|
2507
|
+
delete: "Delete",
|
|
2508
|
+
previous: "Previous content",
|
|
2509
|
+
proposed: "Proposed content",
|
|
2510
|
+
accept: "Accept",
|
|
2511
|
+
reject: "Reject",
|
|
2512
|
+
review: "Sent for admin review",
|
|
2513
|
+
unavailable: "This proposal cannot be resolved here",
|
|
2514
|
+
accepted: "Accepted",
|
|
2515
|
+
rejected: "Rejected",
|
|
2516
|
+
expired: "Expired",
|
|
2517
|
+
conflicted: "Could not be applied because the memory changed",
|
|
2518
|
+
conflictError: "The memory changed. The latest status has been loaded.",
|
|
2519
|
+
expiredError: "This proposal is no longer available.",
|
|
2520
|
+
permissionError: "You no longer have permission to resolve this proposal.",
|
|
2521
|
+
genericError: "The proposal could not be resolved."
|
|
2522
|
+
},
|
|
2523
|
+
es: {
|
|
2524
|
+
title: "Propuesta de memoria",
|
|
2525
|
+
user: "Memoria personal",
|
|
2526
|
+
project: "Aprendizaje del proyecto",
|
|
2527
|
+
create: "Crear",
|
|
2528
|
+
update: "Actualizar",
|
|
2529
|
+
delete: "Eliminar",
|
|
2530
|
+
previous: "Contenido anterior",
|
|
2531
|
+
proposed: "Contenido propuesto",
|
|
2532
|
+
accept: "Aceptar",
|
|
2533
|
+
reject: "Rechazar",
|
|
2534
|
+
review: "Enviado para revisión de un administrador",
|
|
2535
|
+
unavailable: "Esta propuesta no se puede resolver aquí",
|
|
2536
|
+
accepted: "Aceptada",
|
|
2537
|
+
rejected: "Rechazada",
|
|
2538
|
+
expired: "Caducada",
|
|
2539
|
+
conflicted: "No se pudo aplicar porque la memoria cambió",
|
|
2540
|
+
conflictError: "La memoria cambió. Se ha cargado el estado más reciente.",
|
|
2541
|
+
expiredError: "Esta propuesta ya no está disponible.",
|
|
2542
|
+
permissionError: "Ya no tienes permiso para resolver esta propuesta.",
|
|
2543
|
+
genericError: "No se pudo resolver la propuesta."
|
|
2544
|
+
},
|
|
2545
|
+
ca: {
|
|
2546
|
+
title: "Proposta de memòria",
|
|
2547
|
+
user: "Memòria personal",
|
|
2548
|
+
project: "Aprenentatge del projecte",
|
|
2549
|
+
create: "Crear",
|
|
2550
|
+
update: "Actualitzar",
|
|
2551
|
+
delete: "Eliminar",
|
|
2552
|
+
previous: "Contingut anterior",
|
|
2553
|
+
proposed: "Contingut proposat",
|
|
2554
|
+
accept: "Acceptar",
|
|
2555
|
+
reject: "Rebutjar",
|
|
2556
|
+
review: "Enviat per a revisió d'un administrador",
|
|
2557
|
+
unavailable: "Aquesta proposta no es pot resoldre aquí",
|
|
2558
|
+
accepted: "Acceptada",
|
|
2559
|
+
rejected: "Rebutjada",
|
|
2560
|
+
expired: "Caducada",
|
|
2561
|
+
conflicted: "No s'ha pogut aplicar perquè la memòria ha canviat",
|
|
2562
|
+
conflictError: "La memòria ha canviat. S'ha carregat l'estat més recent.",
|
|
2563
|
+
expiredError: "Aquesta proposta ja no està disponible.",
|
|
2564
|
+
permissionError: "Ja no tens permís per resoldre aquesta proposta.",
|
|
2565
|
+
genericError: "No s'ha pogut resoldre la proposta."
|
|
2566
|
+
},
|
|
2567
|
+
da: {
|
|
2568
|
+
title: "Hukommelsesforslag",
|
|
2569
|
+
user: "Personlig hukommelse",
|
|
2570
|
+
project: "Projektlæring",
|
|
2571
|
+
create: "Opret",
|
|
2572
|
+
update: "Opdater",
|
|
2573
|
+
delete: "Slet",
|
|
2574
|
+
previous: "Tidligere indhold",
|
|
2575
|
+
proposed: "Foreslået indhold",
|
|
2576
|
+
accept: "Acceptér",
|
|
2577
|
+
reject: "Afvis",
|
|
2578
|
+
review: "Sendt til administratorgennemgang",
|
|
2579
|
+
unavailable: "Forslaget kan ikke behandles her",
|
|
2580
|
+
accepted: "Accepteret",
|
|
2581
|
+
rejected: "Afvist",
|
|
2582
|
+
expired: "Udløbet",
|
|
2583
|
+
conflicted: "Kunne ikke anvendes, fordi hukommelsen blev ændret",
|
|
2584
|
+
conflictError: "Hukommelsen blev ændret. Den seneste status er indlæst.",
|
|
2585
|
+
expiredError: "Forslaget er ikke længere tilgængeligt.",
|
|
2586
|
+
permissionError: "Du har ikke længere tilladelse til at behandle forslaget.",
|
|
2587
|
+
genericError: "Forslaget kunne ikke behandles."
|
|
2588
|
+
},
|
|
2589
|
+
de: {
|
|
2590
|
+
title: "Speichervorschlag",
|
|
2591
|
+
user: "Persönliche Erinnerung",
|
|
2592
|
+
project: "Projektwissen",
|
|
2593
|
+
create: "Erstellen",
|
|
2594
|
+
update: "Aktualisieren",
|
|
2595
|
+
delete: "Löschen",
|
|
2596
|
+
previous: "Vorheriger Inhalt",
|
|
2597
|
+
proposed: "Vorgeschlagener Inhalt",
|
|
2598
|
+
accept: "Akzeptieren",
|
|
2599
|
+
reject: "Ablehnen",
|
|
2600
|
+
review: "Zur Administratorprüfung gesendet",
|
|
2601
|
+
unavailable: "Dieser Vorschlag kann hier nicht bearbeitet werden",
|
|
2602
|
+
accepted: "Akzeptiert",
|
|
2603
|
+
rejected: "Abgelehnt",
|
|
2604
|
+
expired: "Abgelaufen",
|
|
2605
|
+
conflicted: "Nicht angewendet, da sich die Erinnerung geändert hat",
|
|
2606
|
+
conflictError: "Die Erinnerung hat sich geändert. Der aktuelle Status wurde geladen.",
|
|
2607
|
+
expiredError: "Dieser Vorschlag ist nicht mehr verfügbar.",
|
|
2608
|
+
permissionError: "Sie dürfen diesen Vorschlag nicht mehr bearbeiten.",
|
|
2609
|
+
genericError: "Der Vorschlag konnte nicht bearbeitet werden."
|
|
2610
|
+
},
|
|
2611
|
+
fr: {
|
|
2612
|
+
title: "Proposition de mémoire",
|
|
2613
|
+
user: "Mémoire personnelle",
|
|
2614
|
+
project: "Apprentissage du projet",
|
|
2615
|
+
create: "Créer",
|
|
2616
|
+
update: "Modifier",
|
|
2617
|
+
delete: "Supprimer",
|
|
2618
|
+
previous: "Contenu précédent",
|
|
2619
|
+
proposed: "Contenu proposé",
|
|
2620
|
+
accept: "Accepter",
|
|
2621
|
+
reject: "Refuser",
|
|
2622
|
+
review: "Envoyé à un administrateur pour examen",
|
|
2623
|
+
unavailable: "Cette proposition ne peut pas être traitée ici",
|
|
2624
|
+
accepted: "Acceptée",
|
|
2625
|
+
rejected: "Refusée",
|
|
2626
|
+
expired: "Expirée",
|
|
2627
|
+
conflicted: "Impossible à appliquer car la mémoire a changé",
|
|
2628
|
+
conflictError: "La mémoire a changé. Le dernier état a été chargé.",
|
|
2629
|
+
expiredError: "Cette proposition n'est plus disponible.",
|
|
2630
|
+
permissionError: "Vous n'avez plus l'autorisation de traiter cette proposition.",
|
|
2631
|
+
genericError: "La proposition n'a pas pu être traitée."
|
|
2632
|
+
},
|
|
2633
|
+
it: {
|
|
2634
|
+
title: "Proposta di memoria",
|
|
2635
|
+
user: "Memoria personale",
|
|
2636
|
+
project: "Apprendimento del progetto",
|
|
2637
|
+
create: "Crea",
|
|
2638
|
+
update: "Aggiorna",
|
|
2639
|
+
delete: "Elimina",
|
|
2640
|
+
previous: "Contenuto precedente",
|
|
2641
|
+
proposed: "Contenuto proposto",
|
|
2642
|
+
accept: "Accetta",
|
|
2643
|
+
reject: "Rifiuta",
|
|
2644
|
+
review: "Inviata alla revisione di un amministratore",
|
|
2645
|
+
unavailable: "Questa proposta non può essere gestita qui",
|
|
2646
|
+
accepted: "Accettata",
|
|
2647
|
+
rejected: "Rifiutata",
|
|
2648
|
+
expired: "Scaduta",
|
|
2649
|
+
conflicted: "Non applicata perché la memoria è cambiata",
|
|
2650
|
+
conflictError: "La memoria è cambiata. È stato caricato lo stato più recente.",
|
|
2651
|
+
expiredError: "Questa proposta non è più disponibile.",
|
|
2652
|
+
permissionError: "Non hai più il permesso di gestire questa proposta.",
|
|
2653
|
+
genericError: "Impossibile gestire la proposta."
|
|
2654
|
+
},
|
|
2655
|
+
no: {
|
|
2656
|
+
title: "Minneforslag",
|
|
2657
|
+
user: "Personlig minne",
|
|
2658
|
+
project: "Prosjektlæring",
|
|
2659
|
+
create: "Opprett",
|
|
2660
|
+
update: "Oppdater",
|
|
2661
|
+
delete: "Slett",
|
|
2662
|
+
previous: "Tidligere innhold",
|
|
2663
|
+
proposed: "Foreslått innhold",
|
|
2664
|
+
accept: "Godta",
|
|
2665
|
+
reject: "Avvis",
|
|
2666
|
+
review: "Sendt til administratorgjennomgang",
|
|
2667
|
+
unavailable: "Forslaget kan ikke behandles her",
|
|
2668
|
+
accepted: "Godtatt",
|
|
2669
|
+
rejected: "Avvist",
|
|
2670
|
+
expired: "Utløpt",
|
|
2671
|
+
conflicted: "Kunne ikke brukes fordi minnet ble endret",
|
|
2672
|
+
conflictError: "Minnet ble endret. Den nyeste statusen er lastet inn.",
|
|
2673
|
+
expiredError: "Forslaget er ikke lenger tilgjengelig.",
|
|
2674
|
+
permissionError: "Du har ikke lenger tillatelse til å behandle forslaget.",
|
|
2675
|
+
genericError: "Forslaget kunne ikke behandles."
|
|
2676
|
+
},
|
|
2677
|
+
pt: {
|
|
2678
|
+
title: "Proposta de memória",
|
|
2679
|
+
user: "Memória pessoal",
|
|
2680
|
+
project: "Aprendizagem do projeto",
|
|
2681
|
+
create: "Criar",
|
|
2682
|
+
update: "Atualizar",
|
|
2683
|
+
delete: "Eliminar",
|
|
2684
|
+
previous: "Conteúdo anterior",
|
|
2685
|
+
proposed: "Conteúdo proposto",
|
|
2686
|
+
accept: "Aceitar",
|
|
2687
|
+
reject: "Rejeitar",
|
|
2688
|
+
review: "Enviado para revisão de um administrador",
|
|
2689
|
+
unavailable: "Esta proposta não pode ser resolvida aqui",
|
|
2690
|
+
accepted: "Aceite",
|
|
2691
|
+
rejected: "Rejeitada",
|
|
2692
|
+
expired: "Expirada",
|
|
2693
|
+
conflicted: "Não aplicada porque a memória foi alterada",
|
|
2694
|
+
conflictError: "A memória foi alterada. O estado mais recente foi carregado.",
|
|
2695
|
+
expiredError: "Esta proposta já não está disponível.",
|
|
2696
|
+
permissionError: "Já não tem permissão para resolver esta proposta.",
|
|
2697
|
+
genericError: "Não foi possível resolver a proposta."
|
|
2698
|
+
},
|
|
2699
|
+
sv: {
|
|
2700
|
+
title: "Minnesförslag",
|
|
2701
|
+
user: "Personligt minne",
|
|
2702
|
+
project: "Projektlärdom",
|
|
2703
|
+
create: "Skapa",
|
|
2704
|
+
update: "Uppdatera",
|
|
2705
|
+
delete: "Ta bort",
|
|
2706
|
+
previous: "Tidigare innehåll",
|
|
2707
|
+
proposed: "Föreslaget innehåll",
|
|
2708
|
+
accept: "Godkänn",
|
|
2709
|
+
reject: "Avvisa",
|
|
2710
|
+
review: "Skickat för administratörsgranskning",
|
|
2711
|
+
unavailable: "Förslaget kan inte hanteras här",
|
|
2712
|
+
accepted: "Godkänt",
|
|
2713
|
+
rejected: "Avvisat",
|
|
2714
|
+
expired: "Utgånget",
|
|
2715
|
+
conflicted: "Kunde inte tillämpas eftersom minnet ändrades",
|
|
2716
|
+
conflictError: "Minnet ändrades. Den senaste statusen har lästs in.",
|
|
2717
|
+
expiredError: "Förslaget är inte längre tillgängligt.",
|
|
2718
|
+
permissionError: "Du har inte längre behörighet att hantera förslaget.",
|
|
2719
|
+
genericError: "Förslaget kunde inte hanteras."
|
|
2720
|
+
}
|
|
2721
|
+
};
|
|
2722
|
+
const REDACTED = "[redacted]";
|
|
2723
|
+
function MemoryProposalCard({ proposal: initial, actions, activeAgentId, locale, className }) {
|
|
2724
|
+
const copy = COPY[getSupportedToolLocale(locale)];
|
|
2725
|
+
const [proposal, setProposal] = useState(initial);
|
|
2726
|
+
const [resolving, setResolving] = useState(false);
|
|
2727
|
+
const [error, setError] = useState(null);
|
|
2728
|
+
useEffect(() => setProposal((current) => mergeProposal(current, initial)), [initial]);
|
|
2729
|
+
async function resolve(accept) {
|
|
2730
|
+
if (resolving) return;
|
|
2731
|
+
setResolving(true);
|
|
2732
|
+
setError(null);
|
|
2733
|
+
try {
|
|
2734
|
+
const next = accept ? await actions.acceptMemoryProposal({ proposalId: proposal.id }) : await actions.rejectMemoryProposal({ proposalId: proposal.id });
|
|
2735
|
+
setProposal((current) => mergeProposal(current, next));
|
|
2736
|
+
} catch (cause) {
|
|
2737
|
+
const status = cause instanceof HttpStatusError ? cause.status : 0;
|
|
2738
|
+
setError(status === 409 ? copy.conflictError : status === 410 ? copy.expiredError : status === 401 || status === 403 ? copy.permissionError : copy.genericError);
|
|
2739
|
+
try {
|
|
2740
|
+
const latest = await actions.getMemoryProposal({ proposalId: proposal.id });
|
|
2741
|
+
setProposal((current) => mergeProposal(current, latest));
|
|
2742
|
+
} catch {}
|
|
2743
|
+
} finally {
|
|
2744
|
+
setResolving(false);
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2747
|
+
const canResolve = proposal.status === "PENDING" && proposal.can_resolve === true && proposal.agent_id === activeAgentId;
|
|
2748
|
+
const statusCopy = proposal.status === "ACCEPTED" ? copy.accepted : proposal.status === "REJECTED" ? copy.rejected : proposal.status === "EXPIRED" ? copy.expired : proposal.status === "CONFLICTED" ? copy.conflicted : null;
|
|
2749
|
+
const operation = proposal.operation === "CREATE" ? copy.create : proposal.operation === "UPDATE" ? copy.update : copy.delete;
|
|
2750
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
2751
|
+
className: joinClasses("space-y-3 rounded-lg border border-emerald-200 bg-emerald-50/30 p-4 text-left", className),
|
|
2752
|
+
"data-memory-proposal-id": proposal.id,
|
|
2753
|
+
children: [
|
|
2754
|
+
/* @__PURE__ */ jsxs("header", {
|
|
2755
|
+
className: "space-y-2",
|
|
2756
|
+
children: [/* @__PURE__ */ jsxs("h4", {
|
|
2757
|
+
className: "flex items-center gap-2 text-sm font-semibold text-slate-900",
|
|
2758
|
+
children: [/* @__PURE__ */ jsx(Brain, { className: "size-4" }), copy.title]
|
|
2759
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
2760
|
+
className: "flex flex-wrap gap-2 text-xs",
|
|
2761
|
+
children: [
|
|
2762
|
+
/* @__PURE__ */ jsx("span", {
|
|
2763
|
+
className: "rounded-full border border-slate-300 bg-white px-2 py-0.5",
|
|
2764
|
+
children: proposal.scope === "USER" ? copy.user : copy.project
|
|
2765
|
+
}),
|
|
2766
|
+
/* @__PURE__ */ jsx("span", {
|
|
2767
|
+
className: "rounded-full bg-slate-100 px-2 py-0.5",
|
|
2768
|
+
children: operation
|
|
2769
|
+
}),
|
|
2770
|
+
/* @__PURE__ */ jsx("span", {
|
|
2771
|
+
className: "rounded-full bg-slate-100 px-2 py-0.5",
|
|
2772
|
+
children: formatCategory(proposal.category)
|
|
2773
|
+
})
|
|
2774
|
+
]
|
|
2775
|
+
})]
|
|
2776
|
+
}),
|
|
2777
|
+
proposal.previous_content && proposal.previous_content !== REDACTED ? /* @__PURE__ */ jsxs("div", {
|
|
2778
|
+
className: "rounded-md bg-slate-100 p-3 text-sm",
|
|
2779
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2780
|
+
className: "mb-1 block text-xs font-medium text-slate-500",
|
|
2781
|
+
children: copy.previous
|
|
2782
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
2783
|
+
className: "whitespace-pre-wrap break-words",
|
|
2784
|
+
children: proposal.previous_content
|
|
2785
|
+
})]
|
|
2786
|
+
}) : null,
|
|
2787
|
+
proposal.content && proposal.content !== REDACTED ? /* @__PURE__ */ jsxs("div", {
|
|
2788
|
+
className: "text-sm",
|
|
2789
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2790
|
+
className: "mb-1 block text-xs font-medium text-slate-500",
|
|
2791
|
+
children: copy.proposed
|
|
2792
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
2793
|
+
className: "whitespace-pre-wrap break-words",
|
|
2794
|
+
children: proposal.content
|
|
2795
|
+
})]
|
|
2796
|
+
}) : null,
|
|
2797
|
+
canResolve ? /* @__PURE__ */ jsxs("div", {
|
|
2798
|
+
className: "flex gap-2",
|
|
2799
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
2800
|
+
type: "button",
|
|
2801
|
+
disabled: resolving,
|
|
2802
|
+
onClick: () => void resolve(true),
|
|
2803
|
+
className: "inline-flex items-center rounded-md bg-slate-900 px-3 py-1.5 text-xs font-medium text-white disabled:opacity-50",
|
|
2804
|
+
children: [resolving ? /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 size-3 animate-spin" }) : null, copy.accept]
|
|
2805
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
2806
|
+
type: "button",
|
|
2807
|
+
disabled: resolving,
|
|
2808
|
+
onClick: () => void resolve(false),
|
|
2809
|
+
className: "rounded-md border border-slate-300 bg-white px-3 py-1.5 text-xs font-medium disabled:opacity-50",
|
|
2810
|
+
children: copy.reject
|
|
2811
|
+
})]
|
|
2812
|
+
}) : null,
|
|
2813
|
+
proposal.status === "PENDING" && !canResolve ? /* @__PURE__ */ jsx("p", {
|
|
2814
|
+
className: "text-xs font-medium text-slate-500",
|
|
2815
|
+
children: proposal.scope === "PROJECT" ? copy.review : copy.unavailable
|
|
2816
|
+
}) : null,
|
|
2817
|
+
proposal.status === "ACCEPTED" && statusCopy ? /* @__PURE__ */ jsxs("span", {
|
|
2818
|
+
className: "inline-flex items-center gap-1.5 rounded-full border bg-white px-3 py-1 text-xs font-medium text-slate-900 shadow-sm",
|
|
2819
|
+
children: [statusCopy, /* @__PURE__ */ jsx(Check, {
|
|
2820
|
+
className: "size-3.5 stroke-[2.5] text-emerald-600",
|
|
2821
|
+
"aria-hidden": "true"
|
|
2822
|
+
})]
|
|
2823
|
+
}) : null,
|
|
2824
|
+
statusCopy && proposal.status !== "ACCEPTED" ? /* @__PURE__ */ jsx("p", {
|
|
2825
|
+
className: "text-xs font-medium text-slate-500",
|
|
2826
|
+
children: statusCopy
|
|
2827
|
+
}) : null,
|
|
2828
|
+
error ? /* @__PURE__ */ jsx("p", {
|
|
2829
|
+
className: "text-xs text-red-600",
|
|
2830
|
+
children: error
|
|
2831
|
+
}) : null
|
|
2832
|
+
]
|
|
2833
|
+
});
|
|
2834
|
+
}
|
|
2835
|
+
function mergeProposal(current, incoming) {
|
|
2836
|
+
if (current.id !== incoming.id) return incoming;
|
|
2837
|
+
return {
|
|
2838
|
+
...incoming,
|
|
2839
|
+
content: incoming.content === REDACTED ? current.content : incoming.content,
|
|
2840
|
+
previous_content: incoming.previous_content === REDACTED ? current.previous_content : incoming.previous_content,
|
|
2841
|
+
rationale: incoming.rationale === REDACTED ? current.rationale : incoming.rationale
|
|
2842
|
+
};
|
|
2843
|
+
}
|
|
2844
|
+
function formatCategory(category) {
|
|
2845
|
+
const value = category.replaceAll("_", " ").toLowerCase();
|
|
2846
|
+
return `${value.charAt(0).toUpperCase()}${value.slice(1)}`;
|
|
2847
|
+
}
|
|
2848
|
+
|
|
2496
2849
|
//#endregion
|
|
2497
2850
|
//#region src/components/tool-result-card.tsx
|
|
2498
2851
|
function formatJson(value) {
|
|
@@ -2510,7 +2863,18 @@ function getDatasourceResources$1(part) {
|
|
|
2510
2863
|
const resources = part.metadata.resources;
|
|
2511
2864
|
return Array.isArray(resources) ? resources.filter(isDatasourceResource) : [];
|
|
2512
2865
|
}
|
|
2513
|
-
function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAgentThread, getResourceDownloadUrl }) {
|
|
2866
|
+
function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAgentThread, getResourceDownloadUrl, memoryProposal }) {
|
|
2867
|
+
if (part.toolType === "memory_proposal") {
|
|
2868
|
+
const proposal = part.metadata?.proposal;
|
|
2869
|
+
if (!memoryProposal || !proposal || typeof proposal !== "object") return null;
|
|
2870
|
+
return /* @__PURE__ */ jsx(MemoryProposalCard, {
|
|
2871
|
+
proposal,
|
|
2872
|
+
actions: memoryProposal.actions,
|
|
2873
|
+
activeAgentId: memoryProposal.activeAgentId,
|
|
2874
|
+
locale,
|
|
2875
|
+
className
|
|
2876
|
+
});
|
|
2877
|
+
}
|
|
2514
2878
|
if (part.state === "pending") return /* @__PURE__ */ jsx(ToolUseIndicator, {
|
|
2515
2879
|
part,
|
|
2516
2880
|
locale,
|
|
@@ -2772,7 +3136,7 @@ function getMessageTextClassName(role) {
|
|
|
2772
3136
|
function getMessageTextAlignmentClassName(role) {
|
|
2773
3137
|
return role === "user" ? "text-right" : "text-left";
|
|
2774
3138
|
}
|
|
2775
|
-
function renderPart(part, index, message, isStreaming, onOpenAgentThread, getResourceDownloadUrl, locale, renderText, renderToolCall, renderThinking, thinkingLabel, completedThinkingLabel, textClassName) {
|
|
3139
|
+
function renderPart(part, index, message, isStreaming, onOpenAgentThread, getResourceDownloadUrl, locale, memoryProposal, renderText, renderToolCall, renderThinking, thinkingLabel, completedThinkingLabel, textClassName) {
|
|
2776
3140
|
if (part.type === "text") {
|
|
2777
3141
|
if (renderText) return /* @__PURE__ */ jsx("div", { children: renderText(part, {
|
|
2778
3142
|
message,
|
|
@@ -2829,7 +3193,8 @@ function renderPart(part, index, message, isStreaming, onOpenAgentThread, getRes
|
|
|
2829
3193
|
part,
|
|
2830
3194
|
locale,
|
|
2831
3195
|
onOpenAgentThread,
|
|
2832
|
-
getResourceDownloadUrl
|
|
3196
|
+
getResourceDownloadUrl,
|
|
3197
|
+
memoryProposal
|
|
2833
3198
|
}, `tool-${part.id}-${index}`);
|
|
2834
3199
|
}
|
|
2835
3200
|
if (part.type === "thinking") {
|
|
@@ -2885,7 +3250,7 @@ function aggregateSourceToolParts(parts, position) {
|
|
|
2885
3250
|
...remainingParts.slice(insertionIndex)
|
|
2886
3251
|
];
|
|
2887
3252
|
}
|
|
2888
|
-
function MessageParts({ message, collapseThreshold = DEFAULT_COLLAPSE_THRESHOLD, sourceToolResultsLayout = "aggregated", sourceToolResultsPosition, maxVisibleSourceCards = 3, datasourceToolResultsPosition, onOpenAgentThread, getResourceDownloadUrl, locale, renderText, renderToolCall, renderThinking, isStreaming = false, thinkingLabel, completedThinkingLabel, readMoreLabel = "Read more", readLessLabel = "Read less", className,...props }) {
|
|
3253
|
+
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 = "Read more", readLessLabel = "Read less", className,...props }) {
|
|
2889
3254
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
2890
3255
|
const textContent = useMemo(() => message.parts.filter((part) => part.type === "text").map((part) => part.text).join("\n"), [message.parts]);
|
|
2891
3256
|
const canCollapse = message.role === "user" && message.parts.every((part) => part.type === "text") && textContent.length > collapseThreshold;
|
|
@@ -2915,7 +3280,7 @@ function MessageParts({ message, collapseThreshold = DEFAULT_COLLAPSE_THRESHOLD,
|
|
|
2915
3280
|
locale,
|
|
2916
3281
|
maxVisible: maxVisibleSourceCards,
|
|
2917
3282
|
getResourceDownloadUrl
|
|
2918
|
-
}, `source-results-${item.index}`) : renderPart(item.part, item.index, message, isStreaming, onOpenAgentThread, getResourceDownloadUrl, locale, renderText, renderToolCall, renderThinking, thinkingLabel, completedThinkingLabel, textClassName)), canCollapse ? /* @__PURE__ */ jsx("button", {
|
|
3283
|
+
}, `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", {
|
|
2919
3284
|
type: "button",
|
|
2920
3285
|
className: "text-xs font-medium text-slate-600 hover:text-slate-900",
|
|
2921
3286
|
onClick: () => setIsExpanded((previous) => !previous),
|
|
@@ -2931,7 +3296,8 @@ function getDatasourceResources(part) {
|
|
|
2931
3296
|
const resources = part.metadata?.resources;
|
|
2932
3297
|
return Array.isArray(resources) ? resources.filter(isDatasourceResource) : [];
|
|
2933
3298
|
}
|
|
2934
|
-
function isRenderableToolPart(part, locale, hasCustomRenderer = false) {
|
|
3299
|
+
function isRenderableToolPart(part, locale, hasCustomRenderer = false, hasMemoryProposalClient = false) {
|
|
3300
|
+
if (part.toolType === "memory_proposal") return hasMemoryProposalClient;
|
|
2935
3301
|
if (hasCustomRenderer || part.toolType !== "datasource") return true;
|
|
2936
3302
|
if (part.state !== "completed") return true;
|
|
2937
3303
|
return getDatasourceResourceCards(getDatasourceResources(part), locale).length > 0;
|
|
@@ -2945,7 +3311,7 @@ function withParts(message, parts) {
|
|
|
2945
3311
|
function AssistantMessage({ message, avatar, footer, messageClassName, contentClassName, toolResultsClassName, toolPartsClassName, contentPartsClassName, messagePartsProps, className,...props }) {
|
|
2946
3312
|
const toolParts = message.parts.filter((part) => part.type === "tool-call");
|
|
2947
3313
|
const contentParts = message.parts.filter((part) => part.type !== "tool-call");
|
|
2948
|
-
const renderableToolParts = toolParts.filter((part) => isRenderableToolPart(part, messagePartsProps?.locale, Boolean(messagePartsProps?.renderToolCall)));
|
|
3314
|
+
const renderableToolParts = toolParts.filter((part) => isRenderableToolPart(part, messagePartsProps?.locale, Boolean(messagePartsProps?.renderToolCall), Boolean(messagePartsProps?.memoryProposal)));
|
|
2949
3315
|
const hasContentRow = contentParts.length > 0 || footer !== void 0;
|
|
2950
3316
|
return /* @__PURE__ */ jsxs("div", {
|
|
2951
3317
|
className: joinClasses("plai-assistant-message flex w-full flex-col gap-2", className),
|
|
@@ -3636,5 +4002,5 @@ async function dummyTranscribeAudio(_audio, signal) {
|
|
|
3636
4002
|
}
|
|
3637
4003
|
|
|
3638
4004
|
//#endregion
|
|
3639
|
-
export { AggregatedSourceResults, ArrowUp, AssistantMessage, Clipboard, DatasourceFolderCard, DatasourceToolResources, DatasourceToolResultCard, Loader, 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, ToolResultWebSearchCard, ToolResultWorkflowDispatchCard, ToolUseIndicator, UserMessage, X, dummyTranscribeAudio, getLocalizedOpenGraphValue, getResourceDescription, getResourceIcon, getResourceOpenGraphImage, getResourceOpenGraphType, getResourceTitle, getResourceType, getResourceUrl, getToolUseLabel, isAllowedPromptFormFile, partitionPromptFormFiles, useSpeechToText };
|
|
4005
|
+
export { AggregatedSourceResults, ArrowUp, AssistantMessage, 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, ToolResultWebSearchCard, ToolResultWorkflowDispatchCard, ToolUseIndicator, UserMessage, X, dummyTranscribeAudio, getLocalizedOpenGraphValue, getResourceDescription, getResourceIcon, getResourceOpenGraphImage, getResourceOpenGraphType, getResourceTitle, getResourceType, getResourceUrl, getToolUseLabel, isAllowedPromptFormFile, partitionPromptFormFiles, useSpeechToText };
|
|
3640
4006
|
//# sourceMappingURL=index.js.map
|