@greatapps/greatagents-ui 0.3.13 → 0.3.15
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/index.d.ts +7 -5
- package/dist/index.js +375 -628
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/agents/agent-prompt-editor.tsx +59 -22
- package/src/components/capabilities/capabilities-tab.tsx +2 -2
- package/src/components/capabilities/integration-card.tsx +160 -112
- package/src/components/capabilities/integration-wizard.tsx +5 -2
- package/src/components/capabilities/integrations-tab.tsx +62 -25
- package/src/components/tools/tool-credentials-form.tsx +1 -374
- package/src/hooks/use-agent-tools.ts +1 -1
- package/src/pages/credentials-page.tsx +0 -10
- package/src/pages/integrations-management-page.tsx +86 -167
- package/src/types/index.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1975,29 +1975,55 @@ function computeDiff(oldText, newText) {
|
|
|
1975
1975
|
function buildPreview(promptText, objectives, agentTools, allTools) {
|
|
1976
1976
|
let preview = promptText;
|
|
1977
1977
|
const activeObjectives = objectives.filter((o) => o.active);
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1978
|
+
const enabledAgentTools = agentTools.filter((at) => at.enabled);
|
|
1979
|
+
const toolMap = new Map(allTools.map((t) => [t.id, t]));
|
|
1980
|
+
const capabilityTools = [];
|
|
1981
|
+
const integrationTools = [];
|
|
1982
|
+
for (const at of enabledAgentTools) {
|
|
1983
|
+
const tool = toolMap.get(at.id_tool);
|
|
1984
|
+
if (!tool) continue;
|
|
1985
|
+
if (tool.type === "integration") {
|
|
1986
|
+
integrationTools.push({ at, tool });
|
|
1987
|
+
} else {
|
|
1988
|
+
capabilityTools.push({ at, tool });
|
|
1984
1989
|
}
|
|
1985
1990
|
}
|
|
1986
|
-
const
|
|
1987
|
-
if (
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
const
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1991
|
+
const hasContent = activeObjectives.length > 0 || capabilityTools.length > 0 || integrationTools.length > 0;
|
|
1992
|
+
if (hasContent) {
|
|
1993
|
+
preview += "\n\n[CAPACIDADES E INTEGRA\xC7\xD5ES]";
|
|
1994
|
+
if (activeObjectives.length > 0 || capabilityTools.length > 0) {
|
|
1995
|
+
preview += "\n\n## Capacidades Internas (GClinic)";
|
|
1996
|
+
for (const obj of activeObjectives) {
|
|
1997
|
+
preview += `
|
|
1998
|
+
|
|
1999
|
+
### ${obj.title} (${obj.slug})`;
|
|
2000
|
+
if (obj.prompt) preview += `
|
|
2001
|
+
${obj.prompt}`;
|
|
2002
|
+
}
|
|
2003
|
+
for (const { at, tool } of capabilityTools) {
|
|
1996
2004
|
preview += `
|
|
1997
|
-
|
|
2005
|
+
|
|
2006
|
+
### ${tool.name} (${tool.slug})`;
|
|
2007
|
+
if (tool.description) preview += `
|
|
2008
|
+
${tool.description}`;
|
|
2009
|
+
if (at.custom_instructions) preview += `
|
|
2010
|
+
${at.custom_instructions}`;
|
|
1998
2011
|
}
|
|
1999
|
-
preview += "\n";
|
|
2000
2012
|
}
|
|
2013
|
+
if (integrationTools.length > 0) {
|
|
2014
|
+
preview += "\n\n## Integra\xE7\xF5es Externas";
|
|
2015
|
+
for (const { at, tool } of integrationTools) {
|
|
2016
|
+
preview += `
|
|
2017
|
+
|
|
2018
|
+
### ${tool.name} (${tool.slug})`;
|
|
2019
|
+
if (at.custom_instructions) preview += `
|
|
2020
|
+
${at.custom_instructions}`;
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
preview += "\n\n## Regras";
|
|
2024
|
+
preview += "\n- Sempre confirme com o usu\xE1rio antes de criar ou alterar registros.";
|
|
2025
|
+
preview += "\n- Nunca invente dados \u2014 sempre consulte primeiro.";
|
|
2026
|
+
preview += "\n- Use EXATAMENTE os nomes de fun\xE7\xE3o listados acima.";
|
|
2001
2027
|
}
|
|
2002
2028
|
return preview;
|
|
2003
2029
|
}
|
|
@@ -2160,11 +2186,14 @@ function AgentPromptEditor({ config, agent }) {
|
|
|
2160
2186
|
}
|
|
2161
2187
|
),
|
|
2162
2188
|
showPreview && /* @__PURE__ */ jsx6("div", { className: "border-t px-4 py-3", children: /* @__PURE__ */ jsx6("pre", { className: "max-h-96 overflow-auto whitespace-pre-wrap font-mono text-sm leading-relaxed", children: previewText.split("\n").map((line, i) => {
|
|
2163
|
-
const
|
|
2189
|
+
const isTopSection = line.startsWith("[CAPACIDADES E INTEGRA\xC7\xD5ES]");
|
|
2190
|
+
const isH2 = line.startsWith("## ");
|
|
2191
|
+
const isH3 = line.startsWith("### ");
|
|
2192
|
+
const cls = isTopSection ? "font-bold text-foreground" : isH2 ? "font-semibold text-muted-foreground" : isH3 ? "font-medium text-muted-foreground" : "";
|
|
2164
2193
|
return /* @__PURE__ */ jsxs5(
|
|
2165
2194
|
"span",
|
|
2166
2195
|
{
|
|
2167
|
-
className:
|
|
2196
|
+
className: cls,
|
|
2168
2197
|
children: [
|
|
2169
2198
|
line,
|
|
2170
2199
|
"\n"
|
|
@@ -2511,7 +2540,7 @@ import {
|
|
|
2511
2540
|
Skeleton as Skeleton5
|
|
2512
2541
|
} from "@greatapps/greatauth-ui/ui";
|
|
2513
2542
|
import {
|
|
2514
|
-
|
|
2543
|
+
CalendarCheck,
|
|
2515
2544
|
Users,
|
|
2516
2545
|
Settings,
|
|
2517
2546
|
HeartHandshake,
|
|
@@ -2531,7 +2560,7 @@ function getOperationLabel(slug) {
|
|
|
2531
2560
|
return OPERATION_LABELS[slug] ?? slug;
|
|
2532
2561
|
}
|
|
2533
2562
|
var CATEGORY_ICONS = {
|
|
2534
|
-
agenda:
|
|
2563
|
+
agenda: CalendarCheck,
|
|
2535
2564
|
cadastros: Users,
|
|
2536
2565
|
infraestrutura: Settings,
|
|
2537
2566
|
relacionamentos: HeartHandshake
|
|
@@ -2829,37 +2858,81 @@ var ICON_MAP = {
|
|
|
2829
2858
|
function resolveIcon(name) {
|
|
2830
2859
|
return ICON_MAP[name] ?? Plug;
|
|
2831
2860
|
}
|
|
2861
|
+
var INTEGRATION_INSTRUCTIONS = {
|
|
2862
|
+
"google-calendar": `Voc\xEA tem acesso ao Google Calendar atrav\xE9s da integra\xE7\xE3o google-calendar.
|
|
2863
|
+
Fun\xE7\xF5es dispon\xEDveis:
|
|
2864
|
+
- google_calendar_setup_oauth: Configurar conex\xE3o OAuth
|
|
2865
|
+
- google_calendar_check_status: Verificar status da conex\xE3o
|
|
2866
|
+
- google_calendar_list_events: Listar eventos do calend\xE1rio
|
|
2867
|
+
- google_calendar_create_event: Criar novo evento
|
|
2868
|
+
- google_calendar_update_event: Atualizar evento existente
|
|
2869
|
+
- google_calendar_delete_event: Cancelar/remover evento
|
|
2870
|
+
|
|
2871
|
+
Use EXATAMENTE os nomes de fun\xE7\xE3o listados acima.`
|
|
2872
|
+
};
|
|
2832
2873
|
function IntegrationsTab({
|
|
2833
2874
|
config,
|
|
2834
2875
|
agentId
|
|
2835
2876
|
}) {
|
|
2836
|
-
const { cards, isLoading } = useIntegrationState(config,
|
|
2837
|
-
const { data: toolsData } = useTools(config);
|
|
2877
|
+
const { cards, isLoading } = useIntegrationState(config, agentId);
|
|
2838
2878
|
const { data: agentToolsData, isLoading: agentToolsLoading } = useAgentTools(config, agentId);
|
|
2879
|
+
const { data: toolsData } = useTools(config);
|
|
2839
2880
|
const addAgentTool = useAddAgentTool(config);
|
|
2840
2881
|
const removeAgentTool = useRemoveAgentTool(config);
|
|
2841
|
-
const
|
|
2882
|
+
const createTool = useCreateTool(config);
|
|
2842
2883
|
const agentTools = agentToolsData?.data ?? [];
|
|
2884
|
+
const allTools = toolsData?.data ?? [];
|
|
2843
2885
|
const connectedCards = cards.filter(
|
|
2844
2886
|
(c) => !c.isAddNew && (c.state === "connected" || c.state === "expired")
|
|
2845
2887
|
);
|
|
2846
2888
|
const handleToggle = useCallback5(
|
|
2847
|
-
(
|
|
2848
|
-
const tool = tools.find((t) => t.slug === toolSlug);
|
|
2849
|
-
if (!tool) return;
|
|
2889
|
+
async (card, checked) => {
|
|
2850
2890
|
if (checked) {
|
|
2891
|
+
let toolId = card.tool?.id;
|
|
2892
|
+
if (!toolId) {
|
|
2893
|
+
const existingTool = allTools.find((t) => t.slug === card.definition.slug);
|
|
2894
|
+
if (existingTool) {
|
|
2895
|
+
toolId = existingTool.id;
|
|
2896
|
+
} else {
|
|
2897
|
+
try {
|
|
2898
|
+
const result = await createTool.mutateAsync({
|
|
2899
|
+
name: card.definition.name,
|
|
2900
|
+
slug: card.definition.slug,
|
|
2901
|
+
type: "integration",
|
|
2902
|
+
description: card.definition.description
|
|
2903
|
+
});
|
|
2904
|
+
const d = result?.data;
|
|
2905
|
+
toolId = (Array.isArray(d) ? d[0]?.id : d?.id) ?? void 0;
|
|
2906
|
+
if (!toolId) {
|
|
2907
|
+
console.error("[IntegrationsTab] Failed to create tool \u2014 no ID returned");
|
|
2908
|
+
return;
|
|
2909
|
+
}
|
|
2910
|
+
} catch (err) {
|
|
2911
|
+
console.error("[IntegrationsTab] Error creating tool:", err);
|
|
2912
|
+
return;
|
|
2913
|
+
}
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
const customInstructions = INTEGRATION_INSTRUCTIONS[card.definition.slug];
|
|
2851
2917
|
addAgentTool.mutate({
|
|
2852
2918
|
idAgent: agentId,
|
|
2853
|
-
body: {
|
|
2919
|
+
body: {
|
|
2920
|
+
id_tool: toolId,
|
|
2921
|
+
enabled: true,
|
|
2922
|
+
...customInstructions ? { custom_instructions: customInstructions } : {}
|
|
2923
|
+
}
|
|
2854
2924
|
});
|
|
2855
2925
|
} else {
|
|
2856
|
-
const
|
|
2857
|
-
if (
|
|
2858
|
-
|
|
2926
|
+
const toolId = card.tool?.id;
|
|
2927
|
+
if (toolId) {
|
|
2928
|
+
const agentTool = agentTools.find((at) => at.id_tool === toolId);
|
|
2929
|
+
if (agentTool) {
|
|
2930
|
+
removeAgentTool.mutate({ idAgent: agentId, id: agentTool.id });
|
|
2931
|
+
}
|
|
2859
2932
|
}
|
|
2860
2933
|
}
|
|
2861
2934
|
},
|
|
2862
|
-
[
|
|
2935
|
+
[agentTools, allTools, agentId, addAgentTool, removeAgentTool, createTool]
|
|
2863
2936
|
);
|
|
2864
2937
|
if (isLoading || agentToolsLoading) {
|
|
2865
2938
|
return /* @__PURE__ */ jsx11("div", { className: "flex items-center justify-center py-16", children: /* @__PURE__ */ jsx11(Loader25, { className: "h-6 w-6 animate-spin text-muted-foreground" }) });
|
|
@@ -2875,9 +2948,8 @@ function IntegrationsTab({
|
|
|
2875
2948
|
/* @__PURE__ */ jsx11("p", { className: "text-xs text-muted-foreground", children: "Ative ou desative as integra\xE7\xF5es conectadas na conta para este agente." }),
|
|
2876
2949
|
/* @__PURE__ */ jsx11("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3", children: connectedCards.map((card) => {
|
|
2877
2950
|
const Icon = resolveIcon(card.definition.icon);
|
|
2878
|
-
const
|
|
2879
|
-
const
|
|
2880
|
-
const isMutating = addAgentTool.isPending || removeAgentTool.isPending;
|
|
2951
|
+
const isLinked = card.linkedToAgent;
|
|
2952
|
+
const isMutating = addAgentTool.isPending || removeAgentTool.isPending || createTool.isPending;
|
|
2881
2953
|
return /* @__PURE__ */ jsxs9(
|
|
2882
2954
|
"div",
|
|
2883
2955
|
{
|
|
@@ -2900,7 +2972,7 @@ function IntegrationsTab({
|
|
|
2900
2972
|
{
|
|
2901
2973
|
checked: isLinked,
|
|
2902
2974
|
disabled: isMutating,
|
|
2903
|
-
onCheckedChange: (checked) =>
|
|
2975
|
+
onCheckedChange: (checked) => handleToggle(card, checked),
|
|
2904
2976
|
"aria-label": `${isLinked ? "Desativar" : "Ativar"} ${card.definition.name} para este agente`
|
|
2905
2977
|
}
|
|
2906
2978
|
)
|
|
@@ -3767,11 +3839,6 @@ import {
|
|
|
3767
3839
|
Tooltip as Tooltip4,
|
|
3768
3840
|
TooltipTrigger as TooltipTrigger4,
|
|
3769
3841
|
TooltipContent as TooltipContent4,
|
|
3770
|
-
Dialog as Dialog6,
|
|
3771
|
-
DialogContent as DialogContent6,
|
|
3772
|
-
DialogHeader as DialogHeader6,
|
|
3773
|
-
DialogTitle as DialogTitle6,
|
|
3774
|
-
DialogFooter as DialogFooter6,
|
|
3775
3842
|
AlertDialog as AlertDialog5,
|
|
3776
3843
|
AlertDialogAction as AlertDialogAction5,
|
|
3777
3844
|
AlertDialogCancel as AlertDialogCancel5,
|
|
@@ -3779,14 +3846,9 @@ import {
|
|
|
3779
3846
|
AlertDialogDescription as AlertDialogDescription5,
|
|
3780
3847
|
AlertDialogFooter as AlertDialogFooter5,
|
|
3781
3848
|
AlertDialogHeader as AlertDialogHeader5,
|
|
3782
|
-
AlertDialogTitle as AlertDialogTitle5
|
|
3783
|
-
Select as Select3,
|
|
3784
|
-
SelectContent as SelectContent3,
|
|
3785
|
-
SelectItem as SelectItem3,
|
|
3786
|
-
SelectTrigger as SelectTrigger3,
|
|
3787
|
-
SelectValue as SelectValue3
|
|
3849
|
+
AlertDialogTitle as AlertDialogTitle5
|
|
3788
3850
|
} from "@greatapps/greatauth-ui/ui";
|
|
3789
|
-
import { Trash2 as Trash25,
|
|
3851
|
+
import { Trash2 as Trash25, Search as Search3 } from "lucide-react";
|
|
3790
3852
|
import { format as format3 } from "date-fns";
|
|
3791
3853
|
import { ptBR as ptBR3 } from "date-fns/locale";
|
|
3792
3854
|
import { toast as toast10 } from "sonner";
|
|
@@ -3795,17 +3857,12 @@ function formatDate2(dateStr) {
|
|
|
3795
3857
|
if (!dateStr) return "Sem expira\xE7\xE3o";
|
|
3796
3858
|
return format3(new Date(dateStr), "dd/MM/yyyy", { locale: ptBR3 });
|
|
3797
3859
|
}
|
|
3798
|
-
function useColumns3(tools,
|
|
3860
|
+
function useColumns3(tools, onRemove) {
|
|
3799
3861
|
function getToolName(idTool) {
|
|
3800
3862
|
if (!idTool) return "\u2014";
|
|
3801
3863
|
const tool = tools.find((t) => t.id === idTool);
|
|
3802
3864
|
return tool?.name || `Ferramenta #${idTool}`;
|
|
3803
3865
|
}
|
|
3804
|
-
function getToolType(idTool) {
|
|
3805
|
-
if (!idTool) return null;
|
|
3806
|
-
const tool = tools.find((t) => t.id === idTool);
|
|
3807
|
-
return tool?.type || null;
|
|
3808
|
-
}
|
|
3809
3866
|
return [
|
|
3810
3867
|
{
|
|
3811
3868
|
accessorKey: "label",
|
|
@@ -3843,50 +3900,20 @@ function useColumns3(tools, onEdit, onConnect, onRemove) {
|
|
|
3843
3900
|
header: "A\xE7\xF5es",
|
|
3844
3901
|
size: 100,
|
|
3845
3902
|
enableSorting: false,
|
|
3846
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
] }),
|
|
3861
|
-
/* @__PURE__ */ jsxs14(Tooltip4, { children: [
|
|
3862
|
-
/* @__PURE__ */ jsx16(TooltipTrigger4, { asChild: true, children: /* @__PURE__ */ jsx16(
|
|
3863
|
-
Button11,
|
|
3864
|
-
{
|
|
3865
|
-
variant: "ghost",
|
|
3866
|
-
size: "icon",
|
|
3867
|
-
className: "h-8 w-8",
|
|
3868
|
-
"aria-label": "Editar",
|
|
3869
|
-
onClick: () => onEdit(row.original),
|
|
3870
|
-
children: /* @__PURE__ */ jsx16(Pencil4, { className: "h-4 w-4" })
|
|
3871
|
-
}
|
|
3872
|
-
) }),
|
|
3873
|
-
/* @__PURE__ */ jsx16(TooltipContent4, { children: "Editar" })
|
|
3874
|
-
] }),
|
|
3875
|
-
/* @__PURE__ */ jsxs14(Tooltip4, { children: [
|
|
3876
|
-
/* @__PURE__ */ jsx16(TooltipTrigger4, { asChild: true, children: /* @__PURE__ */ jsx16(
|
|
3877
|
-
Button11,
|
|
3878
|
-
{
|
|
3879
|
-
variant: "ghost",
|
|
3880
|
-
size: "icon",
|
|
3881
|
-
className: "h-8 w-8 text-destructive hover:text-destructive",
|
|
3882
|
-
"aria-label": "Excluir",
|
|
3883
|
-
onClick: () => onRemove(row.original),
|
|
3884
|
-
children: /* @__PURE__ */ jsx16(Trash25, { className: "h-4 w-4" })
|
|
3885
|
-
}
|
|
3886
|
-
) }),
|
|
3887
|
-
/* @__PURE__ */ jsx16(TooltipContent4, { children: "Remover" })
|
|
3888
|
-
] })
|
|
3889
|
-
] })
|
|
3903
|
+
cell: ({ row }) => /* @__PURE__ */ jsx16("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ jsxs14(Tooltip4, { children: [
|
|
3904
|
+
/* @__PURE__ */ jsx16(TooltipTrigger4, { asChild: true, children: /* @__PURE__ */ jsx16(
|
|
3905
|
+
Button11,
|
|
3906
|
+
{
|
|
3907
|
+
variant: "ghost",
|
|
3908
|
+
size: "icon",
|
|
3909
|
+
className: "h-8 w-8 text-destructive hover:text-destructive",
|
|
3910
|
+
"aria-label": "Excluir",
|
|
3911
|
+
onClick: () => onRemove(row.original),
|
|
3912
|
+
children: /* @__PURE__ */ jsx16(Trash25, { className: "h-4 w-4" })
|
|
3913
|
+
}
|
|
3914
|
+
) }),
|
|
3915
|
+
/* @__PURE__ */ jsx16(TooltipContent4, { children: "Remover" })
|
|
3916
|
+
] }) })
|
|
3890
3917
|
}
|
|
3891
3918
|
];
|
|
3892
3919
|
}
|
|
@@ -3894,33 +3921,12 @@ function ToolCredentialsForm({
|
|
|
3894
3921
|
credentials,
|
|
3895
3922
|
isLoading,
|
|
3896
3923
|
config,
|
|
3897
|
-
gagentsApiUrl
|
|
3898
|
-
createOpen: externalCreateOpen,
|
|
3899
|
-
onCreateOpenChange
|
|
3924
|
+
gagentsApiUrl
|
|
3900
3925
|
}) {
|
|
3901
|
-
const createMutation = useCreateToolCredential(config);
|
|
3902
|
-
const updateMutation = useUpdateToolCredential(config);
|
|
3903
3926
|
const deleteMutation = useDeleteToolCredential(config);
|
|
3904
3927
|
const { data: toolsData } = useTools(config);
|
|
3905
3928
|
const tools = (toolsData?.data || []).filter((t) => !t.slug?.startsWith("gclinic_"));
|
|
3906
3929
|
const [search, setSearch] = useState12("");
|
|
3907
|
-
const [internalCreateOpen, setInternalCreateOpen] = useState12(false);
|
|
3908
|
-
const showCreateDialog = externalCreateOpen ?? internalCreateOpen;
|
|
3909
|
-
const setShowCreateDialog = onCreateOpenChange ?? setInternalCreateOpen;
|
|
3910
|
-
const [createForm, setCreateForm] = useState12({
|
|
3911
|
-
id_tool: "",
|
|
3912
|
-
label: "",
|
|
3913
|
-
credentials_encrypted: "",
|
|
3914
|
-
expires_at: ""
|
|
3915
|
-
});
|
|
3916
|
-
const [editTarget, setEditTarget] = useState12(null);
|
|
3917
|
-
const [editForm, setEditForm] = useState12({
|
|
3918
|
-
id_tool: "",
|
|
3919
|
-
label: "",
|
|
3920
|
-
credentials_encrypted: "",
|
|
3921
|
-
expires_at: "",
|
|
3922
|
-
status: ""
|
|
3923
|
-
});
|
|
3924
3930
|
const [removeTarget, setRemoveTarget] = useState12(null);
|
|
3925
3931
|
const internalToolIds = useMemo7(() => {
|
|
3926
3932
|
const allRawTools = toolsData?.data || [];
|
|
@@ -3941,79 +3947,8 @@ function ToolCredentialsForm({
|
|
|
3941
3947
|
}, [credentials, search, tools, internalToolIds]);
|
|
3942
3948
|
const columns = useColumns3(
|
|
3943
3949
|
tools,
|
|
3944
|
-
(cred) => startEdit(cred),
|
|
3945
|
-
(cred) => handleConnect(cred),
|
|
3946
3950
|
(cred) => setRemoveTarget(cred)
|
|
3947
3951
|
);
|
|
3948
|
-
async function handleCreate() {
|
|
3949
|
-
const idTool = parseInt(createForm.id_tool, 10);
|
|
3950
|
-
if (!idTool || !createForm.label.trim() || !createForm.credentials_encrypted.trim()) return;
|
|
3951
|
-
try {
|
|
3952
|
-
const result = await createMutation.mutateAsync({
|
|
3953
|
-
id_tool: idTool,
|
|
3954
|
-
label: createForm.label.trim(),
|
|
3955
|
-
credentials_encrypted: createForm.credentials_encrypted.trim(),
|
|
3956
|
-
...createForm.expires_at ? { expires_at: createForm.expires_at } : {}
|
|
3957
|
-
});
|
|
3958
|
-
if (result.status === 1) {
|
|
3959
|
-
toast10.success("Credencial criada");
|
|
3960
|
-
setShowCreateDialog(false);
|
|
3961
|
-
setCreateForm({ id_tool: "", label: "", credentials_encrypted: "", expires_at: "" });
|
|
3962
|
-
} else {
|
|
3963
|
-
toast10.error(result.message || "Erro ao criar credencial");
|
|
3964
|
-
}
|
|
3965
|
-
} catch {
|
|
3966
|
-
toast10.error("Erro ao criar credencial");
|
|
3967
|
-
}
|
|
3968
|
-
}
|
|
3969
|
-
function startEdit(cred) {
|
|
3970
|
-
setEditTarget(cred);
|
|
3971
|
-
setEditForm({
|
|
3972
|
-
id_tool: cred.id_tool ? String(cred.id_tool) : "",
|
|
3973
|
-
label: cred.label || "",
|
|
3974
|
-
credentials_encrypted: "",
|
|
3975
|
-
expires_at: cred.expires_at || "",
|
|
3976
|
-
status: cred.status
|
|
3977
|
-
});
|
|
3978
|
-
}
|
|
3979
|
-
async function handleSaveEdit() {
|
|
3980
|
-
if (!editTarget) return;
|
|
3981
|
-
const body = {};
|
|
3982
|
-
const newIdTool = editForm.id_tool ? parseInt(editForm.id_tool, 10) : null;
|
|
3983
|
-
if (newIdTool && newIdTool !== editTarget.id_tool) {
|
|
3984
|
-
body.id_tool = newIdTool;
|
|
3985
|
-
}
|
|
3986
|
-
if (editForm.label.trim() && editForm.label.trim() !== (editTarget.label || "")) {
|
|
3987
|
-
body.label = editForm.label.trim();
|
|
3988
|
-
}
|
|
3989
|
-
if (editForm.credentials_encrypted.trim()) {
|
|
3990
|
-
body.credentials_encrypted = editForm.credentials_encrypted.trim();
|
|
3991
|
-
}
|
|
3992
|
-
if (editForm.expires_at !== (editTarget.expires_at || "")) {
|
|
3993
|
-
body.expires_at = editForm.expires_at || null;
|
|
3994
|
-
}
|
|
3995
|
-
if (editForm.status && editForm.status !== editTarget.status) {
|
|
3996
|
-
body.status = editForm.status;
|
|
3997
|
-
}
|
|
3998
|
-
if (Object.keys(body).length === 0) {
|
|
3999
|
-
setEditTarget(null);
|
|
4000
|
-
return;
|
|
4001
|
-
}
|
|
4002
|
-
try {
|
|
4003
|
-
const result = await updateMutation.mutateAsync({
|
|
4004
|
-
id: editTarget.id,
|
|
4005
|
-
body
|
|
4006
|
-
});
|
|
4007
|
-
if (result.status === 1) {
|
|
4008
|
-
toast10.success("Credencial atualizada");
|
|
4009
|
-
setEditTarget(null);
|
|
4010
|
-
} else {
|
|
4011
|
-
toast10.error(result.message || "Erro ao atualizar credencial");
|
|
4012
|
-
}
|
|
4013
|
-
} catch {
|
|
4014
|
-
toast10.error("Erro ao atualizar credencial");
|
|
4015
|
-
}
|
|
4016
|
-
}
|
|
4017
3952
|
async function handleRemove() {
|
|
4018
3953
|
if (!removeTarget) return;
|
|
4019
3954
|
try {
|
|
@@ -4029,13 +3964,6 @@ function ToolCredentialsForm({
|
|
|
4029
3964
|
setRemoveTarget(null);
|
|
4030
3965
|
}
|
|
4031
3966
|
}
|
|
4032
|
-
function handleConnect(cred) {
|
|
4033
|
-
if (!config.accountId || !config.token) return;
|
|
4034
|
-
const language = config.language ?? "pt-br";
|
|
4035
|
-
const idWl = config.idWl ?? 1;
|
|
4036
|
-
const url = `${gagentsApiUrl}/v1/${language}/${idWl}/accounts/${config.accountId}/oauth/connect?id_tool=${cred.id_tool}`;
|
|
4037
|
-
window.open(url, "_blank");
|
|
4038
|
-
}
|
|
4039
3967
|
return /* @__PURE__ */ jsxs14("div", { className: "space-y-4", children: [
|
|
4040
3968
|
/* @__PURE__ */ jsx16("div", { className: "flex items-center gap-3", children: /* @__PURE__ */ jsxs14("div", { className: "relative flex-1 max-w-md", children: [
|
|
4041
3969
|
/* @__PURE__ */ jsx16(Search3, { "aria-hidden": "true", className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
|
|
@@ -4061,188 +3989,6 @@ function ToolCredentialsForm({
|
|
|
4061
3989
|
emptyMessage: "Nenhuma credencial encontrada"
|
|
4062
3990
|
}
|
|
4063
3991
|
),
|
|
4064
|
-
/* @__PURE__ */ jsx16(Dialog6, { open: showCreateDialog, onOpenChange: setShowCreateDialog, children: /* @__PURE__ */ jsxs14(DialogContent6, { children: [
|
|
4065
|
-
/* @__PURE__ */ jsx16(DialogHeader6, { children: /* @__PURE__ */ jsx16(DialogTitle6, { children: "Nova Credencial" }) }),
|
|
4066
|
-
/* @__PURE__ */ jsxs14("div", { className: "space-y-4", children: [
|
|
4067
|
-
/* @__PURE__ */ jsxs14("div", { children: [
|
|
4068
|
-
/* @__PURE__ */ jsx16("label", { htmlFor: "cred-tool", className: "mb-1 block text-sm font-medium", children: "Ferramenta *" }),
|
|
4069
|
-
/* @__PURE__ */ jsxs14(
|
|
4070
|
-
Select3,
|
|
4071
|
-
{
|
|
4072
|
-
value: createForm.id_tool,
|
|
4073
|
-
onValueChange: (val) => setCreateForm((f) => ({ ...f, id_tool: val })),
|
|
4074
|
-
children: [
|
|
4075
|
-
/* @__PURE__ */ jsx16(SelectTrigger3, { id: "cred-tool", children: /* @__PURE__ */ jsx16(SelectValue3, { placeholder: "Selecione a ferramenta" }) }),
|
|
4076
|
-
/* @__PURE__ */ jsx16(SelectContent3, { children: tools.map((tool) => /* @__PURE__ */ jsx16(SelectItem3, { value: String(tool.id), children: tool.name }, tool.id)) })
|
|
4077
|
-
]
|
|
4078
|
-
}
|
|
4079
|
-
)
|
|
4080
|
-
] }),
|
|
4081
|
-
/* @__PURE__ */ jsxs14("div", { children: [
|
|
4082
|
-
/* @__PURE__ */ jsx16("label", { htmlFor: "cred-label", className: "mb-1 block text-sm font-medium", children: "Label *" }),
|
|
4083
|
-
/* @__PURE__ */ jsx16(
|
|
4084
|
-
Input9,
|
|
4085
|
-
{
|
|
4086
|
-
id: "cred-label",
|
|
4087
|
-
name: "label",
|
|
4088
|
-
value: createForm.label,
|
|
4089
|
-
onChange: (e) => setCreateForm((f) => ({ ...f, label: e.target.value })),
|
|
4090
|
-
placeholder: "Ex: Google Calendar - Cl\xEDnica S\xE3o Paulo"
|
|
4091
|
-
}
|
|
4092
|
-
)
|
|
4093
|
-
] }),
|
|
4094
|
-
/* @__PURE__ */ jsxs14("div", { children: [
|
|
4095
|
-
/* @__PURE__ */ jsx16("label", { htmlFor: "cred-credential", className: "mb-1 block text-sm font-medium", children: "Credencial *" }),
|
|
4096
|
-
/* @__PURE__ */ jsx16(
|
|
4097
|
-
Input9,
|
|
4098
|
-
{
|
|
4099
|
-
id: "cred-credential",
|
|
4100
|
-
name: "credential",
|
|
4101
|
-
autoComplete: "off",
|
|
4102
|
-
type: "password",
|
|
4103
|
-
value: createForm.credentials_encrypted,
|
|
4104
|
-
onChange: (e) => setCreateForm((f) => ({
|
|
4105
|
-
...f,
|
|
4106
|
-
credentials_encrypted: e.target.value
|
|
4107
|
-
})),
|
|
4108
|
-
placeholder: "Credencial encriptada"
|
|
4109
|
-
}
|
|
4110
|
-
)
|
|
4111
|
-
] }),
|
|
4112
|
-
/* @__PURE__ */ jsxs14("div", { children: [
|
|
4113
|
-
/* @__PURE__ */ jsx16("label", { htmlFor: "cred-expires", className: "mb-1 block text-sm font-medium", children: "Data de Expira\xE7\xE3o (opcional)" }),
|
|
4114
|
-
/* @__PURE__ */ jsx16(
|
|
4115
|
-
Input9,
|
|
4116
|
-
{
|
|
4117
|
-
id: "cred-expires",
|
|
4118
|
-
name: "expires",
|
|
4119
|
-
type: "date",
|
|
4120
|
-
value: createForm.expires_at,
|
|
4121
|
-
onChange: (e) => setCreateForm((f) => ({ ...f, expires_at: e.target.value }))
|
|
4122
|
-
}
|
|
4123
|
-
)
|
|
4124
|
-
] })
|
|
4125
|
-
] }),
|
|
4126
|
-
/* @__PURE__ */ jsxs14(DialogFooter6, { children: [
|
|
4127
|
-
/* @__PURE__ */ jsx16(
|
|
4128
|
-
Button11,
|
|
4129
|
-
{
|
|
4130
|
-
variant: "outline",
|
|
4131
|
-
onClick: () => setShowCreateDialog(false),
|
|
4132
|
-
children: "Cancelar"
|
|
4133
|
-
}
|
|
4134
|
-
),
|
|
4135
|
-
/* @__PURE__ */ jsx16(
|
|
4136
|
-
Button11,
|
|
4137
|
-
{
|
|
4138
|
-
onClick: handleCreate,
|
|
4139
|
-
disabled: !createForm.id_tool || !createForm.label.trim() || !createForm.credentials_encrypted.trim() || createMutation.isPending,
|
|
4140
|
-
children: "Criar"
|
|
4141
|
-
}
|
|
4142
|
-
)
|
|
4143
|
-
] })
|
|
4144
|
-
] }) }),
|
|
4145
|
-
/* @__PURE__ */ jsx16(
|
|
4146
|
-
Dialog6,
|
|
4147
|
-
{
|
|
4148
|
-
open: !!editTarget,
|
|
4149
|
-
onOpenChange: (open) => !open && setEditTarget(null),
|
|
4150
|
-
children: /* @__PURE__ */ jsxs14(DialogContent6, { children: [
|
|
4151
|
-
/* @__PURE__ */ jsx16(DialogHeader6, { children: /* @__PURE__ */ jsx16(DialogTitle6, { children: "Editar Credencial" }) }),
|
|
4152
|
-
/* @__PURE__ */ jsxs14("div", { className: "space-y-4", children: [
|
|
4153
|
-
/* @__PURE__ */ jsxs14("div", { children: [
|
|
4154
|
-
/* @__PURE__ */ jsx16("label", { htmlFor: "edit-cred-tool", className: "mb-1 block text-sm font-medium", children: "Ferramenta *" }),
|
|
4155
|
-
/* @__PURE__ */ jsxs14(
|
|
4156
|
-
Select3,
|
|
4157
|
-
{
|
|
4158
|
-
value: editForm.id_tool,
|
|
4159
|
-
onValueChange: (val) => setEditForm((f) => ({ ...f, id_tool: val })),
|
|
4160
|
-
children: [
|
|
4161
|
-
/* @__PURE__ */ jsx16(SelectTrigger3, { id: "edit-cred-tool", children: /* @__PURE__ */ jsx16(SelectValue3, { placeholder: "Selecione a ferramenta" }) }),
|
|
4162
|
-
/* @__PURE__ */ jsx16(SelectContent3, { children: tools.map((tool) => /* @__PURE__ */ jsx16(SelectItem3, { value: String(tool.id), children: tool.name }, tool.id)) })
|
|
4163
|
-
]
|
|
4164
|
-
}
|
|
4165
|
-
)
|
|
4166
|
-
] }),
|
|
4167
|
-
/* @__PURE__ */ jsxs14("div", { children: [
|
|
4168
|
-
/* @__PURE__ */ jsx16("label", { htmlFor: "edit-cred-label", className: "mb-1 block text-sm font-medium", children: "Label" }),
|
|
4169
|
-
/* @__PURE__ */ jsx16(
|
|
4170
|
-
Input9,
|
|
4171
|
-
{
|
|
4172
|
-
id: "edit-cred-label",
|
|
4173
|
-
name: "label",
|
|
4174
|
-
value: editForm.label,
|
|
4175
|
-
onChange: (e) => setEditForm((f) => ({ ...f, label: e.target.value })),
|
|
4176
|
-
placeholder: "Label da credencial"
|
|
4177
|
-
}
|
|
4178
|
-
)
|
|
4179
|
-
] }),
|
|
4180
|
-
/* @__PURE__ */ jsxs14("div", { children: [
|
|
4181
|
-
/* @__PURE__ */ jsx16("label", { htmlFor: "edit-cred-credential", className: "mb-1 block text-sm font-medium", children: "Nova Credencial (vazio = manter atual)" }),
|
|
4182
|
-
/* @__PURE__ */ jsx16(
|
|
4183
|
-
Input9,
|
|
4184
|
-
{
|
|
4185
|
-
id: "edit-cred-credential",
|
|
4186
|
-
name: "credential",
|
|
4187
|
-
autoComplete: "off",
|
|
4188
|
-
type: "password",
|
|
4189
|
-
value: editForm.credentials_encrypted,
|
|
4190
|
-
onChange: (e) => setEditForm((f) => ({
|
|
4191
|
-
...f,
|
|
4192
|
-
credentials_encrypted: e.target.value
|
|
4193
|
-
})),
|
|
4194
|
-
placeholder: "Nova credencial"
|
|
4195
|
-
}
|
|
4196
|
-
)
|
|
4197
|
-
] }),
|
|
4198
|
-
/* @__PURE__ */ jsxs14("div", { children: [
|
|
4199
|
-
/* @__PURE__ */ jsx16("label", { htmlFor: "edit-cred-expires", className: "mb-1 block text-sm font-medium", children: "Data de Expira\xE7\xE3o" }),
|
|
4200
|
-
/* @__PURE__ */ jsx16(
|
|
4201
|
-
Input9,
|
|
4202
|
-
{
|
|
4203
|
-
id: "edit-cred-expires",
|
|
4204
|
-
name: "expires",
|
|
4205
|
-
type: "date",
|
|
4206
|
-
value: editForm.expires_at,
|
|
4207
|
-
onChange: (e) => setEditForm((f) => ({ ...f, expires_at: e.target.value }))
|
|
4208
|
-
}
|
|
4209
|
-
)
|
|
4210
|
-
] }),
|
|
4211
|
-
/* @__PURE__ */ jsxs14("div", { children: [
|
|
4212
|
-
/* @__PURE__ */ jsx16("label", { htmlFor: "edit-cred-status", className: "mb-1 block text-sm font-medium", children: "Status" }),
|
|
4213
|
-
/* @__PURE__ */ jsxs14(
|
|
4214
|
-
Select3,
|
|
4215
|
-
{
|
|
4216
|
-
value: editForm.status || void 0,
|
|
4217
|
-
onValueChange: (val) => setEditForm((f) => ({
|
|
4218
|
-
...f,
|
|
4219
|
-
status: val
|
|
4220
|
-
})),
|
|
4221
|
-
children: [
|
|
4222
|
-
/* @__PURE__ */ jsx16(SelectTrigger3, { id: "edit-cred-status", children: /* @__PURE__ */ jsx16(SelectValue3, {}) }),
|
|
4223
|
-
/* @__PURE__ */ jsxs14(SelectContent3, { children: [
|
|
4224
|
-
/* @__PURE__ */ jsx16(SelectItem3, { value: "active", children: "Ativo" }),
|
|
4225
|
-
/* @__PURE__ */ jsx16(SelectItem3, { value: "expired", children: "Expirado" })
|
|
4226
|
-
] })
|
|
4227
|
-
]
|
|
4228
|
-
}
|
|
4229
|
-
)
|
|
4230
|
-
] })
|
|
4231
|
-
] }),
|
|
4232
|
-
/* @__PURE__ */ jsxs14(DialogFooter6, { children: [
|
|
4233
|
-
/* @__PURE__ */ jsx16(Button11, { variant: "outline", onClick: () => setEditTarget(null), children: "Cancelar" }),
|
|
4234
|
-
/* @__PURE__ */ jsx16(
|
|
4235
|
-
Button11,
|
|
4236
|
-
{
|
|
4237
|
-
onClick: handleSaveEdit,
|
|
4238
|
-
disabled: updateMutation.isPending,
|
|
4239
|
-
children: "Salvar"
|
|
4240
|
-
}
|
|
4241
|
-
)
|
|
4242
|
-
] })
|
|
4243
|
-
] })
|
|
4244
|
-
}
|
|
4245
|
-
),
|
|
4246
3992
|
/* @__PURE__ */ jsx16(
|
|
4247
3993
|
AlertDialog5,
|
|
4248
3994
|
{
|
|
@@ -4271,23 +4017,39 @@ function ToolCredentialsForm({
|
|
|
4271
4017
|
}
|
|
4272
4018
|
|
|
4273
4019
|
// src/components/capabilities/integration-card.tsx
|
|
4274
|
-
import {
|
|
4020
|
+
import { useState as useState13 } from "react";
|
|
4021
|
+
import {
|
|
4022
|
+
Badge as Badge9,
|
|
4023
|
+
Button as Button12,
|
|
4024
|
+
DropdownMenu,
|
|
4025
|
+
DropdownMenuContent,
|
|
4026
|
+
DropdownMenuItem,
|
|
4027
|
+
DropdownMenuTrigger,
|
|
4028
|
+
AlertDialog as AlertDialog6,
|
|
4029
|
+
AlertDialogAction as AlertDialogAction6,
|
|
4030
|
+
AlertDialogCancel as AlertDialogCancel6,
|
|
4031
|
+
AlertDialogContent as AlertDialogContent6,
|
|
4032
|
+
AlertDialogDescription as AlertDialogDescription6,
|
|
4033
|
+
AlertDialogFooter as AlertDialogFooter6,
|
|
4034
|
+
AlertDialogHeader as AlertDialogHeader6,
|
|
4035
|
+
AlertDialogTitle as AlertDialogTitle6
|
|
4036
|
+
} from "@greatapps/greatauth-ui/ui";
|
|
4275
4037
|
import {
|
|
4276
4038
|
CalendarSync as CalendarSync2,
|
|
4277
4039
|
Plug as Plug3,
|
|
4278
4040
|
Settings as Settings3,
|
|
4279
4041
|
RefreshCw,
|
|
4280
|
-
Users as Users2,
|
|
4281
4042
|
Clock,
|
|
4282
|
-
Plus as Plus3
|
|
4043
|
+
Plus as Plus3,
|
|
4044
|
+
Unplug,
|
|
4045
|
+
Trash2 as Trash26
|
|
4283
4046
|
} from "lucide-react";
|
|
4284
|
-
import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
4047
|
+
import { Fragment as Fragment3, jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
4285
4048
|
var ICON_MAP2 = {
|
|
4286
4049
|
CalendarSync: CalendarSync2,
|
|
4287
4050
|
Plug: Plug3,
|
|
4288
4051
|
Settings: Settings3,
|
|
4289
4052
|
RefreshCw,
|
|
4290
|
-
Users: Users2,
|
|
4291
4053
|
Clock,
|
|
4292
4054
|
Plus: Plus3
|
|
4293
4055
|
};
|
|
@@ -4312,35 +4074,29 @@ var STATE_BADGES = {
|
|
|
4312
4074
|
className: "bg-muted text-muted-foreground"
|
|
4313
4075
|
}
|
|
4314
4076
|
};
|
|
4315
|
-
function
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
return "Reconectar";
|
|
4324
|
-
default:
|
|
4325
|
-
return "";
|
|
4326
|
-
}
|
|
4327
|
-
}
|
|
4328
|
-
function IntegrationCard({ card, onConnect }) {
|
|
4329
|
-
const { definition, state, sharedByAgentsCount, isAddNew, accountLabel } = card;
|
|
4077
|
+
function IntegrationCard({
|
|
4078
|
+
card,
|
|
4079
|
+
onConnect,
|
|
4080
|
+
onReconnect,
|
|
4081
|
+
onDisconnect,
|
|
4082
|
+
onDelete
|
|
4083
|
+
}) {
|
|
4084
|
+
const { definition, state, isAddNew, accountLabel } = card;
|
|
4330
4085
|
const Icon = resolveIcon2(definition.icon);
|
|
4331
4086
|
const isComingSoon = state === "coming_soon";
|
|
4332
|
-
const
|
|
4087
|
+
const isConnected = state === "connected" || state === "expired";
|
|
4088
|
+
const [deleteDialogOpen, setDeleteDialogOpen] = useState13(false);
|
|
4333
4089
|
if (isAddNew) {
|
|
4334
4090
|
return /* @__PURE__ */ jsxs15(
|
|
4335
4091
|
"div",
|
|
4336
4092
|
{
|
|
4337
4093
|
className: cn(
|
|
4338
|
-
"group relative flex flex-col gap-3 rounded-xl border
|
|
4339
|
-
"hover:shadow-md hover:
|
|
4094
|
+
"group relative flex flex-col gap-3 rounded-xl border bg-card/50 p-5 transition-all",
|
|
4095
|
+
"hover:shadow-md hover:bg-card cursor-pointer"
|
|
4340
4096
|
),
|
|
4341
4097
|
role: "button",
|
|
4342
4098
|
tabIndex: 0,
|
|
4343
|
-
"aria-label": `
|
|
4099
|
+
"aria-label": `Conectar ${definition.name}`,
|
|
4344
4100
|
onClick: () => onConnect(card),
|
|
4345
4101
|
onKeyDown: (e) => {
|
|
4346
4102
|
if (e.key === "Enter" || e.key === " ") {
|
|
@@ -4349,15 +4105,11 @@ function IntegrationCard({ card, onConnect }) {
|
|
|
4349
4105
|
}
|
|
4350
4106
|
},
|
|
4351
4107
|
children: [
|
|
4352
|
-
/* @__PURE__ */ jsxs15("div", { className: "flex items-start
|
|
4108
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex items-start gap-3", children: [
|
|
4353
4109
|
/* @__PURE__ */ jsx17("div", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/5 text-primary/60", children: /* @__PURE__ */ jsx17(Icon, { className: "h-5 w-5" }) }),
|
|
4354
|
-
/* @__PURE__ */
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
/* @__PURE__ */ jsx17("h3", { className: "text-sm font-semibold leading-tight text-muted-foreground", children: definition.name }),
|
|
4358
|
-
/* @__PURE__ */ jsxs15("p", { className: "text-xs text-muted-foreground/70 leading-relaxed flex items-center gap-1", children: [
|
|
4359
|
-
/* @__PURE__ */ jsx17(Plus3, { className: "h-3 w-3" }),
|
|
4360
|
-
"Adicionar conta"
|
|
4110
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex-1 min-w-0 space-y-0.5", children: [
|
|
4111
|
+
/* @__PURE__ */ jsx17("h3", { className: "text-sm font-semibold leading-tight text-foreground", children: definition.name }),
|
|
4112
|
+
/* @__PURE__ */ jsx17("p", { className: "text-xs text-muted-foreground leading-relaxed", children: "Conectar nova conta" })
|
|
4361
4113
|
] })
|
|
4362
4114
|
] }),
|
|
4363
4115
|
/* @__PURE__ */ jsx17("div", { className: "mt-auto flex items-center justify-end pt-1", children: /* @__PURE__ */ jsx17(
|
|
@@ -4370,75 +4122,138 @@ function IntegrationCard({ card, onConnect }) {
|
|
|
4370
4122
|
e.stopPropagation();
|
|
4371
4123
|
onConnect(card);
|
|
4372
4124
|
},
|
|
4373
|
-
children:
|
|
4125
|
+
children: "Conectar"
|
|
4374
4126
|
}
|
|
4375
4127
|
) })
|
|
4376
4128
|
]
|
|
4377
4129
|
}
|
|
4378
4130
|
);
|
|
4379
4131
|
}
|
|
4132
|
+
if (isComingSoon) {
|
|
4133
|
+
const badge2 = STATE_BADGES[state];
|
|
4134
|
+
return /* @__PURE__ */ jsxs15(
|
|
4135
|
+
"div",
|
|
4136
|
+
{
|
|
4137
|
+
className: "group relative flex flex-col gap-3 rounded-xl border bg-card p-5 opacity-60 cursor-default",
|
|
4138
|
+
"aria-disabled": true,
|
|
4139
|
+
children: [
|
|
4140
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex items-start justify-between gap-2", children: [
|
|
4141
|
+
/* @__PURE__ */ jsx17("div", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary", children: /* @__PURE__ */ jsx17(Icon, { className: "h-5 w-5" }) }),
|
|
4142
|
+
/* @__PURE__ */ jsx17(Badge9, { variant: "outline", className: cn("text-xs", badge2.className), children: badge2.label })
|
|
4143
|
+
] }),
|
|
4144
|
+
/* @__PURE__ */ jsxs15("div", { className: "space-y-1", children: [
|
|
4145
|
+
/* @__PURE__ */ jsx17("h3", { className: "text-sm font-semibold leading-tight", children: definition.name }),
|
|
4146
|
+
/* @__PURE__ */ jsx17("p", { className: "text-xs text-muted-foreground leading-relaxed", children: definition.description })
|
|
4147
|
+
] })
|
|
4148
|
+
]
|
|
4149
|
+
}
|
|
4150
|
+
);
|
|
4151
|
+
}
|
|
4380
4152
|
const badge = STATE_BADGES[state];
|
|
4381
|
-
return /* @__PURE__ */ jsxs15(
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
"group relative flex flex-col gap-3 rounded-xl border bg-card p-5 transition-shadow",
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
/* @__PURE__ */
|
|
4411
|
-
/* @__PURE__ */
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4153
|
+
return /* @__PURE__ */ jsxs15(Fragment3, { children: [
|
|
4154
|
+
/* @__PURE__ */ jsxs15(
|
|
4155
|
+
"div",
|
|
4156
|
+
{
|
|
4157
|
+
className: "group relative flex flex-col gap-3 rounded-xl border bg-card p-5 transition-shadow hover:shadow-md",
|
|
4158
|
+
children: [
|
|
4159
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex items-start justify-between gap-2", children: [
|
|
4160
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex items-start gap-3 min-w-0 flex-1", children: [
|
|
4161
|
+
/* @__PURE__ */ jsx17("div", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary", children: /* @__PURE__ */ jsx17(Icon, { className: "h-5 w-5" }) }),
|
|
4162
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex-1 min-w-0 space-y-0.5", children: [
|
|
4163
|
+
/* @__PURE__ */ jsx17("h3", { className: "text-sm font-semibold leading-tight", children: definition.name }),
|
|
4164
|
+
accountLabel && /* @__PURE__ */ jsx17("p", { className: "text-xs text-muted-foreground leading-relaxed truncate", title: accountLabel, children: accountLabel })
|
|
4165
|
+
] })
|
|
4166
|
+
] }),
|
|
4167
|
+
/* @__PURE__ */ jsx17(Badge9, { variant: "outline", className: cn("text-xs shrink-0", badge.className), children: badge.label })
|
|
4168
|
+
] }),
|
|
4169
|
+
/* @__PURE__ */ jsx17("div", { className: "mt-auto flex items-center justify-end gap-2 pt-1", children: /* @__PURE__ */ jsxs15(DropdownMenu, { children: [
|
|
4170
|
+
/* @__PURE__ */ jsx17(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs15(
|
|
4171
|
+
Button12,
|
|
4172
|
+
{
|
|
4173
|
+
variant: "outline",
|
|
4174
|
+
size: "sm",
|
|
4175
|
+
className: "text-xs gap-1.5",
|
|
4176
|
+
children: [
|
|
4177
|
+
/* @__PURE__ */ jsx17(Settings3, { className: "h-3.5 w-3.5" }),
|
|
4178
|
+
"Configurar"
|
|
4179
|
+
]
|
|
4180
|
+
}
|
|
4181
|
+
) }),
|
|
4182
|
+
/* @__PURE__ */ jsxs15(DropdownMenuContent, { align: "end", children: [
|
|
4183
|
+
/* @__PURE__ */ jsxs15(
|
|
4184
|
+
DropdownMenuItem,
|
|
4185
|
+
{
|
|
4186
|
+
onClick: () => onReconnect?.(card),
|
|
4187
|
+
className: "gap-2",
|
|
4188
|
+
children: [
|
|
4189
|
+
/* @__PURE__ */ jsx17(RefreshCw, { className: "h-4 w-4" }),
|
|
4190
|
+
"Reconectar"
|
|
4191
|
+
]
|
|
4192
|
+
}
|
|
4193
|
+
),
|
|
4194
|
+
/* @__PURE__ */ jsxs15(
|
|
4195
|
+
DropdownMenuItem,
|
|
4196
|
+
{
|
|
4197
|
+
onClick: () => onDisconnect?.(card),
|
|
4198
|
+
className: "gap-2",
|
|
4199
|
+
children: [
|
|
4200
|
+
/* @__PURE__ */ jsx17(Unplug, { className: "h-4 w-4" }),
|
|
4201
|
+
"Desconectar"
|
|
4202
|
+
]
|
|
4203
|
+
}
|
|
4204
|
+
),
|
|
4205
|
+
/* @__PURE__ */ jsxs15(
|
|
4206
|
+
DropdownMenuItem,
|
|
4207
|
+
{
|
|
4208
|
+
onClick: () => setDeleteDialogOpen(true),
|
|
4209
|
+
className: "gap-2 text-destructive focus:text-destructive",
|
|
4210
|
+
children: [
|
|
4211
|
+
/* @__PURE__ */ jsx17(Trash26, { className: "h-4 w-4" }),
|
|
4212
|
+
"Remover"
|
|
4213
|
+
]
|
|
4214
|
+
}
|
|
4215
|
+
)
|
|
4216
|
+
] })
|
|
4217
|
+
] }) })
|
|
4218
|
+
]
|
|
4219
|
+
}
|
|
4220
|
+
),
|
|
4221
|
+
/* @__PURE__ */ jsx17(AlertDialog6, { open: deleteDialogOpen, onOpenChange: setDeleteDialogOpen, children: /* @__PURE__ */ jsxs15(AlertDialogContent6, { children: [
|
|
4222
|
+
/* @__PURE__ */ jsxs15(AlertDialogHeader6, { children: [
|
|
4223
|
+
/* @__PURE__ */ jsx17(AlertDialogTitle6, { children: "Remover integra\xE7\xE3o?" }),
|
|
4224
|
+
/* @__PURE__ */ jsxs15(AlertDialogDescription6, { children: [
|
|
4225
|
+
"Esta a\xE7\xE3o vai remover a credencial",
|
|
4226
|
+
accountLabel ? ` (${accountLabel})` : "",
|
|
4227
|
+
" de ",
|
|
4228
|
+
definition.name,
|
|
4229
|
+
". Esta a\xE7\xE3o n\xE3o pode ser desfeita."
|
|
4429
4230
|
] })
|
|
4430
|
-
]
|
|
4431
|
-
|
|
4432
|
-
|
|
4231
|
+
] }),
|
|
4232
|
+
/* @__PURE__ */ jsxs15(AlertDialogFooter6, { children: [
|
|
4233
|
+
/* @__PURE__ */ jsx17(AlertDialogCancel6, { children: "Cancelar" }),
|
|
4234
|
+
/* @__PURE__ */ jsx17(
|
|
4235
|
+
AlertDialogAction6,
|
|
4236
|
+
{
|
|
4237
|
+
onClick: () => {
|
|
4238
|
+
onDelete?.(card);
|
|
4239
|
+
setDeleteDialogOpen(false);
|
|
4240
|
+
},
|
|
4241
|
+
className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
4242
|
+
children: "Remover"
|
|
4243
|
+
}
|
|
4244
|
+
)
|
|
4245
|
+
] })
|
|
4246
|
+
] }) })
|
|
4247
|
+
] });
|
|
4433
4248
|
}
|
|
4434
4249
|
|
|
4435
4250
|
// src/components/capabilities/advanced-tab.tsx
|
|
4436
|
-
import { useState as
|
|
4251
|
+
import { useState as useState14 } from "react";
|
|
4437
4252
|
import { Info } from "lucide-react";
|
|
4438
4253
|
import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
4439
4254
|
function AdvancedTab({ config, agentId, gagentsApiUrl }) {
|
|
4440
|
-
const [editingTool, setEditingTool] =
|
|
4441
|
-
const [showToolForm, setShowToolForm] =
|
|
4255
|
+
const [editingTool, setEditingTool] = useState14(null);
|
|
4256
|
+
const [showToolForm, setShowToolForm] = useState14(false);
|
|
4442
4257
|
function handleEditTool(tool) {
|
|
4443
4258
|
setEditingTool(tool);
|
|
4444
4259
|
setShowToolForm(true);
|
|
@@ -4475,13 +4290,13 @@ function AdvancedTab({ config, agentId, gagentsApiUrl }) {
|
|
|
4475
4290
|
}
|
|
4476
4291
|
|
|
4477
4292
|
// src/components/capabilities/integration-wizard.tsx
|
|
4478
|
-
import { useCallback as useCallback6, useEffect as useEffect5, useRef as useRef2, useState as
|
|
4293
|
+
import { useCallback as useCallback6, useEffect as useEffect5, useRef as useRef2, useState as useState15 } from "react";
|
|
4479
4294
|
import {
|
|
4480
|
-
Dialog as
|
|
4481
|
-
DialogContent as
|
|
4482
|
-
DialogFooter as
|
|
4483
|
-
DialogHeader as
|
|
4484
|
-
DialogTitle as
|
|
4295
|
+
Dialog as Dialog6,
|
|
4296
|
+
DialogContent as DialogContent6,
|
|
4297
|
+
DialogFooter as DialogFooter6,
|
|
4298
|
+
DialogHeader as DialogHeader6,
|
|
4299
|
+
DialogTitle as DialogTitle6,
|
|
4485
4300
|
Button as Button14
|
|
4486
4301
|
} from "@greatapps/greatauth-ui/ui";
|
|
4487
4302
|
import { Loader2 as Loader29, ChevronLeft, ChevronRight, Check as Check2 } from "lucide-react";
|
|
@@ -4695,11 +4510,11 @@ function ApiKeyCredentials({
|
|
|
4695
4510
|
import { Loader2 as Loader28 } from "lucide-react";
|
|
4696
4511
|
import {
|
|
4697
4512
|
Label as Label7,
|
|
4698
|
-
Select as
|
|
4699
|
-
SelectContent as
|
|
4700
|
-
SelectItem as
|
|
4701
|
-
SelectTrigger as
|
|
4702
|
-
SelectValue as
|
|
4513
|
+
Select as Select3,
|
|
4514
|
+
SelectContent as SelectContent3,
|
|
4515
|
+
SelectItem as SelectItem3,
|
|
4516
|
+
SelectTrigger as SelectTrigger3,
|
|
4517
|
+
SelectValue as SelectValue3
|
|
4703
4518
|
} from "@greatapps/greatauth-ui/ui";
|
|
4704
4519
|
import { jsx as jsx21, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
4705
4520
|
function ConfigStep({
|
|
@@ -4729,9 +4544,9 @@ function ConfigStep({
|
|
|
4729
4544
|
/* @__PURE__ */ jsx21("p", { className: "text-sm text-muted-foreground", children: "Carregando op\xE7\xF5es..." })
|
|
4730
4545
|
] }) : options.length === 0 ? /* @__PURE__ */ jsx21("div", { className: "rounded-lg border border-dashed p-6 text-center", children: /* @__PURE__ */ jsx21("p", { className: "text-sm text-muted-foreground", children: "Nenhuma op\xE7\xE3o dispon\xEDvel. A configura\xE7\xE3o padr\xE3o ser\xE1 usada." }) }) : /* @__PURE__ */ jsxs19("div", { className: "space-y-2", children: [
|
|
4731
4546
|
/* @__PURE__ */ jsx21(Label7, { htmlFor: "integration-config-select", children: label }),
|
|
4732
|
-
/* @__PURE__ */ jsxs19(
|
|
4733
|
-
/* @__PURE__ */ jsx21(
|
|
4734
|
-
/* @__PURE__ */ jsx21(
|
|
4547
|
+
/* @__PURE__ */ jsxs19(Select3, { value: selectedValue, onValueChange, children: [
|
|
4548
|
+
/* @__PURE__ */ jsx21(SelectTrigger3, { id: "integration-config-select", children: /* @__PURE__ */ jsx21(SelectValue3, { placeholder }) }),
|
|
4549
|
+
/* @__PURE__ */ jsx21(SelectContent3, { children: options.map((opt) => /* @__PURE__ */ jsxs19(SelectItem3, { value: opt.id, children: [
|
|
4735
4550
|
/* @__PURE__ */ jsx21("span", { children: opt.label }),
|
|
4736
4551
|
opt.description && /* @__PURE__ */ jsxs19("span", { className: "ml-2 text-xs text-muted-foreground", children: [
|
|
4737
4552
|
"(",
|
|
@@ -4877,18 +4692,18 @@ function IntegrationWizard({
|
|
|
4877
4692
|
existingConfigValue
|
|
4878
4693
|
}) {
|
|
4879
4694
|
const isReconnect = !!existingCredentialId;
|
|
4880
|
-
const [currentStep, setCurrentStep] =
|
|
4695
|
+
const [currentStep, setCurrentStep] = useState15("info");
|
|
4881
4696
|
const currentIndex = STEPS.indexOf(currentStep);
|
|
4882
|
-
const [oauthStatus, setOauthStatus] =
|
|
4883
|
-
const [oauthResult, setOauthResult] =
|
|
4697
|
+
const [oauthStatus, setOauthStatus] = useState15("idle");
|
|
4698
|
+
const [oauthResult, setOauthResult] = useState15(null);
|
|
4884
4699
|
const popupRef = useRef2(null);
|
|
4885
4700
|
const popupPollRef = useRef2(null);
|
|
4886
|
-
const [apiKey, setApiKey] =
|
|
4887
|
-
const [configOptions, setConfigOptions] =
|
|
4888
|
-
const [configLoading, setConfigLoading] =
|
|
4889
|
-
const [selectedConfigValue, setSelectedConfigValue] =
|
|
4890
|
-
const [enableOnComplete, setEnableOnComplete] =
|
|
4891
|
-
const [isSubmitting, setIsSubmitting] =
|
|
4701
|
+
const [apiKey, setApiKey] = useState15("");
|
|
4702
|
+
const [configOptions, setConfigOptions] = useState15([]);
|
|
4703
|
+
const [configLoading, setConfigLoading] = useState15(false);
|
|
4704
|
+
const [selectedConfigValue, setSelectedConfigValue] = useState15("");
|
|
4705
|
+
const [enableOnComplete, setEnableOnComplete] = useState15(true);
|
|
4706
|
+
const [isSubmitting, setIsSubmitting] = useState15(false);
|
|
4892
4707
|
useEffect5(() => {
|
|
4893
4708
|
return () => {
|
|
4894
4709
|
if (popupPollRef.current) {
|
|
@@ -5057,7 +4872,6 @@ function IntegrationWizard({
|
|
|
5057
4872
|
setIsSubmitting(true);
|
|
5058
4873
|
try {
|
|
5059
4874
|
onComplete();
|
|
5060
|
-
onOpenChange(false);
|
|
5061
4875
|
toast11.success(
|
|
5062
4876
|
`${integration.name} ${isReconnect ? "reconectado" : "configurado"} com sucesso!`
|
|
5063
4877
|
);
|
|
@@ -5070,8 +4884,8 @@ function IntegrationWizard({
|
|
|
5070
4884
|
const selectedConfigOption = configOptions.find((o) => o.id === selectedConfigValue) || null;
|
|
5071
4885
|
const isLastStep = currentStep === "confirm";
|
|
5072
4886
|
const effectiveSteps = meta.hasConfigStep ? STEPS : STEPS.filter((s) => s !== "config");
|
|
5073
|
-
return /* @__PURE__ */ jsx23(
|
|
5074
|
-
/* @__PURE__ */ jsx23(
|
|
4887
|
+
return /* @__PURE__ */ jsx23(Dialog6, { open, onOpenChange, children: /* @__PURE__ */ jsxs21(DialogContent6, { className: "sm:max-w-lg", children: [
|
|
4888
|
+
/* @__PURE__ */ jsx23(DialogHeader6, { children: /* @__PURE__ */ jsx23(DialogTitle6, { children: integration.name }) }),
|
|
5075
4889
|
/* @__PURE__ */ jsx23(StepIndicator, { steps: effectiveSteps, currentStep }),
|
|
5076
4890
|
/* @__PURE__ */ jsxs21("div", { className: "min-h-[280px] py-2", children: [
|
|
5077
4891
|
currentStep === "info" && /* @__PURE__ */ jsx23(
|
|
@@ -5115,7 +4929,7 @@ function IntegrationWizard({
|
|
|
5115
4929
|
}
|
|
5116
4930
|
)
|
|
5117
4931
|
] }),
|
|
5118
|
-
/* @__PURE__ */ jsxs21(
|
|
4932
|
+
/* @__PURE__ */ jsxs21(DialogFooter6, { className: "flex-row justify-between sm:justify-between", children: [
|
|
5119
4933
|
/* @__PURE__ */ jsx23("div", { children: currentStep === "info" ? /* @__PURE__ */ jsx23(
|
|
5120
4934
|
Button14,
|
|
5121
4935
|
{
|
|
@@ -5225,7 +5039,7 @@ function StepIndicator({
|
|
|
5225
5039
|
}
|
|
5226
5040
|
|
|
5227
5041
|
// src/pages/agents-page.tsx
|
|
5228
|
-
import { useState as
|
|
5042
|
+
import { useState as useState16 } from "react";
|
|
5229
5043
|
import { Button as Button15 } from "@greatapps/greatauth-ui/ui";
|
|
5230
5044
|
import { Plus as Plus4 } from "lucide-react";
|
|
5231
5045
|
import { jsx as jsx24, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
@@ -5235,7 +5049,7 @@ function AgentsPage({
|
|
|
5235
5049
|
title = "Agentes AI",
|
|
5236
5050
|
subtitle = "Gerencie seus agentes de atendimento inteligente"
|
|
5237
5051
|
}) {
|
|
5238
|
-
const [createOpen, setCreateOpen] =
|
|
5052
|
+
const [createOpen, setCreateOpen] = useState16(false);
|
|
5239
5053
|
return /* @__PURE__ */ jsxs22("div", { className: "flex flex-col gap-4 p-4 md:p-6", children: [
|
|
5240
5054
|
/* @__PURE__ */ jsxs22("div", { className: "flex items-center justify-between", children: [
|
|
5241
5055
|
/* @__PURE__ */ jsxs22("div", { children: [
|
|
@@ -5260,10 +5074,10 @@ function AgentsPage({
|
|
|
5260
5074
|
}
|
|
5261
5075
|
|
|
5262
5076
|
// src/pages/agent-detail-page.tsx
|
|
5263
|
-
import { useState as
|
|
5077
|
+
import { useState as useState17 } from "react";
|
|
5264
5078
|
import { Badge as Badge10, Button as Button16, Skeleton as Skeleton7 } from "@greatapps/greatauth-ui/ui";
|
|
5265
5079
|
import { EntityAvatar as EntityAvatar2 } from "@greatapps/greatauth-ui";
|
|
5266
|
-
import { ArrowLeft, Pencil as
|
|
5080
|
+
import { ArrowLeft, Pencil as Pencil4 } from "lucide-react";
|
|
5267
5081
|
import { jsx as jsx25, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
5268
5082
|
function AgentDetailPage({
|
|
5269
5083
|
config,
|
|
@@ -5272,7 +5086,7 @@ function AgentDetailPage({
|
|
|
5272
5086
|
renderChatLink
|
|
5273
5087
|
}) {
|
|
5274
5088
|
const { data: agent, isLoading } = useAgent(config, agentId);
|
|
5275
|
-
const [editOpen, setEditOpen] =
|
|
5089
|
+
const [editOpen, setEditOpen] = useState17(false);
|
|
5276
5090
|
if (isLoading) {
|
|
5277
5091
|
return /* @__PURE__ */ jsxs23("div", { className: "flex flex-col gap-4 p-4", children: [
|
|
5278
5092
|
/* @__PURE__ */ jsx25(Skeleton7, { className: "h-4 w-32" }),
|
|
@@ -5325,7 +5139,7 @@ function AgentDetailPage({
|
|
|
5325
5139
|
className: "shrink-0 self-start",
|
|
5326
5140
|
onClick: () => setEditOpen(true),
|
|
5327
5141
|
children: [
|
|
5328
|
-
/* @__PURE__ */ jsx25(
|
|
5142
|
+
/* @__PURE__ */ jsx25(Pencil4, { className: "mr-2 h-4 w-4" }),
|
|
5329
5143
|
"Editar"
|
|
5330
5144
|
]
|
|
5331
5145
|
}
|
|
@@ -5401,7 +5215,7 @@ function AgentCapabilitiesPage({
|
|
|
5401
5215
|
}
|
|
5402
5216
|
|
|
5403
5217
|
// src/pages/tools-page.tsx
|
|
5404
|
-
import { useState as
|
|
5218
|
+
import { useState as useState18 } from "react";
|
|
5405
5219
|
import { Button as Button17 } from "@greatapps/greatauth-ui/ui";
|
|
5406
5220
|
import { Plus as Plus5 } from "lucide-react";
|
|
5407
5221
|
import { jsx as jsx27, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
@@ -5410,8 +5224,8 @@ function ToolsPage({
|
|
|
5410
5224
|
title = "Ferramentas",
|
|
5411
5225
|
subtitle = "Gerencie as ferramentas dispon\xEDveis para seus agentes"
|
|
5412
5226
|
}) {
|
|
5413
|
-
const [createOpen, setCreateOpen] =
|
|
5414
|
-
const [editTool, setEditTool] =
|
|
5227
|
+
const [createOpen, setCreateOpen] = useState18(false);
|
|
5228
|
+
const [editTool, setEditTool] = useState18(void 0);
|
|
5415
5229
|
return /* @__PURE__ */ jsxs25("div", { className: "flex flex-col gap-4 p-4 md:p-6", children: [
|
|
5416
5230
|
/* @__PURE__ */ jsxs25("div", { className: "flex items-center justify-between", children: [
|
|
5417
5231
|
/* @__PURE__ */ jsxs25("div", { children: [
|
|
@@ -5445,9 +5259,6 @@ function ToolsPage({
|
|
|
5445
5259
|
}
|
|
5446
5260
|
|
|
5447
5261
|
// src/pages/credentials-page.tsx
|
|
5448
|
-
import { useState as useState18 } from "react";
|
|
5449
|
-
import { Button as Button18 } from "@greatapps/greatauth-ui/ui";
|
|
5450
|
-
import { Plus as Plus6 } from "lucide-react";
|
|
5451
5262
|
import { jsx as jsx28, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
5452
5263
|
function CredentialsPage({
|
|
5453
5264
|
config,
|
|
@@ -5456,85 +5267,63 @@ function CredentialsPage({
|
|
|
5456
5267
|
subtitle = "Gerencie as credenciais de autentica\xE7\xE3o das ferramentas"
|
|
5457
5268
|
}) {
|
|
5458
5269
|
const { data: credentialsData, isLoading: credentialsLoading } = useToolCredentials(config);
|
|
5459
|
-
const [createOpen, setCreateOpen] = useState18(false);
|
|
5460
5270
|
const credentials = credentialsData?.data || [];
|
|
5461
5271
|
return /* @__PURE__ */ jsxs26("div", { className: "flex flex-col gap-4 p-4 md:p-6", children: [
|
|
5462
|
-
/* @__PURE__ */
|
|
5463
|
-
/* @__PURE__ */
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
] }),
|
|
5467
|
-
/* @__PURE__ */ jsxs26(Button18, { onClick: () => setCreateOpen(true), size: "sm", children: [
|
|
5468
|
-
/* @__PURE__ */ jsx28(Plus6, { className: "mr-2 h-4 w-4" }),
|
|
5469
|
-
"Nova Credencial"
|
|
5470
|
-
] })
|
|
5471
|
-
] }),
|
|
5272
|
+
/* @__PURE__ */ jsx28("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsxs26("div", { children: [
|
|
5273
|
+
/* @__PURE__ */ jsx28("h1", { className: "text-xl font-semibold", children: title }),
|
|
5274
|
+
/* @__PURE__ */ jsx28("p", { className: "text-sm text-muted-foreground", children: subtitle })
|
|
5275
|
+
] }) }),
|
|
5472
5276
|
/* @__PURE__ */ jsx28(
|
|
5473
5277
|
ToolCredentialsForm,
|
|
5474
5278
|
{
|
|
5475
5279
|
config,
|
|
5476
5280
|
gagentsApiUrl,
|
|
5477
5281
|
credentials,
|
|
5478
|
-
isLoading: credentialsLoading
|
|
5479
|
-
createOpen,
|
|
5480
|
-
onCreateOpenChange: setCreateOpen
|
|
5282
|
+
isLoading: credentialsLoading
|
|
5481
5283
|
}
|
|
5482
5284
|
)
|
|
5483
5285
|
] });
|
|
5484
5286
|
}
|
|
5485
5287
|
|
|
5486
5288
|
// src/pages/integrations-management-page.tsx
|
|
5487
|
-
import {
|
|
5488
|
-
import {
|
|
5489
|
-
|
|
5490
|
-
Button as Button19,
|
|
5491
|
-
Tabs as Tabs3,
|
|
5492
|
-
TabsContent as TabsContent3,
|
|
5493
|
-
TabsList as TabsList3,
|
|
5494
|
-
TabsTrigger as TabsTrigger3
|
|
5495
|
-
} from "@greatapps/greatauth-ui/ui";
|
|
5496
|
-
import { Plus as Plus7, Plug as Plug5, KeyRound, Info as Info3, Loader2 as Loader210 } from "lucide-react";
|
|
5289
|
+
import { useCallback as useCallback7, useState as useState19 } from "react";
|
|
5290
|
+
import { useQueryClient as useQueryClient7 } from "@tanstack/react-query";
|
|
5291
|
+
import { Plug as Plug5, Loader2 as Loader210 } from "lucide-react";
|
|
5497
5292
|
import { jsx as jsx29, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
5498
|
-
function useCredentialAgentSummary(credentials, tools, agents) {
|
|
5499
|
-
return useMemo8(() => {
|
|
5500
|
-
const toolIdsWithCredentials = new Set(
|
|
5501
|
-
credentials.map((c) => c.id_tool).filter(Boolean)
|
|
5502
|
-
);
|
|
5503
|
-
const linkedCount = credentials.filter(
|
|
5504
|
-
(c) => c.id_tool && toolIdsWithCredentials.has(c.id_tool)
|
|
5505
|
-
).length;
|
|
5506
|
-
return {
|
|
5507
|
-
totalCredentials: credentials.length,
|
|
5508
|
-
linkedToTools: linkedCount,
|
|
5509
|
-
totalAgents: agents.length,
|
|
5510
|
-
totalTools: tools.length
|
|
5511
|
-
};
|
|
5512
|
-
}, [credentials, tools, agents]);
|
|
5513
|
-
}
|
|
5514
5293
|
function IntegrationsManagementPage({
|
|
5515
5294
|
config,
|
|
5516
5295
|
gagentsApiUrl,
|
|
5517
5296
|
resolveWizardMeta,
|
|
5518
5297
|
loadConfigOptions,
|
|
5519
5298
|
onWizardComplete,
|
|
5520
|
-
title = "Integra\xE7\xF5es
|
|
5521
|
-
subtitle = "Gerencie
|
|
5299
|
+
title = "Integra\xE7\xF5es",
|
|
5300
|
+
subtitle = "Gerencie as integra\xE7\xF5es da conta."
|
|
5522
5301
|
}) {
|
|
5523
|
-
const
|
|
5524
|
-
const { data: agentsData } = useAgents(config);
|
|
5525
|
-
const { data: toolsData } = useTools(config);
|
|
5526
|
-
const [createOpen, setCreateOpen] = useState19(false);
|
|
5302
|
+
const queryClient = useQueryClient7();
|
|
5527
5303
|
const { cards, isLoading: cardsLoading } = useIntegrationState(config, null);
|
|
5528
5304
|
const [wizardOpen, setWizardOpen] = useState19(false);
|
|
5529
5305
|
const [activeCard, setActiveCard] = useState19(null);
|
|
5530
|
-
const
|
|
5531
|
-
const
|
|
5532
|
-
const tools = toolsData?.data || [];
|
|
5533
|
-
const summary = useCredentialAgentSummary(credentials, tools, agents);
|
|
5306
|
+
const deleteCredential = useDeleteToolCredential(config);
|
|
5307
|
+
const updateCredential = useUpdateToolCredential(config);
|
|
5534
5308
|
const handleConnect = useCallback7((card) => {
|
|
5535
5309
|
setActiveCard(card);
|
|
5536
5310
|
setWizardOpen(true);
|
|
5537
5311
|
}, []);
|
|
5312
|
+
const handleReconnect = useCallback7((card) => {
|
|
5313
|
+
setActiveCard(card);
|
|
5314
|
+
setWizardOpen(true);
|
|
5315
|
+
}, []);
|
|
5316
|
+
const handleDisconnect = useCallback7((card) => {
|
|
5317
|
+
if (!card.credentialId) return;
|
|
5318
|
+
updateCredential.mutate({
|
|
5319
|
+
id: card.credentialId,
|
|
5320
|
+
body: { status: "inactive" }
|
|
5321
|
+
});
|
|
5322
|
+
}, [updateCredential]);
|
|
5323
|
+
const handleDelete = useCallback7((card) => {
|
|
5324
|
+
if (!card.credentialId) return;
|
|
5325
|
+
deleteCredential.mutate(card.credentialId);
|
|
5326
|
+
}, [deleteCredential]);
|
|
5538
5327
|
const handleWizardClose = useCallback7((open) => {
|
|
5539
5328
|
if (!open) {
|
|
5540
5329
|
setActiveCard(null);
|
|
@@ -5542,10 +5331,13 @@ function IntegrationsManagementPage({
|
|
|
5542
5331
|
setWizardOpen(open);
|
|
5543
5332
|
}, []);
|
|
5544
5333
|
const handleWizardComplete = useCallback7(() => {
|
|
5334
|
+
queryClient.invalidateQueries({ queryKey: ["greatagents", "tool-credentials"] });
|
|
5335
|
+
queryClient.invalidateQueries({ queryKey: ["greatagents", "tools"] });
|
|
5336
|
+
queryClient.invalidateQueries({ queryKey: ["greatagents", "agent-tools"] });
|
|
5545
5337
|
setWizardOpen(false);
|
|
5546
5338
|
setActiveCard(null);
|
|
5547
5339
|
onWizardComplete?.();
|
|
5548
|
-
}, [onWizardComplete]);
|
|
5340
|
+
}, [onWizardComplete, queryClient]);
|
|
5549
5341
|
const wizardMeta = activeCard ? resolveWizardMeta?.(activeCard) ?? {
|
|
5550
5342
|
capabilities: [],
|
|
5551
5343
|
requirements: [],
|
|
@@ -5562,82 +5354,37 @@ function IntegrationsManagementPage({
|
|
|
5562
5354
|
/* @__PURE__ */ jsx29("h1", { className: "text-xl font-semibold", children: title }),
|
|
5563
5355
|
/* @__PURE__ */ jsx29("p", { className: "text-sm text-muted-foreground", children: subtitle })
|
|
5564
5356
|
] }) }),
|
|
5565
|
-
/* @__PURE__ */
|
|
5566
|
-
/* @__PURE__ */
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
/* @__PURE__ */
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5357
|
+
cardsLoading ? /* @__PURE__ */ jsx29("div", { className: "flex items-center justify-center py-16", children: /* @__PURE__ */ jsx29(Loader210, { className: "h-6 w-6 animate-spin text-muted-foreground" }) }) : cards.length === 0 ? /* @__PURE__ */ jsxs27("div", { className: "flex flex-col items-center justify-center gap-3 py-16 text-muted-foreground", children: [
|
|
5358
|
+
/* @__PURE__ */ jsx29(Plug5, { className: "h-10 w-10" }),
|
|
5359
|
+
/* @__PURE__ */ jsx29("p", { className: "text-sm", children: "Nenhuma integra\xE7\xE3o dispon\xEDvel" })
|
|
5360
|
+
] }) : /* @__PURE__ */ jsxs27("div", { className: "space-y-6", children: [
|
|
5361
|
+
connectedCards.length > 0 && /* @__PURE__ */ jsxs27("div", { children: [
|
|
5362
|
+
/* @__PURE__ */ jsx29("h3", { className: "mb-3 text-xs font-medium uppercase tracking-wider text-muted-foreground", children: "Contas conectadas" }),
|
|
5363
|
+
/* @__PURE__ */ jsx29("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3", children: connectedCards.map((card) => /* @__PURE__ */ jsx29(
|
|
5364
|
+
IntegrationCard,
|
|
5365
|
+
{
|
|
5366
|
+
card,
|
|
5367
|
+
onConnect: handleConnect,
|
|
5368
|
+
onReconnect: handleReconnect,
|
|
5369
|
+
onDisconnect: handleDisconnect,
|
|
5370
|
+
onDelete: handleDelete
|
|
5371
|
+
},
|
|
5372
|
+
`${card.definition.slug}-cred-${card.credentialId}`
|
|
5373
|
+
)) })
|
|
5575
5374
|
] }),
|
|
5576
|
-
|
|
5577
|
-
/* @__PURE__ */ jsx29(
|
|
5578
|
-
/* @__PURE__ */ jsx29("
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
/* @__PURE__ */ jsx29("h3", { className: "mb-3 text-xs font-medium uppercase tracking-wider text-muted-foreground", children: "Contas conectadas" }),
|
|
5582
|
-
/* @__PURE__ */ jsx29("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3", children: connectedCards.map((card) => /* @__PURE__ */ jsx29(
|
|
5375
|
+
otherCards.length > 0 && /* @__PURE__ */ jsxs27("div", { children: [
|
|
5376
|
+
connectedCards.length > 0 && /* @__PURE__ */ jsx29("h3", { className: "mb-3 text-xs font-medium uppercase tracking-wider text-muted-foreground", children: "Adicionar integra\xE7\xE3o" }),
|
|
5377
|
+
/* @__PURE__ */ jsx29("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3", children: otherCards.map((card) => {
|
|
5378
|
+
const key = card.isAddNew ? `${card.definition.slug}-add-new` : card.definition.slug;
|
|
5379
|
+
return /* @__PURE__ */ jsx29(
|
|
5583
5380
|
IntegrationCard,
|
|
5584
5381
|
{
|
|
5585
5382
|
card,
|
|
5586
5383
|
onConnect: handleConnect
|
|
5587
5384
|
},
|
|
5588
|
-
|
|
5589
|
-
)
|
|
5590
|
-
|
|
5591
|
-
otherCards.length > 0 && /* @__PURE__ */ jsxs27("div", { children: [
|
|
5592
|
-
connectedCards.length > 0 && /* @__PURE__ */ jsx29("h3", { className: "mb-3 text-xs font-medium uppercase tracking-wider text-muted-foreground", children: "Adicionar integra\xE7\xE3o" }),
|
|
5593
|
-
/* @__PURE__ */ jsx29("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3", children: otherCards.map((card) => {
|
|
5594
|
-
const key = card.isAddNew ? `${card.definition.slug}-add-new` : card.definition.slug;
|
|
5595
|
-
return /* @__PURE__ */ jsx29(
|
|
5596
|
-
IntegrationCard,
|
|
5597
|
-
{
|
|
5598
|
-
card,
|
|
5599
|
-
onConnect: handleConnect
|
|
5600
|
-
},
|
|
5601
|
-
key
|
|
5602
|
-
);
|
|
5603
|
-
}) })
|
|
5604
|
-
] })
|
|
5605
|
-
] }) }),
|
|
5606
|
-
/* @__PURE__ */ jsxs27(TabsContent3, { value: "credentials", className: "mt-4", children: [
|
|
5607
|
-
!credentialsLoading && /* @__PURE__ */ jsxs27("div", { className: "flex items-center gap-4 rounded-lg border bg-muted/50 px-4 py-3 mb-4", children: [
|
|
5608
|
-
/* @__PURE__ */ jsx29(Info3, { className: "h-4 w-4 text-muted-foreground shrink-0" }),
|
|
5609
|
-
/* @__PURE__ */ jsxs27("div", { className: "flex flex-wrap items-center gap-3 text-sm", children: [
|
|
5610
|
-
/* @__PURE__ */ jsxs27("span", { children: [
|
|
5611
|
-
/* @__PURE__ */ jsx29(Badge11, { variant: "secondary", className: "mr-1", children: summary.totalCredentials }),
|
|
5612
|
-
summary.totalCredentials === 1 ? "credencial configurada" : "credenciais configuradas"
|
|
5613
|
-
] }),
|
|
5614
|
-
/* @__PURE__ */ jsx29("span", { className: "text-muted-foreground", children: "|" }),
|
|
5615
|
-
/* @__PURE__ */ jsxs27("span", { children: [
|
|
5616
|
-
/* @__PURE__ */ jsx29(Badge11, { variant: "secondary", className: "mr-1", children: summary.linkedToTools }),
|
|
5617
|
-
summary.linkedToTools === 1 ? "vinculada a ferramentas" : "vinculadas a ferramentas"
|
|
5618
|
-
] }),
|
|
5619
|
-
/* @__PURE__ */ jsx29("span", { className: "text-muted-foreground", children: "|" }),
|
|
5620
|
-
/* @__PURE__ */ jsxs27("span", { children: [
|
|
5621
|
-
/* @__PURE__ */ jsx29(Badge11, { variant: "secondary", className: "mr-1", children: summary.totalAgents }),
|
|
5622
|
-
summary.totalAgents === 1 ? "agente na conta" : "agentes na conta"
|
|
5623
|
-
] })
|
|
5624
|
-
] })
|
|
5625
|
-
] }),
|
|
5626
|
-
/* @__PURE__ */ jsx29("div", { className: "flex items-center justify-end mb-4", children: /* @__PURE__ */ jsxs27(Button19, { onClick: () => setCreateOpen(true), size: "sm", children: [
|
|
5627
|
-
/* @__PURE__ */ jsx29(Plus7, { className: "mr-2 h-4 w-4" }),
|
|
5628
|
-
"Nova Credencial"
|
|
5629
|
-
] }) }),
|
|
5630
|
-
/* @__PURE__ */ jsx29(
|
|
5631
|
-
ToolCredentialsForm,
|
|
5632
|
-
{
|
|
5633
|
-
config,
|
|
5634
|
-
gagentsApiUrl,
|
|
5635
|
-
credentials,
|
|
5636
|
-
isLoading: credentialsLoading,
|
|
5637
|
-
createOpen,
|
|
5638
|
-
onCreateOpenChange: setCreateOpen
|
|
5639
|
-
}
|
|
5640
|
-
)
|
|
5385
|
+
key
|
|
5386
|
+
);
|
|
5387
|
+
}) })
|
|
5641
5388
|
] })
|
|
5642
5389
|
] }),
|
|
5643
5390
|
activeCard && wizardMeta && /* @__PURE__ */ jsx29(
|