@greatapps/greatagents-ui 0.3.20 → 0.3.22
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 +52 -16
- package/dist/index.js +1449 -1109
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client/index.ts +4 -4
- package/src/components/agents/agent-definition-editor.tsx +305 -0
- package/src/components/agents/agent-objectives-list.tsx +76 -62
- package/src/components/agents/agent-revision-tab.tsx +368 -0
- package/src/components/agents/agent-tabs.tsx +17 -8
- package/src/components/agents/conversation-flow-editor.tsx +180 -0
- package/src/components/capabilities/integrations-tab.tsx +11 -6
- package/src/hooks/use-agents.ts +7 -2
- package/src/hooks/use-objectives.ts +8 -2
- package/src/index.ts +4 -1
- package/src/types/index.ts +16 -1
- package/src/components/agents/agent-prompt-editor.tsx +0 -442
package/dist/index.js
CHANGED
|
@@ -1143,10 +1143,10 @@ function AgentEditForm({ config, agent, idAccount, open, onOpenChange }) {
|
|
|
1143
1143
|
}
|
|
1144
1144
|
|
|
1145
1145
|
// src/components/agents/agent-objectives-list.tsx
|
|
1146
|
-
import { useState as
|
|
1146
|
+
import { useState as useState6 } from "react";
|
|
1147
1147
|
import {
|
|
1148
|
-
Input as
|
|
1149
|
-
Button as
|
|
1148
|
+
Input as Input5,
|
|
1149
|
+
Button as Button5,
|
|
1150
1150
|
Switch as Switch3,
|
|
1151
1151
|
Skeleton,
|
|
1152
1152
|
Textarea,
|
|
@@ -1630,39 +1630,163 @@ function SortableOverlay(props) {
|
|
|
1630
1630
|
);
|
|
1631
1631
|
}
|
|
1632
1632
|
|
|
1633
|
+
// src/components/agents/conversation-flow-editor.tsx
|
|
1634
|
+
import { useCallback as useCallback3, useRef, useState as useState5 } from "react";
|
|
1635
|
+
import { Button as Button4, Input as Input4 } from "@greatapps/greatauth-ui/ui";
|
|
1636
|
+
import { GripVertical, Plus, Trash2 as Trash22 } from "lucide-react";
|
|
1637
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1638
|
+
function renumber(steps) {
|
|
1639
|
+
return steps.map((s, i) => ({ ...s, order: i + 1 }));
|
|
1640
|
+
}
|
|
1641
|
+
function stripKeys(steps) {
|
|
1642
|
+
return steps.map(({ _key, ...rest }) => rest);
|
|
1643
|
+
}
|
|
1644
|
+
function ConversationFlowEditor({
|
|
1645
|
+
steps,
|
|
1646
|
+
onChange
|
|
1647
|
+
}) {
|
|
1648
|
+
const nextKey = useRef(steps.length + 1);
|
|
1649
|
+
const [internal, setInternal] = useState5(
|
|
1650
|
+
() => steps.map((s, i) => ({ ...s, _key: i + 1 }))
|
|
1651
|
+
);
|
|
1652
|
+
const sync = useCallback3(
|
|
1653
|
+
(next) => {
|
|
1654
|
+
const renumbered = renumber(next).map((s, i) => ({
|
|
1655
|
+
...s,
|
|
1656
|
+
_key: next[i]._key
|
|
1657
|
+
}));
|
|
1658
|
+
setInternal(renumbered);
|
|
1659
|
+
onChange(stripKeys(renumbered));
|
|
1660
|
+
},
|
|
1661
|
+
[onChange]
|
|
1662
|
+
);
|
|
1663
|
+
function handleAdd() {
|
|
1664
|
+
nextKey.current += 1;
|
|
1665
|
+
const newStep = {
|
|
1666
|
+
order: internal.length + 1,
|
|
1667
|
+
instruction: "",
|
|
1668
|
+
example: null,
|
|
1669
|
+
_key: nextKey.current
|
|
1670
|
+
};
|
|
1671
|
+
sync([...internal, newStep]);
|
|
1672
|
+
}
|
|
1673
|
+
function handleRemove(key) {
|
|
1674
|
+
sync(internal.filter((s) => s._key !== key));
|
|
1675
|
+
}
|
|
1676
|
+
function handleFieldChange(key, field, value) {
|
|
1677
|
+
const next = internal.map((s) => {
|
|
1678
|
+
if (s._key !== key) return s;
|
|
1679
|
+
if (field === "example") {
|
|
1680
|
+
return { ...s, example: value || null };
|
|
1681
|
+
}
|
|
1682
|
+
return { ...s, [field]: value };
|
|
1683
|
+
});
|
|
1684
|
+
sync(next);
|
|
1685
|
+
}
|
|
1686
|
+
function handleReorder(newItems) {
|
|
1687
|
+
sync(newItems);
|
|
1688
|
+
}
|
|
1689
|
+
return /* @__PURE__ */ jsxs4("div", { className: "space-y-3", children: [
|
|
1690
|
+
internal.length === 0 ? /* @__PURE__ */ jsx5("div", { className: "flex flex-col items-center justify-center rounded-lg border border-dashed p-8 text-center", children: /* @__PURE__ */ jsx5("p", { className: "text-sm text-muted-foreground", children: "Nenhuma etapa definida. Adicione a primeira etapa do fluxo de conversa." }) }) : /* @__PURE__ */ jsxs4(
|
|
1691
|
+
Sortable,
|
|
1692
|
+
{
|
|
1693
|
+
value: internal,
|
|
1694
|
+
onValueChange: handleReorder,
|
|
1695
|
+
getItemValue: (item) => item._key,
|
|
1696
|
+
children: [
|
|
1697
|
+
/* @__PURE__ */ jsx5(SortableContent, { className: "space-y-2", children: internal.map((step) => /* @__PURE__ */ jsxs4(
|
|
1698
|
+
SortableItem,
|
|
1699
|
+
{
|
|
1700
|
+
value: step._key,
|
|
1701
|
+
className: "flex items-center gap-2 rounded-lg border bg-card p-2",
|
|
1702
|
+
children: [
|
|
1703
|
+
/* @__PURE__ */ jsx5(SortableItemHandle, { className: "shrink-0 cursor-grab text-muted-foreground hover:text-foreground", children: /* @__PURE__ */ jsx5(GripVertical, { "aria-hidden": "true", className: "h-4 w-4" }) }),
|
|
1704
|
+
/* @__PURE__ */ jsxs4("span", { className: "shrink-0 text-xs font-medium text-muted-foreground tabular-nums w-6 text-right", children: [
|
|
1705
|
+
step.order,
|
|
1706
|
+
"."
|
|
1707
|
+
] }),
|
|
1708
|
+
/* @__PURE__ */ jsx5(
|
|
1709
|
+
Input4,
|
|
1710
|
+
{
|
|
1711
|
+
value: step.instruction,
|
|
1712
|
+
onChange: (e) => handleFieldChange(step._key, "instruction", e.target.value),
|
|
1713
|
+
placeholder: "Instru\xE7\xE3o (obrigat\xF3rio)",
|
|
1714
|
+
className: "flex-1 min-w-0",
|
|
1715
|
+
required: true
|
|
1716
|
+
}
|
|
1717
|
+
),
|
|
1718
|
+
/* @__PURE__ */ jsx5(
|
|
1719
|
+
Input4,
|
|
1720
|
+
{
|
|
1721
|
+
value: step.example ?? "",
|
|
1722
|
+
onChange: (e) => handleFieldChange(step._key, "example", e.target.value),
|
|
1723
|
+
placeholder: "Exemplo (opcional)",
|
|
1724
|
+
className: "flex-1 min-w-0"
|
|
1725
|
+
}
|
|
1726
|
+
),
|
|
1727
|
+
/* @__PURE__ */ jsx5(
|
|
1728
|
+
Button4,
|
|
1729
|
+
{
|
|
1730
|
+
type: "button",
|
|
1731
|
+
variant: "ghost",
|
|
1732
|
+
size: "icon",
|
|
1733
|
+
"aria-label": "Remover etapa",
|
|
1734
|
+
className: cn(
|
|
1735
|
+
"shrink-0 text-muted-foreground hover:text-destructive"
|
|
1736
|
+
),
|
|
1737
|
+
onClick: () => handleRemove(step._key),
|
|
1738
|
+
children: /* @__PURE__ */ jsx5(Trash22, { className: "h-4 w-4" })
|
|
1739
|
+
}
|
|
1740
|
+
)
|
|
1741
|
+
]
|
|
1742
|
+
},
|
|
1743
|
+
step._key
|
|
1744
|
+
)) }),
|
|
1745
|
+
/* @__PURE__ */ jsx5(SortableOverlay, { children: ({ value }) => {
|
|
1746
|
+
const step = internal.find((s) => s._key === value);
|
|
1747
|
+
return /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2 rounded-lg border bg-card p-2 shadow-lg", children: [
|
|
1748
|
+
/* @__PURE__ */ jsx5(
|
|
1749
|
+
GripVertical,
|
|
1750
|
+
{
|
|
1751
|
+
"aria-hidden": "true",
|
|
1752
|
+
className: "h-4 w-4 text-muted-foreground"
|
|
1753
|
+
}
|
|
1754
|
+
),
|
|
1755
|
+
/* @__PURE__ */ jsxs4("span", { className: "text-xs font-medium text-muted-foreground", children: [
|
|
1756
|
+
step?.order,
|
|
1757
|
+
"."
|
|
1758
|
+
] }),
|
|
1759
|
+
/* @__PURE__ */ jsx5("span", { className: "text-sm truncate", children: step?.instruction || "Etapa sem instru\xE7\xE3o" })
|
|
1760
|
+
] });
|
|
1761
|
+
} })
|
|
1762
|
+
]
|
|
1763
|
+
}
|
|
1764
|
+
),
|
|
1765
|
+
/* @__PURE__ */ jsxs4(Button4, { type: "button", variant: "outline", size: "sm", onClick: handleAdd, children: [
|
|
1766
|
+
/* @__PURE__ */ jsx5(Plus, { className: "mr-2 h-4 w-4" }),
|
|
1767
|
+
"Adicionar etapa"
|
|
1768
|
+
] })
|
|
1769
|
+
] });
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1633
1772
|
// src/components/agents/agent-objectives-list.tsx
|
|
1634
|
-
import { Trash2 as
|
|
1773
|
+
import { Trash2 as Trash23, Target, Pencil as Pencil2, Plus as Plus2, GripVertical as GripVertical2 } from "lucide-react";
|
|
1635
1774
|
import { toast as toast4 } from "sonner";
|
|
1636
|
-
import { jsx as
|
|
1775
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1637
1776
|
function slugify(text) {
|
|
1638
1777
|
return text.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
1639
1778
|
}
|
|
1640
|
-
var EMPTY_FORM = { title: "", slug: "", instruction: "",
|
|
1641
|
-
function splitPrompt(prompt) {
|
|
1642
|
-
if (!prompt) return { instruction: "", body: "" };
|
|
1643
|
-
const idx = prompt.indexOf("\n");
|
|
1644
|
-
if (idx === -1) return { instruction: prompt.trim(), body: "" };
|
|
1645
|
-
return { instruction: prompt.slice(0, idx).trim(), body: prompt.slice(idx + 1).trim() };
|
|
1646
|
-
}
|
|
1647
|
-
function mergePrompt(instruction, body) {
|
|
1648
|
-
const i = instruction.trim();
|
|
1649
|
-
const b = body.trim();
|
|
1650
|
-
if (!i && !b) return "";
|
|
1651
|
-
if (!b) return i;
|
|
1652
|
-
if (!i) return b;
|
|
1653
|
-
return `${i}
|
|
1654
|
-
${b}`;
|
|
1655
|
-
}
|
|
1779
|
+
var EMPTY_FORM = { title: "", slug: "", instruction: "", description: "", conversation_flow: [], rules: "" };
|
|
1656
1780
|
function AgentObjectivesList({ agent, config }) {
|
|
1657
1781
|
const { data: objectivesData, isLoading } = useObjectives(config, agent.id);
|
|
1658
1782
|
const createMutation = useCreateObjective(config);
|
|
1659
1783
|
const updateMutation = useUpdateObjective(config);
|
|
1660
1784
|
const deleteMutation = useDeleteObjective(config);
|
|
1661
|
-
const [formOpen, setFormOpen] =
|
|
1662
|
-
const [editTarget, setEditTarget] =
|
|
1663
|
-
const [form, setForm] =
|
|
1664
|
-
const [slugManual, setSlugManual] =
|
|
1665
|
-
const [removeTarget, setRemoveTarget] =
|
|
1785
|
+
const [formOpen, setFormOpen] = useState6(false);
|
|
1786
|
+
const [editTarget, setEditTarget] = useState6(null);
|
|
1787
|
+
const [form, setForm] = useState6(EMPTY_FORM);
|
|
1788
|
+
const [slugManual, setSlugManual] = useState6(false);
|
|
1789
|
+
const [removeTarget, setRemoveTarget] = useState6(null);
|
|
1666
1790
|
const objectives = objectivesData?.data || [];
|
|
1667
1791
|
const sortedObjectives = [...objectives].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
1668
1792
|
async function handleReorder(newItems) {
|
|
@@ -1688,12 +1812,20 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
1688
1812
|
}
|
|
1689
1813
|
function openEdit(objective) {
|
|
1690
1814
|
setEditTarget(objective);
|
|
1691
|
-
|
|
1815
|
+
let parsedFlow = [];
|
|
1816
|
+
if (objective.conversation_flow) {
|
|
1817
|
+
try {
|
|
1818
|
+
parsedFlow = JSON.parse(objective.conversation_flow);
|
|
1819
|
+
} catch {
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1692
1822
|
setForm({
|
|
1693
1823
|
title: objective.title,
|
|
1694
1824
|
slug: objective.slug || "",
|
|
1695
|
-
instruction,
|
|
1696
|
-
|
|
1825
|
+
instruction: objective.instruction || "",
|
|
1826
|
+
description: objective.description || "",
|
|
1827
|
+
conversation_flow: parsedFlow,
|
|
1828
|
+
rules: objective.rules || ""
|
|
1697
1829
|
});
|
|
1698
1830
|
setSlugManual(true);
|
|
1699
1831
|
setFormOpen(true);
|
|
@@ -1701,29 +1833,27 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
1701
1833
|
async function handleSubmit() {
|
|
1702
1834
|
if (!form.title.trim()) return;
|
|
1703
1835
|
const effectiveSlug = form.slug.trim() || slugify(form.title);
|
|
1704
|
-
const mergedPrompt = mergePrompt(form.instruction, form.prompt) || null;
|
|
1705
1836
|
const nextOrder = sortedObjectives.length > 0 ? Math.max(...sortedObjectives.map((o) => o.order)) + 1 : 1;
|
|
1706
1837
|
try {
|
|
1838
|
+
const bodyFields = {
|
|
1839
|
+
title: form.title.trim(),
|
|
1840
|
+
slug: effectiveSlug,
|
|
1841
|
+
instruction: form.instruction.trim() || null,
|
|
1842
|
+
description: form.description.trim() || null,
|
|
1843
|
+
conversation_flow: form.conversation_flow.length > 0 ? JSON.stringify(form.conversation_flow) : null,
|
|
1844
|
+
rules: form.rules.trim() || null
|
|
1845
|
+
};
|
|
1707
1846
|
if (editTarget) {
|
|
1708
1847
|
await updateMutation.mutateAsync({
|
|
1709
1848
|
idAgent: agent.id,
|
|
1710
1849
|
id: editTarget.id,
|
|
1711
|
-
body:
|
|
1712
|
-
title: form.title.trim(),
|
|
1713
|
-
slug: effectiveSlug,
|
|
1714
|
-
prompt: mergedPrompt
|
|
1715
|
-
}
|
|
1850
|
+
body: bodyFields
|
|
1716
1851
|
});
|
|
1717
1852
|
toast4.success("Objetivo atualizado");
|
|
1718
1853
|
} else {
|
|
1719
1854
|
await createMutation.mutateAsync({
|
|
1720
1855
|
idAgent: agent.id,
|
|
1721
|
-
body: {
|
|
1722
|
-
title: form.title.trim(),
|
|
1723
|
-
slug: effectiveSlug,
|
|
1724
|
-
prompt: mergedPrompt,
|
|
1725
|
-
order: nextOrder
|
|
1726
|
-
}
|
|
1856
|
+
body: { ...bodyFields, order: nextOrder }
|
|
1727
1857
|
});
|
|
1728
1858
|
toast4.success("Objetivo criado");
|
|
1729
1859
|
}
|
|
@@ -1765,59 +1895,56 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
1765
1895
|
}
|
|
1766
1896
|
}
|
|
1767
1897
|
if (isLoading) {
|
|
1768
|
-
return /* @__PURE__ */
|
|
1898
|
+
return /* @__PURE__ */ jsx6("div", { className: "space-y-3 p-4", children: Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ jsx6(Skeleton, { className: "h-14 w-full" }, i)) });
|
|
1769
1899
|
}
|
|
1770
|
-
return /* @__PURE__ */
|
|
1771
|
-
/* @__PURE__ */
|
|
1772
|
-
/* @__PURE__ */
|
|
1773
|
-
/* @__PURE__ */
|
|
1900
|
+
return /* @__PURE__ */ jsxs5("div", { className: "space-y-4 p-4", children: [
|
|
1901
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between", children: [
|
|
1902
|
+
/* @__PURE__ */ jsxs5("div", { children: [
|
|
1903
|
+
/* @__PURE__ */ jsxs5("h3", { className: "text-sm font-medium text-muted-foreground", children: [
|
|
1774
1904
|
sortedObjectives.length,
|
|
1775
1905
|
" objetivo",
|
|
1776
1906
|
sortedObjectives.length !== 1 ? "s" : "",
|
|
1777
1907
|
" definido",
|
|
1778
1908
|
sortedObjectives.length !== 1 ? "s" : ""
|
|
1779
1909
|
] }),
|
|
1780
|
-
/* @__PURE__ */
|
|
1910
|
+
/* @__PURE__ */ jsx6("p", { className: "text-xs text-muted-foreground", children: "Objetivos s\xE3o modos de conversa que o agente ativa automaticamente conforme a inten\xE7\xE3o do utilizador." })
|
|
1781
1911
|
] }),
|
|
1782
|
-
/* @__PURE__ */
|
|
1783
|
-
/* @__PURE__ */
|
|
1912
|
+
/* @__PURE__ */ jsxs5(Button5, { onClick: openCreate, size: "sm", children: [
|
|
1913
|
+
/* @__PURE__ */ jsx6(Plus2, { className: "mr-2 h-4 w-4" }),
|
|
1784
1914
|
"Novo Objetivo"
|
|
1785
1915
|
] })
|
|
1786
1916
|
] }),
|
|
1787
|
-
sortedObjectives.length === 0 ? /* @__PURE__ */
|
|
1788
|
-
/* @__PURE__ */
|
|
1789
|
-
/* @__PURE__ */
|
|
1790
|
-
] }) : /* @__PURE__ */
|
|
1917
|
+
sortedObjectives.length === 0 ? /* @__PURE__ */ jsxs5("div", { className: "flex flex-col items-center justify-center rounded-lg border border-dashed p-8 text-center", children: [
|
|
1918
|
+
/* @__PURE__ */ jsx6(Target, { className: "mb-2 h-8 w-8 text-muted-foreground" }),
|
|
1919
|
+
/* @__PURE__ */ jsx6("p", { className: "text-sm text-muted-foreground", children: "Nenhum objetivo definido. Adicione objetivos para orientar o agente em diferentes contextos." })
|
|
1920
|
+
] }) : /* @__PURE__ */ jsxs5(
|
|
1791
1921
|
Sortable,
|
|
1792
1922
|
{
|
|
1793
1923
|
value: sortedObjectives,
|
|
1794
1924
|
onValueChange: handleReorder,
|
|
1795
1925
|
getItemValue: (item) => item.id,
|
|
1796
1926
|
children: [
|
|
1797
|
-
/* @__PURE__ */
|
|
1927
|
+
/* @__PURE__ */ jsx6(SortableContent, { className: "space-y-2", children: sortedObjectives.map((objective) => /* @__PURE__ */ jsxs5(
|
|
1798
1928
|
SortableItem,
|
|
1799
1929
|
{
|
|
1800
1930
|
value: objective.id,
|
|
1801
1931
|
className: "flex items-center gap-3 rounded-lg border bg-card p-3",
|
|
1802
1932
|
children: [
|
|
1803
|
-
/* @__PURE__ */
|
|
1804
|
-
/* @__PURE__ */
|
|
1805
|
-
/* @__PURE__ */
|
|
1806
|
-
/* @__PURE__ */
|
|
1807
|
-
objective.slug && /* @__PURE__ */
|
|
1933
|
+
/* @__PURE__ */ jsx6(SortableItemHandle, { className: "shrink-0 text-muted-foreground hover:text-foreground", children: /* @__PURE__ */ jsx6(GripVertical2, { "aria-hidden": "true", className: "h-5 w-5" }) }),
|
|
1934
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex flex-1 flex-col gap-1 min-w-0", children: [
|
|
1935
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2", children: [
|
|
1936
|
+
/* @__PURE__ */ jsx6("span", { className: "truncate font-medium", children: objective.title }),
|
|
1937
|
+
objective.slug && /* @__PURE__ */ jsx6(Badge2, { variant: "secondary", className: "shrink-0 text-xs font-mono", children: objective.slug })
|
|
1808
1938
|
] }),
|
|
1809
|
-
objective.
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
instruction
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
body && /* @__PURE__ */ jsx5("p", { className: "line-clamp-1 text-xs text-muted-foreground", children: body })
|
|
1817
|
-
] });
|
|
1818
|
-
})()
|
|
1939
|
+
(objective.instruction || objective.description) && /* @__PURE__ */ jsxs5("div", { className: "space-y-0.5", children: [
|
|
1940
|
+
objective.instruction && /* @__PURE__ */ jsxs5("p", { className: "text-xs font-medium text-muted-foreground", children: [
|
|
1941
|
+
"Quando: ",
|
|
1942
|
+
objective.instruction
|
|
1943
|
+
] }),
|
|
1944
|
+
objective.description && /* @__PURE__ */ jsx6("p", { className: "line-clamp-1 text-xs text-muted-foreground", children: objective.description })
|
|
1945
|
+
] })
|
|
1819
1946
|
] }),
|
|
1820
|
-
/* @__PURE__ */
|
|
1947
|
+
/* @__PURE__ */ jsx6(
|
|
1821
1948
|
Switch3,
|
|
1822
1949
|
{
|
|
1823
1950
|
"aria-label": "Ativar/Desativar",
|
|
@@ -1826,49 +1953,49 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
1826
1953
|
disabled: updateMutation.isPending
|
|
1827
1954
|
}
|
|
1828
1955
|
),
|
|
1829
|
-
/* @__PURE__ */
|
|
1830
|
-
|
|
1956
|
+
/* @__PURE__ */ jsx6(
|
|
1957
|
+
Button5,
|
|
1831
1958
|
{
|
|
1832
1959
|
variant: "ghost",
|
|
1833
1960
|
size: "icon",
|
|
1834
1961
|
"aria-label": "Editar",
|
|
1835
1962
|
className: "shrink-0 text-muted-foreground hover:text-foreground",
|
|
1836
1963
|
onClick: () => openEdit(objective),
|
|
1837
|
-
children: /* @__PURE__ */
|
|
1964
|
+
children: /* @__PURE__ */ jsx6(Pencil2, { className: "h-4 w-4" })
|
|
1838
1965
|
}
|
|
1839
1966
|
),
|
|
1840
|
-
/* @__PURE__ */
|
|
1841
|
-
|
|
1967
|
+
/* @__PURE__ */ jsx6(
|
|
1968
|
+
Button5,
|
|
1842
1969
|
{
|
|
1843
1970
|
variant: "ghost",
|
|
1844
1971
|
size: "icon",
|
|
1845
1972
|
"aria-label": "Excluir",
|
|
1846
1973
|
className: "shrink-0 text-muted-foreground hover:text-destructive",
|
|
1847
1974
|
onClick: () => setRemoveTarget(objective),
|
|
1848
|
-
children: /* @__PURE__ */
|
|
1975
|
+
children: /* @__PURE__ */ jsx6(Trash23, { className: "h-4 w-4" })
|
|
1849
1976
|
}
|
|
1850
1977
|
)
|
|
1851
1978
|
]
|
|
1852
1979
|
},
|
|
1853
1980
|
objective.id
|
|
1854
1981
|
)) }),
|
|
1855
|
-
/* @__PURE__ */
|
|
1982
|
+
/* @__PURE__ */ jsx6(SortableOverlay, { children: ({ value }) => {
|
|
1856
1983
|
const obj = sortedObjectives.find((o) => o.id === value);
|
|
1857
|
-
return /* @__PURE__ */
|
|
1858
|
-
/* @__PURE__ */
|
|
1859
|
-
/* @__PURE__ */
|
|
1984
|
+
return /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-3 rounded-lg border bg-card p-3 shadow-lg", children: [
|
|
1985
|
+
/* @__PURE__ */ jsx6(GripVertical2, { "aria-hidden": "true", className: "h-5 w-5 text-muted-foreground" }),
|
|
1986
|
+
/* @__PURE__ */ jsx6("span", { className: "font-medium", children: obj?.title })
|
|
1860
1987
|
] });
|
|
1861
1988
|
} })
|
|
1862
1989
|
]
|
|
1863
1990
|
}
|
|
1864
1991
|
),
|
|
1865
|
-
/* @__PURE__ */
|
|
1866
|
-
/* @__PURE__ */
|
|
1867
|
-
/* @__PURE__ */
|
|
1868
|
-
/* @__PURE__ */
|
|
1869
|
-
/* @__PURE__ */
|
|
1870
|
-
/* @__PURE__ */
|
|
1871
|
-
|
|
1992
|
+
/* @__PURE__ */ jsx6(Dialog3, { open: formOpen, onOpenChange: setFormOpen, children: /* @__PURE__ */ jsxs5(DialogContent3, { className: "sm:max-w-lg", children: [
|
|
1993
|
+
/* @__PURE__ */ jsx6(DialogHeader3, { children: /* @__PURE__ */ jsx6(DialogTitle3, { children: editTarget ? "Editar Objetivo" : "Novo Objetivo" }) }),
|
|
1994
|
+
/* @__PURE__ */ jsxs5("div", { className: "space-y-4", children: [
|
|
1995
|
+
/* @__PURE__ */ jsxs5("div", { className: "space-y-2", children: [
|
|
1996
|
+
/* @__PURE__ */ jsx6(Label3, { htmlFor: "objective-title", children: "T\xEDtulo *" }),
|
|
1997
|
+
/* @__PURE__ */ jsx6(
|
|
1998
|
+
Input5,
|
|
1872
1999
|
{
|
|
1873
2000
|
id: "objective-title",
|
|
1874
2001
|
name: "title",
|
|
@@ -1885,10 +2012,10 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
1885
2012
|
}
|
|
1886
2013
|
)
|
|
1887
2014
|
] }),
|
|
1888
|
-
/* @__PURE__ */
|
|
1889
|
-
/* @__PURE__ */
|
|
1890
|
-
/* @__PURE__ */
|
|
1891
|
-
|
|
2015
|
+
/* @__PURE__ */ jsxs5("div", { className: "space-y-2", children: [
|
|
2016
|
+
/* @__PURE__ */ jsx6(Label3, { htmlFor: "objective-slug", children: "Slug (identificador) *" }),
|
|
2017
|
+
/* @__PURE__ */ jsx6(
|
|
2018
|
+
Input5,
|
|
1892
2019
|
{
|
|
1893
2020
|
id: "objective-slug",
|
|
1894
2021
|
name: "slug",
|
|
@@ -1901,12 +2028,12 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
1901
2028
|
className: "font-mono"
|
|
1902
2029
|
}
|
|
1903
2030
|
),
|
|
1904
|
-
/* @__PURE__ */
|
|
2031
|
+
/* @__PURE__ */ jsx6("p", { className: "text-xs text-muted-foreground", children: "Gerado automaticamente. Usado pelo agente para identificar o objetivo." })
|
|
1905
2032
|
] }),
|
|
1906
|
-
/* @__PURE__ */
|
|
1907
|
-
/* @__PURE__ */
|
|
1908
|
-
/* @__PURE__ */
|
|
1909
|
-
|
|
2033
|
+
/* @__PURE__ */ jsxs5("div", { className: "space-y-2", children: [
|
|
2034
|
+
/* @__PURE__ */ jsx6(Label3, { htmlFor: "objective-instruction", children: "Quando ativar (instru\xE7\xE3o curta) *" }),
|
|
2035
|
+
/* @__PURE__ */ jsx6(
|
|
2036
|
+
Input5,
|
|
1910
2037
|
{
|
|
1911
2038
|
id: "objective-instruction",
|
|
1912
2039
|
name: "instruction",
|
|
@@ -1915,35 +2042,61 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
1915
2042
|
placeholder: "Ex: Quando o utilizador quer agendar uma consulta"
|
|
1916
2043
|
}
|
|
1917
2044
|
),
|
|
1918
|
-
/* @__PURE__ */
|
|
2045
|
+
/* @__PURE__ */ jsx6("p", { className: "text-xs text-muted-foreground", children: "Instru\xE7\xE3o curta que diz ao agente QUANDO ativar este objetivo. Aparece na sec\xE7\xE3o [OBJETIVOS] do prompt." })
|
|
2046
|
+
] }),
|
|
2047
|
+
/* @__PURE__ */ jsxs5("div", { className: "space-y-2", children: [
|
|
2048
|
+
/* @__PURE__ */ jsx6(Label3, { htmlFor: "objective-description", children: "Descri\xE7\xE3o" }),
|
|
2049
|
+
/* @__PURE__ */ jsx6(
|
|
2050
|
+
Textarea,
|
|
2051
|
+
{
|
|
2052
|
+
id: "objective-description",
|
|
2053
|
+
name: "description",
|
|
2054
|
+
value: form.description,
|
|
2055
|
+
onChange: (e) => setForm((f) => ({ ...f, description: e.target.value })),
|
|
2056
|
+
placeholder: "Descreva o prop\xF3sito deste objectivo...",
|
|
2057
|
+
rows: 3
|
|
2058
|
+
}
|
|
2059
|
+
),
|
|
2060
|
+
/* @__PURE__ */ jsx6("p", { className: "text-xs text-muted-foreground", children: "Miss\xE3o e prop\xF3sito deste objectivo \u2014 o que o agente deve alcan\xE7ar." })
|
|
2061
|
+
] }),
|
|
2062
|
+
/* @__PURE__ */ jsxs5("div", { className: "space-y-2", children: [
|
|
2063
|
+
/* @__PURE__ */ jsx6(Label3, { children: "Fluxo de Conversa" }),
|
|
2064
|
+
/* @__PURE__ */ jsx6(
|
|
2065
|
+
ConversationFlowEditor,
|
|
2066
|
+
{
|
|
2067
|
+
steps: form.conversation_flow,
|
|
2068
|
+
onChange: (steps) => setForm((f) => ({ ...f, conversation_flow: steps }))
|
|
2069
|
+
}
|
|
2070
|
+
),
|
|
2071
|
+
/* @__PURE__ */ jsx6("p", { className: "text-xs text-muted-foreground", children: "Etapas que o agente segue quando este objectivo \xE9 activado." })
|
|
1919
2072
|
] }),
|
|
1920
|
-
/* @__PURE__ */
|
|
1921
|
-
/* @__PURE__ */
|
|
1922
|
-
/* @__PURE__ */
|
|
2073
|
+
/* @__PURE__ */ jsxs5("div", { className: "space-y-2", children: [
|
|
2074
|
+
/* @__PURE__ */ jsx6(Label3, { htmlFor: "objective-rules", children: "Regras" }),
|
|
2075
|
+
/* @__PURE__ */ jsx6(
|
|
1923
2076
|
Textarea,
|
|
1924
2077
|
{
|
|
1925
|
-
id: "objective-
|
|
1926
|
-
name: "
|
|
1927
|
-
value: form.
|
|
1928
|
-
onChange: (e) => setForm((f) => ({ ...f,
|
|
1929
|
-
placeholder: "
|
|
1930
|
-
rows:
|
|
2078
|
+
id: "objective-rules",
|
|
2079
|
+
name: "rules",
|
|
2080
|
+
value: form.rules,
|
|
2081
|
+
onChange: (e) => setForm((f) => ({ ...f, rules: e.target.value })),
|
|
2082
|
+
placeholder: "Regras espec\xEDficas deste objectivo...",
|
|
2083
|
+
rows: 3
|
|
1931
2084
|
}
|
|
1932
2085
|
),
|
|
1933
|
-
/* @__PURE__ */
|
|
2086
|
+
/* @__PURE__ */ jsx6("p", { className: "text-xs text-muted-foreground", children: "Restri\xE7\xF5es e limites espec\xEDficos quando este objectivo est\xE1 activo." })
|
|
1934
2087
|
] })
|
|
1935
2088
|
] }),
|
|
1936
|
-
/* @__PURE__ */
|
|
1937
|
-
/* @__PURE__ */
|
|
1938
|
-
|
|
2089
|
+
/* @__PURE__ */ jsxs5(DialogFooter3, { children: [
|
|
2090
|
+
/* @__PURE__ */ jsx6(
|
|
2091
|
+
Button5,
|
|
1939
2092
|
{
|
|
1940
2093
|
variant: "outline",
|
|
1941
2094
|
onClick: () => setFormOpen(false),
|
|
1942
2095
|
children: "Cancelar"
|
|
1943
2096
|
}
|
|
1944
2097
|
),
|
|
1945
|
-
/* @__PURE__ */
|
|
1946
|
-
|
|
2098
|
+
/* @__PURE__ */ jsx6(
|
|
2099
|
+
Button5,
|
|
1947
2100
|
{
|
|
1948
2101
|
onClick: handleSubmit,
|
|
1949
2102
|
disabled: !form.title.trim() || createMutation.isPending || updateMutation.isPending,
|
|
@@ -1952,19 +2105,19 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
1952
2105
|
)
|
|
1953
2106
|
] })
|
|
1954
2107
|
] }) }),
|
|
1955
|
-
/* @__PURE__ */
|
|
2108
|
+
/* @__PURE__ */ jsx6(
|
|
1956
2109
|
AlertDialog2,
|
|
1957
2110
|
{
|
|
1958
2111
|
open: !!removeTarget,
|
|
1959
2112
|
onOpenChange: (open) => !open && setRemoveTarget(null),
|
|
1960
|
-
children: /* @__PURE__ */
|
|
1961
|
-
/* @__PURE__ */
|
|
1962
|
-
/* @__PURE__ */
|
|
1963
|
-
/* @__PURE__ */
|
|
2113
|
+
children: /* @__PURE__ */ jsxs5(AlertDialogContent2, { children: [
|
|
2114
|
+
/* @__PURE__ */ jsxs5(AlertDialogHeader2, { children: [
|
|
2115
|
+
/* @__PURE__ */ jsx6(AlertDialogTitle2, { children: "Remover objetivo?" }),
|
|
2116
|
+
/* @__PURE__ */ jsx6(AlertDialogDescription2, { children: "O objetivo ser\xE1 removido permanentemente." })
|
|
1964
2117
|
] }),
|
|
1965
|
-
/* @__PURE__ */
|
|
1966
|
-
/* @__PURE__ */
|
|
1967
|
-
/* @__PURE__ */
|
|
2118
|
+
/* @__PURE__ */ jsxs5(AlertDialogFooter2, { children: [
|
|
2119
|
+
/* @__PURE__ */ jsx6(AlertDialogCancel2, { children: "Cancelar" }),
|
|
2120
|
+
/* @__PURE__ */ jsx6(
|
|
1968
2121
|
AlertDialogAction2,
|
|
1969
2122
|
{
|
|
1970
2123
|
onClick: handleRemove,
|
|
@@ -1979,12 +2132,263 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
1979
2132
|
] });
|
|
1980
2133
|
}
|
|
1981
2134
|
|
|
1982
|
-
// src/components/agents/agent-
|
|
1983
|
-
import { useState as
|
|
1984
|
-
import { Button as
|
|
1985
|
-
import {
|
|
2135
|
+
// src/components/agents/agent-definition-editor.tsx
|
|
2136
|
+
import { useState as useState7, useRef as useRef2, useCallback as useCallback4, useEffect as useEffect3 } from "react";
|
|
2137
|
+
import { Button as Button6, Input as Input6, Label as Label4 } from "@greatapps/greatauth-ui/ui";
|
|
2138
|
+
import { Loader2 as Loader23 } from "lucide-react";
|
|
1986
2139
|
import { toast as toast5 } from "sonner";
|
|
1987
|
-
import { jsx as
|
|
2140
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2141
|
+
var SECTIONS = [
|
|
2142
|
+
{
|
|
2143
|
+
key: "identity",
|
|
2144
|
+
label: "Identidade",
|
|
2145
|
+
helper: "Descreva quem \xE9 o agente, o seu nome e personalidade",
|
|
2146
|
+
required: true,
|
|
2147
|
+
field: "identity",
|
|
2148
|
+
type: "textarea"
|
|
2149
|
+
},
|
|
2150
|
+
{
|
|
2151
|
+
key: "mission",
|
|
2152
|
+
label: "Miss\xE3o",
|
|
2153
|
+
helper: "Qual \xE9 a miss\xE3o principal deste agente",
|
|
2154
|
+
required: true,
|
|
2155
|
+
field: "mission",
|
|
2156
|
+
type: "textarea"
|
|
2157
|
+
},
|
|
2158
|
+
{
|
|
2159
|
+
key: "tone_style_format",
|
|
2160
|
+
label: "Tom, Estilo & Formato",
|
|
2161
|
+
helper: "Defina como o agente comunica e formata as respostas",
|
|
2162
|
+
required: false,
|
|
2163
|
+
field: "tone_style_format",
|
|
2164
|
+
type: "textarea"
|
|
2165
|
+
},
|
|
2166
|
+
{
|
|
2167
|
+
key: "rules",
|
|
2168
|
+
label: "Regras",
|
|
2169
|
+
helper: "Limites, restri\xE7\xF5es e comportamentos obrigat\xF3rios",
|
|
2170
|
+
required: false,
|
|
2171
|
+
field: "rules",
|
|
2172
|
+
type: "textarea"
|
|
2173
|
+
},
|
|
2174
|
+
{
|
|
2175
|
+
key: "conversation_flow",
|
|
2176
|
+
label: "Fluxo de Conversa",
|
|
2177
|
+
helper: "Etapas que o agente segue no in\xEDcio de cada conversa",
|
|
2178
|
+
required: false,
|
|
2179
|
+
field: "conversation_flow",
|
|
2180
|
+
type: "conversation_flow"
|
|
2181
|
+
},
|
|
2182
|
+
{
|
|
2183
|
+
key: "context",
|
|
2184
|
+
label: "Contexto",
|
|
2185
|
+
helper: "Informa\xE7\xF5es adicionais que o agente deve saber",
|
|
2186
|
+
required: false,
|
|
2187
|
+
field: "context",
|
|
2188
|
+
type: "textarea"
|
|
2189
|
+
}
|
|
2190
|
+
];
|
|
2191
|
+
function parseConversationFlow(raw) {
|
|
2192
|
+
if (!raw) return [];
|
|
2193
|
+
try {
|
|
2194
|
+
const parsed = JSON.parse(raw);
|
|
2195
|
+
if (Array.isArray(parsed)) return parsed;
|
|
2196
|
+
return [];
|
|
2197
|
+
} catch {
|
|
2198
|
+
return [];
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
function computeTotals(fields, steps) {
|
|
2202
|
+
const textChars = Object.values(fields).reduce((sum, v) => sum + v.length, 0);
|
|
2203
|
+
const flowChars = JSON.stringify(steps).length;
|
|
2204
|
+
const total = textChars + flowChars;
|
|
2205
|
+
return { chars: total, tokens: Math.ceil(total / 4) };
|
|
2206
|
+
}
|
|
2207
|
+
function AutoTextarea({
|
|
2208
|
+
value,
|
|
2209
|
+
onChange,
|
|
2210
|
+
disabled,
|
|
2211
|
+
placeholder,
|
|
2212
|
+
ariaLabel
|
|
2213
|
+
}) {
|
|
2214
|
+
const ref = useRef2(null);
|
|
2215
|
+
const autoResize = useCallback4(() => {
|
|
2216
|
+
const el = ref.current;
|
|
2217
|
+
if (!el) return;
|
|
2218
|
+
el.style.height = "auto";
|
|
2219
|
+
el.style.height = `${Math.max(120, el.scrollHeight)}px`;
|
|
2220
|
+
}, []);
|
|
2221
|
+
useEffect3(() => {
|
|
2222
|
+
autoResize();
|
|
2223
|
+
}, [value, autoResize]);
|
|
2224
|
+
function handleKeyDown(e) {
|
|
2225
|
+
if (e.key === "Tab") {
|
|
2226
|
+
e.preventDefault();
|
|
2227
|
+
const el = e.currentTarget;
|
|
2228
|
+
const start = el.selectionStart;
|
|
2229
|
+
const end = el.selectionEnd;
|
|
2230
|
+
const newValue = el.value.substring(0, start) + " " + el.value.substring(end);
|
|
2231
|
+
onChange(newValue);
|
|
2232
|
+
requestAnimationFrame(() => {
|
|
2233
|
+
el.selectionStart = el.selectionEnd = start + 2;
|
|
2234
|
+
});
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
return /* @__PURE__ */ jsx7(
|
|
2238
|
+
"textarea",
|
|
2239
|
+
{
|
|
2240
|
+
ref,
|
|
2241
|
+
"aria-label": ariaLabel,
|
|
2242
|
+
value,
|
|
2243
|
+
onChange: (e) => onChange(e.target.value),
|
|
2244
|
+
onKeyDown: handleKeyDown,
|
|
2245
|
+
placeholder,
|
|
2246
|
+
disabled,
|
|
2247
|
+
className: "w-full resize-none rounded-lg border bg-background p-3 text-sm leading-relaxed focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50",
|
|
2248
|
+
style: { minHeight: "120px" }
|
|
2249
|
+
}
|
|
2250
|
+
);
|
|
2251
|
+
}
|
|
2252
|
+
function AgentDefinitionEditor({ agent, config }) {
|
|
2253
|
+
const updateAgent = useUpdateAgent(config);
|
|
2254
|
+
const [trackedAgentId, setTrackedAgentId] = useState7(agent.id);
|
|
2255
|
+
const [fields, setFields] = useState7(() => ({
|
|
2256
|
+
identity: agent.identity ?? "",
|
|
2257
|
+
mission: agent.mission ?? "",
|
|
2258
|
+
tone_style_format: agent.tone_style_format ?? "",
|
|
2259
|
+
rules: agent.rules ?? "",
|
|
2260
|
+
context: agent.context ?? ""
|
|
2261
|
+
}));
|
|
2262
|
+
const [conversationFlowSteps, setConversationFlowSteps] = useState7(
|
|
2263
|
+
() => parseConversationFlow(agent.conversation_flow)
|
|
2264
|
+
);
|
|
2265
|
+
const [changeNotes, setChangeNotes] = useState7("");
|
|
2266
|
+
if (trackedAgentId !== agent.id) {
|
|
2267
|
+
setTrackedAgentId(agent.id);
|
|
2268
|
+
setFields({
|
|
2269
|
+
identity: agent.identity ?? "",
|
|
2270
|
+
mission: agent.mission ?? "",
|
|
2271
|
+
tone_style_format: agent.tone_style_format ?? "",
|
|
2272
|
+
rules: agent.rules ?? "",
|
|
2273
|
+
context: agent.context ?? ""
|
|
2274
|
+
});
|
|
2275
|
+
setConversationFlowSteps(parseConversationFlow(agent.conversation_flow));
|
|
2276
|
+
setChangeNotes("");
|
|
2277
|
+
}
|
|
2278
|
+
function updateField(key, value) {
|
|
2279
|
+
setFields((prev) => ({ ...prev, [key]: value }));
|
|
2280
|
+
}
|
|
2281
|
+
const { chars, tokens } = computeTotals(fields, conversationFlowSteps);
|
|
2282
|
+
async function handleSave() {
|
|
2283
|
+
if (!fields.identity.trim() || !fields.mission.trim()) {
|
|
2284
|
+
toast5.error("Identidade e Miss\xE3o s\xE3o campos obrigat\xF3rios");
|
|
2285
|
+
return;
|
|
2286
|
+
}
|
|
2287
|
+
const body = {
|
|
2288
|
+
identity: fields.identity.trim(),
|
|
2289
|
+
mission: fields.mission.trim(),
|
|
2290
|
+
tone_style_format: fields.tone_style_format.trim() || null,
|
|
2291
|
+
rules: fields.rules.trim() || null,
|
|
2292
|
+
conversation_flow: conversationFlowSteps.length > 0 ? JSON.stringify(conversationFlowSteps) : null,
|
|
2293
|
+
context: fields.context.trim() || null
|
|
2294
|
+
};
|
|
2295
|
+
if (changeNotes.trim()) {
|
|
2296
|
+
body.change_notes = changeNotes.trim();
|
|
2297
|
+
}
|
|
2298
|
+
try {
|
|
2299
|
+
await updateAgent.mutateAsync({ id: agent.id, body });
|
|
2300
|
+
setChangeNotes("");
|
|
2301
|
+
toast5.success("Defini\xE7\xE3o do agente salva com sucesso");
|
|
2302
|
+
} catch {
|
|
2303
|
+
toast5.error("Erro ao salvar defini\xE7\xE3o do agente");
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
return /* @__PURE__ */ jsxs6("div", { className: "space-y-6 p-4", children: [
|
|
2307
|
+
SECTIONS.map((section) => /* @__PURE__ */ jsxs6("div", { className: "space-y-2", children: [
|
|
2308
|
+
/* @__PURE__ */ jsxs6(Label4, { className: "text-sm font-medium", children: [
|
|
2309
|
+
section.label,
|
|
2310
|
+
section.required && /* @__PURE__ */ jsx7("span", { className: "ml-0.5 text-destructive", children: "*" })
|
|
2311
|
+
] }),
|
|
2312
|
+
/* @__PURE__ */ jsx7("p", { className: "text-xs text-muted-foreground", children: section.helper }),
|
|
2313
|
+
section.type === "textarea" ? /* @__PURE__ */ jsx7(
|
|
2314
|
+
AutoTextarea,
|
|
2315
|
+
{
|
|
2316
|
+
value: fields[section.key] ?? "",
|
|
2317
|
+
onChange: (v) => updateField(section.key, v),
|
|
2318
|
+
disabled: updateAgent.isPending,
|
|
2319
|
+
placeholder: `${section.label}...`,
|
|
2320
|
+
ariaLabel: section.label
|
|
2321
|
+
}
|
|
2322
|
+
) : /* @__PURE__ */ jsx7(
|
|
2323
|
+
ConversationFlowEditor,
|
|
2324
|
+
{
|
|
2325
|
+
steps: conversationFlowSteps,
|
|
2326
|
+
onChange: setConversationFlowSteps,
|
|
2327
|
+
disabled: updateAgent.isPending
|
|
2328
|
+
}
|
|
2329
|
+
)
|
|
2330
|
+
] }, section.key)),
|
|
2331
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-3 text-xs text-muted-foreground", children: [
|
|
2332
|
+
/* @__PURE__ */ jsxs6("span", { className: "tabular-nums", children: [
|
|
2333
|
+
chars.toLocaleString("pt-BR"),
|
|
2334
|
+
" caracteres"
|
|
2335
|
+
] }),
|
|
2336
|
+
/* @__PURE__ */ jsx7("span", { children: "\xB7" }),
|
|
2337
|
+
/* @__PURE__ */ jsxs6("span", { className: "tabular-nums", children: [
|
|
2338
|
+
"~",
|
|
2339
|
+
tokens.toLocaleString("pt-BR"),
|
|
2340
|
+
" tokens"
|
|
2341
|
+
] })
|
|
2342
|
+
] }),
|
|
2343
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-3", children: [
|
|
2344
|
+
/* @__PURE__ */ jsx7(
|
|
2345
|
+
Input6,
|
|
2346
|
+
{
|
|
2347
|
+
"aria-label": "Notas da altera\xE7\xE3o",
|
|
2348
|
+
name: "changeNotes",
|
|
2349
|
+
value: changeNotes,
|
|
2350
|
+
onChange: (e) => setChangeNotes(e.target.value),
|
|
2351
|
+
placeholder: "O que mudou? (opcional)",
|
|
2352
|
+
disabled: updateAgent.isPending,
|
|
2353
|
+
className: "flex-1",
|
|
2354
|
+
onKeyDown: (e) => {
|
|
2355
|
+
if (e.key === "Enter") {
|
|
2356
|
+
e.preventDefault();
|
|
2357
|
+
handleSave();
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
),
|
|
2362
|
+
/* @__PURE__ */ jsxs6(
|
|
2363
|
+
Button6,
|
|
2364
|
+
{
|
|
2365
|
+
onClick: handleSave,
|
|
2366
|
+
disabled: updateAgent.isPending || !fields.identity.trim() || !fields.mission.trim(),
|
|
2367
|
+
children: [
|
|
2368
|
+
updateAgent.isPending && /* @__PURE__ */ jsx7(Loader23, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
2369
|
+
"Salvar"
|
|
2370
|
+
]
|
|
2371
|
+
}
|
|
2372
|
+
)
|
|
2373
|
+
] })
|
|
2374
|
+
] });
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2377
|
+
// src/components/agents/agent-revision-tab.tsx
|
|
2378
|
+
import { useState as useState8, useMemo as useMemo5 } from "react";
|
|
2379
|
+
import {
|
|
2380
|
+
Button as Button7,
|
|
2381
|
+
Badge as Badge3,
|
|
2382
|
+
Skeleton as Skeleton2,
|
|
2383
|
+
Dialog as Dialog4,
|
|
2384
|
+
DialogContent as DialogContent4,
|
|
2385
|
+
DialogHeader as DialogHeader4,
|
|
2386
|
+
DialogTitle as DialogTitle4
|
|
2387
|
+
} from "@greatapps/greatauth-ui/ui";
|
|
2388
|
+
import { FileText, RotateCcw, X, AlertTriangle } from "lucide-react";
|
|
2389
|
+
import { toast as toast6 } from "sonner";
|
|
2390
|
+
import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2391
|
+
var STRUCTURED_MARKERS = ["[IDENTIDADE]", "[MISS\xC3O]", "[TOM, ESTILO & FORMATO]"];
|
|
1988
2392
|
function formatDate(dateStr) {
|
|
1989
2393
|
const date = new Date(dateStr);
|
|
1990
2394
|
return date.toLocaleDateString("pt-BR", {
|
|
@@ -2016,214 +2420,95 @@ function computeDiff(oldText, newText) {
|
|
|
2016
2420
|
}
|
|
2017
2421
|
return result;
|
|
2018
2422
|
}
|
|
2019
|
-
function
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
}
|
|
2033
|
-
}
|
|
2423
|
+
function formatConversationFlow(raw) {
|
|
2424
|
+
if (!raw) return "";
|
|
2425
|
+
try {
|
|
2426
|
+
const steps = JSON.parse(raw);
|
|
2427
|
+
if (!Array.isArray(steps) || steps.length === 0) return "";
|
|
2428
|
+
return steps.sort((a, b) => a.order - b.order).map((s) => {
|
|
2429
|
+
let line = `${s.order}. ${s.instruction}`;
|
|
2430
|
+
if (s.example) line += `
|
|
2431
|
+
Exemplo: ${s.example}`;
|
|
2432
|
+
return line;
|
|
2433
|
+
}).join("\n");
|
|
2434
|
+
} catch {
|
|
2435
|
+
return raw;
|
|
2034
2436
|
}
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
const
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
}
|
|
2042
|
-
if (
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
${
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2437
|
+
}
|
|
2438
|
+
function buildAssembledPrompt(agent) {
|
|
2439
|
+
const sections = [];
|
|
2440
|
+
if (agent.identity?.trim()) {
|
|
2441
|
+
sections.push(`[IDENTIDADE]
|
|
2442
|
+
${agent.identity.trim()}`);
|
|
2443
|
+
}
|
|
2444
|
+
if (agent.mission?.trim()) {
|
|
2445
|
+
sections.push(`[MISS\xC3O]
|
|
2446
|
+
${agent.mission.trim()}`);
|
|
2447
|
+
}
|
|
2448
|
+
if (agent.tone_style_format?.trim()) {
|
|
2449
|
+
sections.push(`[TOM, ESTILO & FORMATO]
|
|
2450
|
+
${agent.tone_style_format.trim()}`);
|
|
2451
|
+
}
|
|
2452
|
+
if (agent.rules?.trim()) {
|
|
2453
|
+
sections.push(`[REGRAS]
|
|
2454
|
+
${agent.rules.trim()}`);
|
|
2455
|
+
}
|
|
2456
|
+
const flowFormatted = formatConversationFlow(agent.conversation_flow);
|
|
2457
|
+
if (flowFormatted) {
|
|
2458
|
+
sections.push(`[FLUXO DE CONVERSA]
|
|
2459
|
+
${flowFormatted}`);
|
|
2057
2460
|
}
|
|
2058
|
-
|
|
2461
|
+
if (agent.context?.trim()) {
|
|
2462
|
+
sections.push(`[CONTEXTO]
|
|
2463
|
+
${agent.context.trim()}`);
|
|
2464
|
+
}
|
|
2465
|
+
return sections.join("\n\n");
|
|
2466
|
+
}
|
|
2467
|
+
function isLegacyVersion(version) {
|
|
2468
|
+
const content = version.prompt_content ?? "";
|
|
2469
|
+
return !STRUCTURED_MARKERS.some((marker) => content.includes(marker));
|
|
2059
2470
|
}
|
|
2060
|
-
function
|
|
2471
|
+
function AgentRevisionTab({ agent, config }) {
|
|
2061
2472
|
const { data: versionsData, isLoading } = usePromptVersions(config, agent.id);
|
|
2062
|
-
const
|
|
2063
|
-
const
|
|
2064
|
-
const { data: agentToolsData } = useAgentTools(config, agent.id);
|
|
2065
|
-
const { data: toolsData } = useTools(config);
|
|
2473
|
+
const [compareVersionId, setCompareVersionId] = useState8(null);
|
|
2474
|
+
const [legacyModalVersion, setLegacyModalVersion] = useState8(null);
|
|
2066
2475
|
const versions = versionsData?.data || [];
|
|
2067
2476
|
const sortedVersions = [...versions].sort(
|
|
2068
2477
|
(a, b) => new Date(b.datetime_add).getTime() - new Date(a.datetime_add).getTime()
|
|
2069
2478
|
);
|
|
2070
2479
|
const currentVersion = sortedVersions.find((v) => v.is_current) || sortedVersions[0] || null;
|
|
2071
|
-
const
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
setPromptInitialized(true);
|
|
2082
|
-
}
|
|
2083
|
-
if (trackedAgentId !== agent.id) {
|
|
2084
|
-
setTrackedAgentId(agent.id);
|
|
2085
|
-
setPromptText(currentPromptContent);
|
|
2086
|
-
setPromptInitialized(!!currentPromptContent);
|
|
2087
|
-
setCompareVersionId(null);
|
|
2088
|
-
}
|
|
2089
|
-
const autoResize = useCallback3(() => {
|
|
2090
|
-
const el = textareaRef.current;
|
|
2091
|
-
if (!el) return;
|
|
2092
|
-
el.style.height = "auto";
|
|
2093
|
-
el.style.height = `${Math.max(300, el.scrollHeight)}px`;
|
|
2094
|
-
}, []);
|
|
2095
|
-
useEffect3(() => {
|
|
2096
|
-
autoResize();
|
|
2097
|
-
}, [promptText, autoResize]);
|
|
2098
|
-
function handleKeyDown(e) {
|
|
2099
|
-
if (e.key === "Tab") {
|
|
2100
|
-
e.preventDefault();
|
|
2101
|
-
const el = e.currentTarget;
|
|
2102
|
-
const start = el.selectionStart;
|
|
2103
|
-
const end = el.selectionEnd;
|
|
2104
|
-
const value = el.value;
|
|
2105
|
-
const newValue = value.substring(0, start) + " " + value.substring(end);
|
|
2106
|
-
setPromptText(newValue);
|
|
2107
|
-
requestAnimationFrame(() => {
|
|
2108
|
-
el.selectionStart = el.selectionEnd = start + 2;
|
|
2109
|
-
});
|
|
2110
|
-
}
|
|
2111
|
-
}
|
|
2480
|
+
const assembledPrompt = useMemo5(() => buildAssembledPrompt(agent), [
|
|
2481
|
+
agent.identity,
|
|
2482
|
+
agent.mission,
|
|
2483
|
+
agent.tone_style_format,
|
|
2484
|
+
agent.rules,
|
|
2485
|
+
agent.conversation_flow,
|
|
2486
|
+
agent.context
|
|
2487
|
+
]);
|
|
2488
|
+
const charCount = assembledPrompt.length;
|
|
2489
|
+
const tokenEstimate = Math.ceil(charCount / 4);
|
|
2112
2490
|
const compareVersion = sortedVersions.find((v) => v.id === compareVersionId);
|
|
2113
2491
|
const diffLines = currentVersion && compareVersion && compareVersion.id !== currentVersion.id ? computeDiff(compareVersion.prompt_content ?? "", currentVersion.prompt_content ?? "") : null;
|
|
2114
|
-
async function handleSave() {
|
|
2115
|
-
const body = {
|
|
2116
|
-
prompt: promptText.trim()
|
|
2117
|
-
};
|
|
2118
|
-
if (changeNotes.trim()) {
|
|
2119
|
-
body.change_notes = changeNotes.trim();
|
|
2120
|
-
}
|
|
2121
|
-
try {
|
|
2122
|
-
await updateAgent.mutateAsync({ id: agent.id, body });
|
|
2123
|
-
setChangeNotes("");
|
|
2124
|
-
toast5.success("Prompt salvo com sucesso");
|
|
2125
|
-
} catch {
|
|
2126
|
-
toast5.error("Erro ao salvar prompt");
|
|
2127
|
-
}
|
|
2128
|
-
}
|
|
2129
2492
|
function handleRestore(version) {
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2493
|
+
if (isLegacyVersion(version)) {
|
|
2494
|
+
setLegacyModalVersion(version);
|
|
2495
|
+
} else {
|
|
2496
|
+
toast6.info("Restaurar vers\xE3o estruturada \u2014 funcionalidade em desenvolvimento");
|
|
2497
|
+
}
|
|
2133
2498
|
}
|
|
2134
|
-
const charCount = promptText.length;
|
|
2135
|
-
const tokenEstimate = Math.ceil(charCount / 4);
|
|
2136
|
-
const objectives = objectivesData?.data || [];
|
|
2137
|
-
const agentTools = agentToolsData?.data || [];
|
|
2138
|
-
const allTools = toolsData?.data || [];
|
|
2139
|
-
const previewText = buildPreview(promptText, objectives, agentTools, allTools);
|
|
2140
2499
|
if (isLoading) {
|
|
2141
|
-
return /* @__PURE__ */
|
|
2500
|
+
return /* @__PURE__ */ jsx8("div", { className: "space-y-3 p-4", children: Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ jsx8(Skeleton2, { className: "h-14 w-full" }, i)) });
|
|
2142
2501
|
}
|
|
2143
|
-
return /* @__PURE__ */
|
|
2144
|
-
/* @__PURE__ */
|
|
2145
|
-
/* @__PURE__ */
|
|
2146
|
-
/* @__PURE__ */
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
"aria-label": "Prompt do sistema",
|
|
2151
|
-
name: "prompt",
|
|
2152
|
-
value: promptText,
|
|
2153
|
-
onChange: (e) => setPromptText(e.target.value),
|
|
2154
|
-
onKeyDown: handleKeyDown,
|
|
2155
|
-
placeholder: "Escreva o prompt do sistema aqui\\u2026",
|
|
2156
|
-
disabled: updateAgent.isPending,
|
|
2157
|
-
className: "w-full resize-none rounded-lg border bg-background p-3 font-mono text-sm leading-relaxed focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50",
|
|
2158
|
-
style: { minHeight: "300px" }
|
|
2159
|
-
}
|
|
2160
|
-
),
|
|
2161
|
-
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-3 text-xs text-muted-foreground", children: [
|
|
2162
|
-
/* @__PURE__ */ jsxs5("span", { className: "tabular-nums", children: [
|
|
2163
|
-
charCount.toLocaleString("pt-BR"),
|
|
2164
|
-
" caracteres"
|
|
2165
|
-
] }),
|
|
2166
|
-
/* @__PURE__ */ jsx6("span", { children: "\xB7" }),
|
|
2167
|
-
/* @__PURE__ */ jsxs5("span", { className: "tabular-nums", children: [
|
|
2168
|
-
"~",
|
|
2169
|
-
tokenEstimate.toLocaleString("pt-BR"),
|
|
2170
|
-
" tokens"
|
|
2171
|
-
] })
|
|
2172
|
-
] })
|
|
2173
|
-
] }),
|
|
2174
|
-
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-3", children: [
|
|
2175
|
-
/* @__PURE__ */ jsx6(
|
|
2176
|
-
Input5,
|
|
2177
|
-
{
|
|
2178
|
-
"aria-label": "Notas da altera\xE7\xE3o",
|
|
2179
|
-
name: "changeNotes",
|
|
2180
|
-
value: changeNotes,
|
|
2181
|
-
onChange: (e) => setChangeNotes(e.target.value),
|
|
2182
|
-
placeholder: "O que mudou? (opcional)",
|
|
2183
|
-
disabled: updateAgent.isPending,
|
|
2184
|
-
className: "flex-1",
|
|
2185
|
-
onKeyDown: (e) => {
|
|
2186
|
-
if (e.key === "Enter") {
|
|
2187
|
-
e.preventDefault();
|
|
2188
|
-
handleSave();
|
|
2189
|
-
}
|
|
2190
|
-
}
|
|
2191
|
-
}
|
|
2192
|
-
),
|
|
2193
|
-
/* @__PURE__ */ jsxs5(
|
|
2194
|
-
Button5,
|
|
2195
|
-
{
|
|
2196
|
-
onClick: handleSave,
|
|
2197
|
-
disabled: updateAgent.isPending || !promptText.trim(),
|
|
2198
|
-
children: [
|
|
2199
|
-
updateAgent.isPending && /* @__PURE__ */ jsx6(Loader23, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
2200
|
-
"Salvar"
|
|
2201
|
-
]
|
|
2202
|
-
}
|
|
2203
|
-
)
|
|
2204
|
-
] }),
|
|
2205
|
-
/* @__PURE__ */ jsxs5("div", { className: "rounded-lg border", children: [
|
|
2206
|
-
/* @__PURE__ */ jsxs5(
|
|
2207
|
-
"button",
|
|
2208
|
-
{
|
|
2209
|
-
type: "button",
|
|
2210
|
-
onClick: () => setShowPreview((prev) => !prev),
|
|
2211
|
-
className: "flex w-full items-center justify-between px-4 py-3 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors",
|
|
2212
|
-
children: [
|
|
2213
|
-
/* @__PURE__ */ jsx6("span", { children: "Preview do prompt final" }),
|
|
2214
|
-
showPreview ? /* @__PURE__ */ jsx6(ChevronUp, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx6(ChevronDown, { className: "h-4 w-4" })
|
|
2215
|
-
]
|
|
2216
|
-
}
|
|
2217
|
-
),
|
|
2218
|
-
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) => {
|
|
2219
|
-
const isTopSection = line.startsWith("[TOOLS]") || line.startsWith("[SKILLS]");
|
|
2220
|
-
const isH2 = line.startsWith("## ");
|
|
2221
|
-
const isH3 = line.startsWith("### ");
|
|
2222
|
-
const cls = isTopSection ? "font-bold text-foreground" : isH2 ? "font-semibold text-muted-foreground" : isH3 ? "font-medium text-muted-foreground" : "";
|
|
2223
|
-
return /* @__PURE__ */ jsxs5(
|
|
2502
|
+
return /* @__PURE__ */ jsxs7("div", { className: "flex flex-col gap-4 p-4 lg:flex-row", children: [
|
|
2503
|
+
/* @__PURE__ */ jsxs7("div", { className: "min-w-0 flex-1 space-y-4", children: [
|
|
2504
|
+
/* @__PURE__ */ jsxs7("div", { className: "space-y-2", children: [
|
|
2505
|
+
/* @__PURE__ */ jsx8("h3", { className: "text-sm font-medium text-muted-foreground", children: "Preview do Prompt Montado" }),
|
|
2506
|
+
/* @__PURE__ */ jsx8("div", { className: "rounded-lg border", children: /* @__PURE__ */ jsx8("pre", { className: "max-h-[32rem] overflow-auto whitespace-pre-wrap p-4 font-mono text-sm leading-relaxed", children: assembledPrompt ? assembledPrompt.split("\n").map((line, i) => {
|
|
2507
|
+
const isSectionHeader = /^\[.+\]$/.test(line.trim());
|
|
2508
|
+
return /* @__PURE__ */ jsxs7(
|
|
2224
2509
|
"span",
|
|
2225
2510
|
{
|
|
2226
|
-
className:
|
|
2511
|
+
className: isSectionHeader ? "font-bold text-foreground" : "",
|
|
2227
2512
|
children: [
|
|
2228
2513
|
line,
|
|
2229
2514
|
"\n"
|
|
@@ -2231,34 +2516,49 @@ function AgentPromptEditor({ config, agent }) {
|
|
|
2231
2516
|
},
|
|
2232
2517
|
i
|
|
2233
2518
|
);
|
|
2234
|
-
}) }) })
|
|
2519
|
+
}) : /* @__PURE__ */ jsx8("span", { className: "italic text-muted-foreground", children: "Nenhum campo estruturado preenchido." }) }) }),
|
|
2520
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-3 text-xs text-muted-foreground", children: [
|
|
2521
|
+
/* @__PURE__ */ jsxs7("span", { className: "tabular-nums", children: [
|
|
2522
|
+
charCount.toLocaleString("pt-BR"),
|
|
2523
|
+
" caracteres"
|
|
2524
|
+
] }),
|
|
2525
|
+
/* @__PURE__ */ jsx8("span", { children: "\xB7" }),
|
|
2526
|
+
/* @__PURE__ */ jsxs7("span", { className: "tabular-nums", children: [
|
|
2527
|
+
"~",
|
|
2528
|
+
tokenEstimate.toLocaleString("pt-BR"),
|
|
2529
|
+
" tokens"
|
|
2530
|
+
] })
|
|
2531
|
+
] })
|
|
2235
2532
|
] }),
|
|
2236
|
-
diffLines && compareVersion && currentVersion && /* @__PURE__ */
|
|
2237
|
-
/* @__PURE__ */
|
|
2238
|
-
/* @__PURE__ */
|
|
2533
|
+
diffLines && compareVersion && currentVersion && /* @__PURE__ */ jsxs7("div", { children: [
|
|
2534
|
+
/* @__PURE__ */ jsxs7("div", { className: "mb-2 flex items-center justify-between", children: [
|
|
2535
|
+
/* @__PURE__ */ jsxs7("h3", { className: "text-sm font-medium text-muted-foreground", children: [
|
|
2239
2536
|
"Diferen\xE7as: v",
|
|
2240
2537
|
compareVersion.version_number,
|
|
2241
2538
|
" \u2192 v",
|
|
2242
2539
|
currentVersion.version_number,
|
|
2243
2540
|
" (actual)"
|
|
2244
2541
|
] }),
|
|
2245
|
-
/* @__PURE__ */
|
|
2246
|
-
|
|
2542
|
+
/* @__PURE__ */ jsxs7(
|
|
2543
|
+
Button7,
|
|
2247
2544
|
{
|
|
2248
2545
|
variant: "ghost",
|
|
2249
2546
|
size: "sm",
|
|
2250
2547
|
onClick: () => setCompareVersionId(null),
|
|
2251
2548
|
className: "text-xs",
|
|
2252
|
-
children:
|
|
2549
|
+
children: [
|
|
2550
|
+
/* @__PURE__ */ jsx8(X, { className: "mr-1 h-3 w-3" }),
|
|
2551
|
+
"Fechar"
|
|
2552
|
+
]
|
|
2253
2553
|
}
|
|
2254
2554
|
)
|
|
2255
2555
|
] }),
|
|
2256
|
-
/* @__PURE__ */
|
|
2556
|
+
/* @__PURE__ */ jsx8("div", { className: "max-h-64 overflow-auto rounded-lg border font-mono text-sm", children: diffLines.map((line, i) => /* @__PURE__ */ jsxs7(
|
|
2257
2557
|
"div",
|
|
2258
2558
|
{
|
|
2259
2559
|
className: `whitespace-pre-wrap px-3 py-0.5 ${line.type === "added" ? "bg-green-500/10 text-green-700 dark:text-green-400" : line.type === "removed" ? "bg-red-500/10 text-red-700 dark:text-red-400" : ""}`,
|
|
2260
2560
|
children: [
|
|
2261
|
-
/* @__PURE__ */
|
|
2561
|
+
/* @__PURE__ */ jsx8("span", { className: "mr-2 inline-block w-4 select-none text-muted-foreground", children: line.type === "added" ? "+" : line.type === "removed" ? "-" : " " }),
|
|
2262
2562
|
line.line || " "
|
|
2263
2563
|
]
|
|
2264
2564
|
},
|
|
@@ -2266,57 +2566,57 @@ function AgentPromptEditor({ config, agent }) {
|
|
|
2266
2566
|
)) })
|
|
2267
2567
|
] })
|
|
2268
2568
|
] }),
|
|
2269
|
-
/* @__PURE__ */
|
|
2270
|
-
/* @__PURE__ */
|
|
2271
|
-
sortedVersions.length === 0 ? /* @__PURE__ */
|
|
2272
|
-
/* @__PURE__ */
|
|
2273
|
-
/* @__PURE__ */
|
|
2274
|
-
] }) : /* @__PURE__ */
|
|
2275
|
-
const isCurrent =
|
|
2569
|
+
/* @__PURE__ */ jsxs7("div", { className: "w-full space-y-2 lg:w-80 lg:shrink-0", children: [
|
|
2570
|
+
/* @__PURE__ */ jsx8("h3", { className: "text-sm font-medium text-muted-foreground", children: "Hist\xF3rico de Vers\xF5es" }),
|
|
2571
|
+
sortedVersions.length === 0 ? /* @__PURE__ */ jsxs7("div", { className: "flex flex-col items-center justify-center rounded-lg border border-dashed p-8 text-center", children: [
|
|
2572
|
+
/* @__PURE__ */ jsx8(FileText, { className: "mb-2 h-8 w-8 text-muted-foreground" }),
|
|
2573
|
+
/* @__PURE__ */ jsx8("p", { className: "text-sm text-muted-foreground", children: "Nenhuma vers\xE3o encontrada." })
|
|
2574
|
+
] }) : /* @__PURE__ */ jsx8("div", { className: "space-y-1", children: sortedVersions.map((version) => {
|
|
2575
|
+
const isCurrent = currentVersion?.id === version.id;
|
|
2276
2576
|
const isComparing = version.id === compareVersionId;
|
|
2277
|
-
return /* @__PURE__ */
|
|
2577
|
+
return /* @__PURE__ */ jsxs7(
|
|
2278
2578
|
"div",
|
|
2279
2579
|
{
|
|
2280
2580
|
className: `rounded-lg border p-3 transition-colors ${isCurrent ? "border-primary bg-primary/5" : isComparing ? "border-muted-foreground/30 bg-muted/50" : ""}`,
|
|
2281
2581
|
children: [
|
|
2282
|
-
/* @__PURE__ */
|
|
2283
|
-
/* @__PURE__ */
|
|
2582
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center justify-between gap-2", children: [
|
|
2583
|
+
/* @__PURE__ */ jsxs7("span", { className: "text-sm font-medium", children: [
|
|
2284
2584
|
"v",
|
|
2285
2585
|
version.version_number
|
|
2286
2586
|
] }),
|
|
2287
|
-
isCurrent && /* @__PURE__ */
|
|
2587
|
+
isCurrent && /* @__PURE__ */ jsx8(Badge3, { variant: "default", className: "text-[10px] px-1.5 py-0", children: "Actual" })
|
|
2288
2588
|
] }),
|
|
2289
|
-
/* @__PURE__ */
|
|
2290
|
-
/* @__PURE__ */
|
|
2291
|
-
/* @__PURE__ */
|
|
2589
|
+
/* @__PURE__ */ jsx8("div", { className: "mt-1 text-xs text-muted-foreground", children: formatDate(version.datetime_add) }),
|
|
2590
|
+
/* @__PURE__ */ jsxs7("div", { className: "mt-1 flex items-center gap-2 text-xs text-muted-foreground", children: [
|
|
2591
|
+
/* @__PURE__ */ jsxs7("span", { children: [
|
|
2292
2592
|
(version.prompt_content ?? "").length,
|
|
2293
2593
|
" chars"
|
|
2294
2594
|
] }),
|
|
2295
|
-
/* @__PURE__ */
|
|
2296
|
-
/* @__PURE__ */
|
|
2595
|
+
/* @__PURE__ */ jsx8("span", { children: "\xB7" }),
|
|
2596
|
+
/* @__PURE__ */ jsx8("span", { className: "truncate font-mono", children: (version.prompt_hash ?? "").slice(0, 8) })
|
|
2297
2597
|
] }),
|
|
2298
|
-
version.change_notes && /* @__PURE__ */
|
|
2299
|
-
!isCurrent && /* @__PURE__ */
|
|
2300
|
-
/* @__PURE__ */
|
|
2598
|
+
version.change_notes && /* @__PURE__ */ jsx8("div", { className: "mt-1.5 text-xs italic text-muted-foreground", children: version.change_notes }),
|
|
2599
|
+
!isCurrent && /* @__PURE__ */ jsxs7("div", { className: "mt-2 flex items-center gap-3", children: [
|
|
2600
|
+
/* @__PURE__ */ jsxs7(
|
|
2301
2601
|
"button",
|
|
2302
2602
|
{
|
|
2303
2603
|
type: "button",
|
|
2304
2604
|
onClick: () => setCompareVersionId(isComparing ? null : version.id),
|
|
2305
2605
|
className: "flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",
|
|
2306
2606
|
children: [
|
|
2307
|
-
/* @__PURE__ */
|
|
2607
|
+
/* @__PURE__ */ jsx8(FileText, { "aria-hidden": "true", className: "h-3 w-3" }),
|
|
2308
2608
|
isComparing ? "Ocultar diff" : "Comparar"
|
|
2309
2609
|
]
|
|
2310
2610
|
}
|
|
2311
2611
|
),
|
|
2312
|
-
/* @__PURE__ */
|
|
2612
|
+
/* @__PURE__ */ jsxs7(
|
|
2313
2613
|
"button",
|
|
2314
2614
|
{
|
|
2315
2615
|
type: "button",
|
|
2316
2616
|
onClick: () => handleRestore(version),
|
|
2317
2617
|
className: "flex items-center gap-1 text-xs text-primary hover:underline",
|
|
2318
2618
|
children: [
|
|
2319
|
-
/* @__PURE__ */
|
|
2619
|
+
/* @__PURE__ */ jsx8(RotateCcw, { "aria-hidden": "true", className: "h-3 w-3" }),
|
|
2320
2620
|
"Restaurar"
|
|
2321
2621
|
]
|
|
2322
2622
|
}
|
|
@@ -2327,12 +2627,43 @@ function AgentPromptEditor({ config, agent }) {
|
|
|
2327
2627
|
version.id
|
|
2328
2628
|
);
|
|
2329
2629
|
}) })
|
|
2330
|
-
] })
|
|
2630
|
+
] }),
|
|
2631
|
+
/* @__PURE__ */ jsx8(
|
|
2632
|
+
Dialog4,
|
|
2633
|
+
{
|
|
2634
|
+
open: !!legacyModalVersion,
|
|
2635
|
+
onOpenChange: (open) => {
|
|
2636
|
+
if (!open) setLegacyModalVersion(null);
|
|
2637
|
+
},
|
|
2638
|
+
children: /* @__PURE__ */ jsxs7(DialogContent4, { className: "max-w-2xl", children: [
|
|
2639
|
+
/* @__PURE__ */ jsx8(DialogHeader4, { children: /* @__PURE__ */ jsxs7(DialogTitle4, { className: "flex items-center gap-2", children: [
|
|
2640
|
+
/* @__PURE__ */ jsx8(AlertTriangle, { className: "h-5 w-5 text-amber-500" }),
|
|
2641
|
+
"Vers\xE3o Legada \u2014 v",
|
|
2642
|
+
legacyModalVersion?.version_number
|
|
2643
|
+
] }) }),
|
|
2644
|
+
/* @__PURE__ */ jsxs7("div", { className: "space-y-3", children: [
|
|
2645
|
+
/* @__PURE__ */ jsx8("div", { className: "rounded-lg border border-amber-500/30 bg-amber-500/5 p-3", children: /* @__PURE__ */ jsx8("p", { className: "text-sm text-amber-700 dark:text-amber-400", children: "Esta vers\xE3o foi criada antes da reestrutura\xE7\xE3o e n\xE3o pode ser restaurada nos campos estruturados." }) }),
|
|
2646
|
+
/* @__PURE__ */ jsx8("div", { className: "max-h-96 overflow-auto rounded-lg border p-4", children: /* @__PURE__ */ jsx8("pre", { className: "whitespace-pre-wrap font-mono text-sm leading-relaxed", children: legacyModalVersion?.prompt_content ?? "" }) }),
|
|
2647
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-3 text-xs text-muted-foreground", children: [
|
|
2648
|
+
/* @__PURE__ */ jsxs7("span", { children: [
|
|
2649
|
+
(legacyModalVersion?.prompt_content ?? "").length.toLocaleString("pt-BR"),
|
|
2650
|
+
" caracteres"
|
|
2651
|
+
] }),
|
|
2652
|
+
legacyModalVersion?.change_notes && /* @__PURE__ */ jsxs7(Fragment2, { children: [
|
|
2653
|
+
/* @__PURE__ */ jsx8("span", { children: "\xB7" }),
|
|
2654
|
+
/* @__PURE__ */ jsx8("span", { className: "italic", children: legacyModalVersion.change_notes })
|
|
2655
|
+
] })
|
|
2656
|
+
] })
|
|
2657
|
+
] }),
|
|
2658
|
+
/* @__PURE__ */ jsx8("div", { className: "flex justify-end pt-2", children: /* @__PURE__ */ jsx8(Button7, { variant: "outline", onClick: () => setLegacyModalVersion(null), children: "Fechar" }) })
|
|
2659
|
+
] })
|
|
2660
|
+
}
|
|
2661
|
+
)
|
|
2331
2662
|
] });
|
|
2332
2663
|
}
|
|
2333
2664
|
|
|
2334
2665
|
// src/components/conversations/agent-conversations-table.tsx
|
|
2335
|
-
import { useState as
|
|
2666
|
+
import { useState as useState9 } from "react";
|
|
2336
2667
|
import {
|
|
2337
2668
|
Table,
|
|
2338
2669
|
TableBody,
|
|
@@ -2346,9 +2677,9 @@ import {
|
|
|
2346
2677
|
import { MessageCircle, ExternalLink } from "lucide-react";
|
|
2347
2678
|
|
|
2348
2679
|
// src/components/conversations/conversation-view.tsx
|
|
2349
|
-
import { Skeleton as Skeleton3, Button as
|
|
2350
|
-
import { X, MessageSquare } from "lucide-react";
|
|
2351
|
-
import { jsx as
|
|
2680
|
+
import { Skeleton as Skeleton3, Button as Button8 } from "@greatapps/greatauth-ui/ui";
|
|
2681
|
+
import { X as X2, MessageSquare } from "lucide-react";
|
|
2682
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2352
2683
|
function formatDateTime(dateStr) {
|
|
2353
2684
|
if (!dateStr) return "\u2014";
|
|
2354
2685
|
return new Date(dateStr).toLocaleString("pt-BR");
|
|
@@ -2362,68 +2693,68 @@ function ConversationView({
|
|
|
2362
2693
|
}) {
|
|
2363
2694
|
const { data: conversation, isLoading } = useConversation(config, conversationId);
|
|
2364
2695
|
if (isLoading) {
|
|
2365
|
-
return /* @__PURE__ */
|
|
2366
|
-
/* @__PURE__ */
|
|
2367
|
-
/* @__PURE__ */
|
|
2696
|
+
return /* @__PURE__ */ jsxs8("div", { className: "rounded-lg border bg-card p-4 space-y-3", children: [
|
|
2697
|
+
/* @__PURE__ */ jsx9(Skeleton3, { className: "h-6 w-48" }),
|
|
2698
|
+
/* @__PURE__ */ jsx9("div", { className: "grid grid-cols-2 gap-3", children: Array.from({ length: 6 }).map((_, i) => /* @__PURE__ */ jsx9(Skeleton3, { className: "h-10 w-full" }, i)) })
|
|
2368
2699
|
] });
|
|
2369
2700
|
}
|
|
2370
2701
|
if (!conversation) {
|
|
2371
|
-
return /* @__PURE__ */
|
|
2372
|
-
/* @__PURE__ */
|
|
2373
|
-
/* @__PURE__ */
|
|
2702
|
+
return /* @__PURE__ */ jsx9("div", { className: "rounded-lg border bg-card p-4", children: /* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between", children: [
|
|
2703
|
+
/* @__PURE__ */ jsx9("p", { className: "text-sm text-muted-foreground", children: "Conversa n\xE3o encontrada." }),
|
|
2704
|
+
/* @__PURE__ */ jsx9(Button8, { variant: "ghost", size: "icon", "aria-label": "Fechar", onClick: onClose, children: /* @__PURE__ */ jsx9(X2, { className: "h-4 w-4" }) })
|
|
2374
2705
|
] }) });
|
|
2375
2706
|
}
|
|
2376
|
-
return /* @__PURE__ */
|
|
2377
|
-
/* @__PURE__ */
|
|
2378
|
-
/* @__PURE__ */
|
|
2707
|
+
return /* @__PURE__ */ jsxs8("div", { className: "rounded-lg border bg-card p-4 space-y-4", children: [
|
|
2708
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between", children: [
|
|
2709
|
+
/* @__PURE__ */ jsxs8("h3", { className: "font-semibold", children: [
|
|
2379
2710
|
"Detalhes da conversa #",
|
|
2380
2711
|
conversation.id
|
|
2381
2712
|
] }),
|
|
2382
|
-
/* @__PURE__ */
|
|
2713
|
+
/* @__PURE__ */ jsx9("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ jsx9(Button8, { variant: "ghost", size: "icon", "aria-label": "Fechar", onClick: onClose, children: /* @__PURE__ */ jsx9(X2, { className: "h-4 w-4" }) }) })
|
|
2383
2714
|
] }),
|
|
2384
|
-
conversation.id_external ? renderChatLink ? renderChatLink(conversation.id_external) : /* @__PURE__ */
|
|
2385
|
-
/* @__PURE__ */
|
|
2715
|
+
conversation.id_external ? renderChatLink ? renderChatLink(conversation.id_external) : /* @__PURE__ */ jsx9(Button8, { variant: "outline", size: "sm", asChild: true, children: /* @__PURE__ */ jsxs8("a", { href: `/gchat/inbox/${conversation.id_external}`, children: [
|
|
2716
|
+
/* @__PURE__ */ jsx9(MessageSquare, { className: "mr-2 h-4 w-4" }),
|
|
2386
2717
|
"Ver no Chat"
|
|
2387
2718
|
] }) }) : null,
|
|
2388
|
-
/* @__PURE__ */
|
|
2389
|
-
/* @__PURE__ */
|
|
2390
|
-
/* @__PURE__ */
|
|
2391
|
-
/* @__PURE__ */
|
|
2719
|
+
/* @__PURE__ */ jsxs8("div", { className: "grid grid-cols-2 gap-x-6 gap-y-3 text-sm", children: [
|
|
2720
|
+
/* @__PURE__ */ jsxs8("div", { children: [
|
|
2721
|
+
/* @__PURE__ */ jsx9("span", { className: "text-muted-foreground", children: "Thread ID" }),
|
|
2722
|
+
/* @__PURE__ */ jsx9("p", { className: "font-mono text-xs mt-0.5", children: conversation.openai_thread_id || "\u2014" })
|
|
2392
2723
|
] }),
|
|
2393
|
-
/* @__PURE__ */
|
|
2394
|
-
/* @__PURE__ */
|
|
2395
|
-
/* @__PURE__ */
|
|
2724
|
+
/* @__PURE__ */ jsxs8("div", { children: [
|
|
2725
|
+
/* @__PURE__ */ jsx9("span", { className: "text-muted-foreground", children: "Contato" }),
|
|
2726
|
+
/* @__PURE__ */ jsx9("p", { className: "mt-0.5", children: contactsMap?.get(conversation.id_contact) ?? conversation.id_contact })
|
|
2396
2727
|
] }),
|
|
2397
|
-
/* @__PURE__ */
|
|
2398
|
-
/* @__PURE__ */
|
|
2399
|
-
/* @__PURE__ */
|
|
2728
|
+
/* @__PURE__ */ jsxs8("div", { children: [
|
|
2729
|
+
/* @__PURE__ */ jsx9("span", { className: "text-muted-foreground", children: "Agente" }),
|
|
2730
|
+
/* @__PURE__ */ jsx9("p", { className: "mt-0.5", children: conversation.id_agent ?? "\u2014" })
|
|
2400
2731
|
] }),
|
|
2401
|
-
/* @__PURE__ */
|
|
2402
|
-
/* @__PURE__ */
|
|
2403
|
-
/* @__PURE__ */
|
|
2732
|
+
/* @__PURE__ */ jsxs8("div", { children: [
|
|
2733
|
+
/* @__PURE__ */ jsx9("span", { className: "text-muted-foreground", children: "Mensagens" }),
|
|
2734
|
+
/* @__PURE__ */ jsx9("p", { className: "mt-0.5", children: conversation.message_count ?? "\u2014" })
|
|
2404
2735
|
] }),
|
|
2405
|
-
/* @__PURE__ */
|
|
2406
|
-
/* @__PURE__ */
|
|
2407
|
-
/* @__PURE__ */
|
|
2736
|
+
/* @__PURE__ */ jsxs8("div", { children: [
|
|
2737
|
+
/* @__PURE__ */ jsx9("span", { className: "text-muted-foreground", children: "Tokens" }),
|
|
2738
|
+
/* @__PURE__ */ jsx9("p", { className: "mt-0.5", children: conversation.usage_tokens ?? "\u2014" })
|
|
2408
2739
|
] }),
|
|
2409
|
-
/* @__PURE__ */
|
|
2410
|
-
/* @__PURE__ */
|
|
2411
|
-
/* @__PURE__ */
|
|
2740
|
+
/* @__PURE__ */ jsxs8("div", { children: [
|
|
2741
|
+
/* @__PURE__ */ jsx9("span", { className: "text-muted-foreground", children: "Rota\xE7\xF5es de Thread" }),
|
|
2742
|
+
/* @__PURE__ */ jsx9("p", { className: "mt-0.5", children: conversation.rotation_count ?? "\u2014" })
|
|
2412
2743
|
] }),
|
|
2413
|
-
/* @__PURE__ */
|
|
2414
|
-
/* @__PURE__ */
|
|
2415
|
-
/* @__PURE__ */
|
|
2744
|
+
/* @__PURE__ */ jsxs8("div", { children: [
|
|
2745
|
+
/* @__PURE__ */ jsx9("span", { className: "text-muted-foreground", children: "Criado em" }),
|
|
2746
|
+
/* @__PURE__ */ jsx9("p", { className: "mt-0.5", children: formatDateTime(conversation.datetime_add) })
|
|
2416
2747
|
] }),
|
|
2417
|
-
/* @__PURE__ */
|
|
2418
|
-
/* @__PURE__ */
|
|
2419
|
-
/* @__PURE__ */
|
|
2748
|
+
/* @__PURE__ */ jsxs8("div", { children: [
|
|
2749
|
+
/* @__PURE__ */ jsx9("span", { className: "text-muted-foreground", children: "Atualizado em" }),
|
|
2750
|
+
/* @__PURE__ */ jsx9("p", { className: "mt-0.5", children: formatDateTime(conversation.datetime_alt) })
|
|
2420
2751
|
] })
|
|
2421
2752
|
] })
|
|
2422
2753
|
] });
|
|
2423
2754
|
}
|
|
2424
2755
|
|
|
2425
2756
|
// src/components/conversations/agent-conversations-table.tsx
|
|
2426
|
-
import { jsx as
|
|
2757
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2427
2758
|
function formatRelativeDate(dateStr) {
|
|
2428
2759
|
if (!dateStr) return "\u2014";
|
|
2429
2760
|
const date = new Date(dateStr);
|
|
@@ -2446,29 +2777,29 @@ function AgentConversationsTable({
|
|
|
2446
2777
|
config,
|
|
2447
2778
|
renderChatLink
|
|
2448
2779
|
}) {
|
|
2449
|
-
const [selectedId, setSelectedId] =
|
|
2780
|
+
const [selectedId, setSelectedId] = useState9(null);
|
|
2450
2781
|
if (isLoading) {
|
|
2451
|
-
return /* @__PURE__ */
|
|
2782
|
+
return /* @__PURE__ */ jsx10("div", { className: "space-y-3", children: Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ jsx10(Skeleton4, { className: "h-12 w-full" }, i)) });
|
|
2452
2783
|
}
|
|
2453
2784
|
if (conversations.length === 0) {
|
|
2454
|
-
return /* @__PURE__ */
|
|
2455
|
-
/* @__PURE__ */
|
|
2456
|
-
/* @__PURE__ */
|
|
2785
|
+
return /* @__PURE__ */ jsxs9("div", { className: "flex flex-col items-center justify-center rounded-lg border border-dashed p-8 text-center", children: [
|
|
2786
|
+
/* @__PURE__ */ jsx10(MessageCircle, { className: "mb-2 h-8 w-8 text-muted-foreground" }),
|
|
2787
|
+
/* @__PURE__ */ jsx10("p", { className: "text-sm text-muted-foreground", children: "Nenhuma conversa encontrada." })
|
|
2457
2788
|
] });
|
|
2458
2789
|
}
|
|
2459
|
-
return /* @__PURE__ */
|
|
2460
|
-
/* @__PURE__ */
|
|
2461
|
-
/* @__PURE__ */
|
|
2462
|
-
/* @__PURE__ */
|
|
2463
|
-
/* @__PURE__ */
|
|
2464
|
-
/* @__PURE__ */
|
|
2465
|
-
/* @__PURE__ */
|
|
2466
|
-
/* @__PURE__ */
|
|
2467
|
-
/* @__PURE__ */
|
|
2468
|
-
/* @__PURE__ */
|
|
2469
|
-
/* @__PURE__ */
|
|
2790
|
+
return /* @__PURE__ */ jsxs9("div", { className: "space-y-4", children: [
|
|
2791
|
+
/* @__PURE__ */ jsxs9(Table, { children: [
|
|
2792
|
+
/* @__PURE__ */ jsx10(TableHeader, { children: /* @__PURE__ */ jsxs9(TableRow, { children: [
|
|
2793
|
+
/* @__PURE__ */ jsx10(TableHead, { children: "ID" }),
|
|
2794
|
+
/* @__PURE__ */ jsx10(TableHead, { children: "Contato" }),
|
|
2795
|
+
/* @__PURE__ */ jsx10(TableHead, { children: "Objetivo" }),
|
|
2796
|
+
/* @__PURE__ */ jsx10(TableHead, { className: "text-right", children: "Mensagens" }),
|
|
2797
|
+
/* @__PURE__ */ jsx10(TableHead, { className: "text-right", children: "Tokens" }),
|
|
2798
|
+
/* @__PURE__ */ jsx10(TableHead, { children: "Criado em" }),
|
|
2799
|
+
/* @__PURE__ */ jsx10(TableHead, { children: "Atualizado em" }),
|
|
2800
|
+
/* @__PURE__ */ jsx10(TableHead, { className: "w-10" })
|
|
2470
2801
|
] }) }),
|
|
2471
|
-
/* @__PURE__ */
|
|
2802
|
+
/* @__PURE__ */ jsx10(TableBody, { children: conversations.map((conversation) => /* @__PURE__ */ jsxs9(
|
|
2472
2803
|
TableRow,
|
|
2473
2804
|
{
|
|
2474
2805
|
className: "cursor-pointer",
|
|
@@ -2487,14 +2818,14 @@ function AgentConversationsTable({
|
|
|
2487
2818
|
},
|
|
2488
2819
|
"data-state": selectedId === conversation.id ? "selected" : void 0,
|
|
2489
2820
|
children: [
|
|
2490
|
-
/* @__PURE__ */
|
|
2491
|
-
/* @__PURE__ */
|
|
2492
|
-
/* @__PURE__ */
|
|
2493
|
-
/* @__PURE__ */
|
|
2494
|
-
/* @__PURE__ */
|
|
2495
|
-
/* @__PURE__ */
|
|
2496
|
-
/* @__PURE__ */
|
|
2497
|
-
/* @__PURE__ */
|
|
2821
|
+
/* @__PURE__ */ jsx10(TableCell, { className: "font-mono text-xs", children: conversation.id }),
|
|
2822
|
+
/* @__PURE__ */ jsx10(TableCell, { children: contactsMap?.get(conversation.id_contact) ?? conversation.id_contact }),
|
|
2823
|
+
/* @__PURE__ */ jsx10(TableCell, { children: conversation.id_objective && objectivesMap?.get(conversation.id_objective) ? /* @__PURE__ */ jsx10(Badge4, { variant: "secondary", className: "text-xs", children: objectivesMap.get(conversation.id_objective) }) : /* @__PURE__ */ jsx10("span", { className: "text-xs text-muted-foreground", children: "\u2014" }) }),
|
|
2824
|
+
/* @__PURE__ */ jsx10(TableCell, { className: "text-right tabular-nums", children: conversation.message_count ?? "\u2014" }),
|
|
2825
|
+
/* @__PURE__ */ jsx10(TableCell, { className: "text-right tabular-nums", children: conversation.usage_tokens ?? "\u2014" }),
|
|
2826
|
+
/* @__PURE__ */ jsx10(TableCell, { children: new Date(conversation.datetime_add).toLocaleDateString("pt-BR") }),
|
|
2827
|
+
/* @__PURE__ */ jsx10(TableCell, { children: formatRelativeDate(conversation.datetime_alt) }),
|
|
2828
|
+
/* @__PURE__ */ jsx10(TableCell, { children: conversation.id_external ? renderChatLink ? /* @__PURE__ */ jsx10("span", { onClick: (e) => e.stopPropagation(), children: renderChatLink(conversation.id_external) }) : /* @__PURE__ */ jsx10(
|
|
2498
2829
|
"a",
|
|
2499
2830
|
{
|
|
2500
2831
|
href: `/gchat/inbox/${conversation.id_external}`,
|
|
@@ -2502,7 +2833,7 @@ function AgentConversationsTable({
|
|
|
2502
2833
|
"aria-label": "Ver no Chat",
|
|
2503
2834
|
onClick: (e) => e.stopPropagation(),
|
|
2504
2835
|
className: "inline-flex items-center justify-center rounded-md p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",
|
|
2505
|
-
children: /* @__PURE__ */
|
|
2836
|
+
children: /* @__PURE__ */ jsx10(ExternalLink, { className: "h-4 w-4" })
|
|
2506
2837
|
}
|
|
2507
2838
|
) : null })
|
|
2508
2839
|
]
|
|
@@ -2510,7 +2841,7 @@ function AgentConversationsTable({
|
|
|
2510
2841
|
conversation.id
|
|
2511
2842
|
)) })
|
|
2512
2843
|
] }),
|
|
2513
|
-
selectedId && /* @__PURE__ */
|
|
2844
|
+
selectedId && /* @__PURE__ */ jsx10(
|
|
2514
2845
|
ConversationView,
|
|
2515
2846
|
{
|
|
2516
2847
|
conversationId: selectedId,
|
|
@@ -2524,7 +2855,7 @@ function AgentConversationsTable({
|
|
|
2524
2855
|
}
|
|
2525
2856
|
|
|
2526
2857
|
// src/components/conversations/agent-conversations-panel.tsx
|
|
2527
|
-
import { jsx as
|
|
2858
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
2528
2859
|
function AgentConversationsPanel({
|
|
2529
2860
|
agent,
|
|
2530
2861
|
config,
|
|
@@ -2543,7 +2874,7 @@ function AgentConversationsPanel({
|
|
|
2543
2874
|
const objectivesMap = new Map(
|
|
2544
2875
|
(objectivesData?.data || []).map((o) => [o.id, o.title])
|
|
2545
2876
|
);
|
|
2546
|
-
return /* @__PURE__ */
|
|
2877
|
+
return /* @__PURE__ */ jsx11("div", { className: "p-4", children: /* @__PURE__ */ jsx11(
|
|
2547
2878
|
AgentConversationsTable,
|
|
2548
2879
|
{
|
|
2549
2880
|
conversations,
|
|
@@ -2557,7 +2888,7 @@ function AgentConversationsPanel({
|
|
|
2557
2888
|
}
|
|
2558
2889
|
|
|
2559
2890
|
// src/components/capabilities/capabilities-tab.tsx
|
|
2560
|
-
import { useState as
|
|
2891
|
+
import { useState as useState10, useCallback as useCallback5, useEffect as useEffect4, useMemo as useMemo6 } from "react";
|
|
2561
2892
|
import {
|
|
2562
2893
|
Accordion,
|
|
2563
2894
|
AccordionItem,
|
|
@@ -2566,7 +2897,7 @@ import {
|
|
|
2566
2897
|
Switch as Switch4,
|
|
2567
2898
|
Checkbox,
|
|
2568
2899
|
Badge as Badge5,
|
|
2569
|
-
Button as
|
|
2900
|
+
Button as Button9,
|
|
2570
2901
|
Skeleton as Skeleton5
|
|
2571
2902
|
} from "@greatapps/greatauth-ui/ui";
|
|
2572
2903
|
import {
|
|
@@ -2575,12 +2906,12 @@ import {
|
|
|
2575
2906
|
Settings,
|
|
2576
2907
|
HeartHandshake,
|
|
2577
2908
|
Package,
|
|
2578
|
-
ChevronDown
|
|
2909
|
+
ChevronDown,
|
|
2579
2910
|
Loader2 as Loader24,
|
|
2580
2911
|
Pencil as Pencil3
|
|
2581
2912
|
} from "lucide-react";
|
|
2582
|
-
import { toast as
|
|
2583
|
-
import { jsx as
|
|
2913
|
+
import { toast as toast7 } from "sonner";
|
|
2914
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2584
2915
|
var OPERATION_LABELS = {
|
|
2585
2916
|
list: "Buscar",
|
|
2586
2917
|
view: "Visualizar",
|
|
@@ -2701,11 +3032,11 @@ function CapabilitiesTab({ config, agentId }) {
|
|
|
2701
3032
|
const { data: registry, isLoading: isLoadingRegistry } = useCapabilities(config);
|
|
2702
3033
|
const { data: agentCaps, isLoading: isLoadingAgent } = useAgentCapabilities(config, agentId);
|
|
2703
3034
|
const updateMutation = useUpdateAgentCapabilities(config);
|
|
2704
|
-
const [localState, setLocalState] =
|
|
2705
|
-
const [serverState, setServerState] =
|
|
2706
|
-
const [localInstructions, setLocalInstructions] =
|
|
2707
|
-
const [serverInstructions, setServerInstructions] =
|
|
2708
|
-
const [initialized, setInitialized] =
|
|
3035
|
+
const [localState, setLocalState] = useState10(/* @__PURE__ */ new Map());
|
|
3036
|
+
const [serverState, setServerState] = useState10(/* @__PURE__ */ new Map());
|
|
3037
|
+
const [localInstructions, setLocalInstructions] = useState10(/* @__PURE__ */ new Map());
|
|
3038
|
+
const [serverInstructions, setServerInstructions] = useState10(/* @__PURE__ */ new Map());
|
|
3039
|
+
const [initialized, setInitialized] = useState10(false);
|
|
2709
3040
|
useEffect4(() => {
|
|
2710
3041
|
if (agentCaps && !initialized) {
|
|
2711
3042
|
const state = buildStateFromAgent(agentCaps);
|
|
@@ -2720,17 +3051,17 @@ function CapabilitiesTab({ config, agentId }) {
|
|
|
2720
3051
|
useEffect4(() => {
|
|
2721
3052
|
setInitialized(false);
|
|
2722
3053
|
}, [agentId]);
|
|
2723
|
-
const hasChanges =
|
|
3054
|
+
const hasChanges = useMemo6(
|
|
2724
3055
|
() => initialized && (!statesEqual(localState, serverState) || !instructionsEqual(localInstructions, serverInstructions, localState)),
|
|
2725
3056
|
[localState, serverState, localInstructions, serverInstructions, initialized]
|
|
2726
3057
|
);
|
|
2727
|
-
const updateState =
|
|
3058
|
+
const updateState = useCallback5(
|
|
2728
3059
|
(updater) => {
|
|
2729
3060
|
setLocalState((prev) => updater(prev));
|
|
2730
3061
|
},
|
|
2731
3062
|
[]
|
|
2732
3063
|
);
|
|
2733
|
-
const toggleModule =
|
|
3064
|
+
const toggleModule = useCallback5(
|
|
2734
3065
|
(mod, enabled) => {
|
|
2735
3066
|
updateState((prev) => {
|
|
2736
3067
|
const next = cloneState(prev);
|
|
@@ -2744,7 +3075,7 @@ function CapabilitiesTab({ config, agentId }) {
|
|
|
2744
3075
|
},
|
|
2745
3076
|
[updateState]
|
|
2746
3077
|
);
|
|
2747
|
-
const toggleOperation =
|
|
3078
|
+
const toggleOperation = useCallback5(
|
|
2748
3079
|
(mod, opSlug, enabled) => {
|
|
2749
3080
|
updateState((prev) => {
|
|
2750
3081
|
const next = cloneState(prev);
|
|
@@ -2764,7 +3095,7 @@ function CapabilitiesTab({ config, agentId }) {
|
|
|
2764
3095
|
},
|
|
2765
3096
|
[updateState]
|
|
2766
3097
|
);
|
|
2767
|
-
const updateOperationInstruction =
|
|
3098
|
+
const updateOperationInstruction = useCallback5(
|
|
2768
3099
|
(moduleSlug, opSlug, instruction) => {
|
|
2769
3100
|
setLocalInstructions((prev) => {
|
|
2770
3101
|
const next = cloneInstructions(prev);
|
|
@@ -2776,7 +3107,7 @@ function CapabilitiesTab({ config, agentId }) {
|
|
|
2776
3107
|
},
|
|
2777
3108
|
[]
|
|
2778
3109
|
);
|
|
2779
|
-
const enableAll =
|
|
3110
|
+
const enableAll = useCallback5(() => {
|
|
2780
3111
|
if (!registry) return;
|
|
2781
3112
|
updateState(() => {
|
|
2782
3113
|
const next = /* @__PURE__ */ new Map();
|
|
@@ -2788,14 +3119,14 @@ function CapabilitiesTab({ config, agentId }) {
|
|
|
2788
3119
|
return next;
|
|
2789
3120
|
});
|
|
2790
3121
|
}, [registry, updateState]);
|
|
2791
|
-
const disableAll =
|
|
3122
|
+
const disableAll = useCallback5(() => {
|
|
2792
3123
|
updateState(() => /* @__PURE__ */ new Map());
|
|
2793
3124
|
}, [updateState]);
|
|
2794
|
-
const discard =
|
|
3125
|
+
const discard = useCallback5(() => {
|
|
2795
3126
|
setLocalState(cloneState(serverState));
|
|
2796
3127
|
setLocalInstructions(cloneInstructions(serverInstructions));
|
|
2797
3128
|
}, [serverState, serverInstructions]);
|
|
2798
|
-
const saveNow =
|
|
3129
|
+
const saveNow = useCallback5(() => {
|
|
2799
3130
|
const payload = stateToPayload(localState, localInstructions);
|
|
2800
3131
|
updateMutation.mutate(
|
|
2801
3132
|
{ agentId, payload },
|
|
@@ -2803,12 +3134,12 @@ function CapabilitiesTab({ config, agentId }) {
|
|
|
2803
3134
|
onSuccess: () => {
|
|
2804
3135
|
setServerState(cloneState(localState));
|
|
2805
3136
|
setServerInstructions(cloneInstructions(localInstructions));
|
|
2806
|
-
|
|
3137
|
+
toast7.success("Capacidades salvas");
|
|
2807
3138
|
},
|
|
2808
3139
|
onError: () => {
|
|
2809
3140
|
setLocalState(cloneState(serverState));
|
|
2810
3141
|
setLocalInstructions(cloneInstructions(serverInstructions));
|
|
2811
|
-
|
|
3142
|
+
toast7.error("Erro ao salvar capacidades");
|
|
2812
3143
|
}
|
|
2813
3144
|
}
|
|
2814
3145
|
);
|
|
@@ -2817,52 +3148,52 @@ function CapabilitiesTab({ config, agentId }) {
|
|
|
2817
3148
|
return cat.modules.filter((m) => (localState.get(m.slug)?.size ?? 0) > 0).length;
|
|
2818
3149
|
}
|
|
2819
3150
|
if (isLoadingRegistry || isLoadingAgent) {
|
|
2820
|
-
return /* @__PURE__ */
|
|
3151
|
+
return /* @__PURE__ */ jsx12("div", { className: "space-y-3", children: [1, 2, 3, 4].map((i) => /* @__PURE__ */ jsx12(Skeleton5, { className: "h-14 w-full" }, i)) });
|
|
2821
3152
|
}
|
|
2822
3153
|
if (!registry || !registry.categories.length) {
|
|
2823
|
-
return /* @__PURE__ */
|
|
2824
|
-
/* @__PURE__ */
|
|
2825
|
-
/* @__PURE__ */
|
|
2826
|
-
/* @__PURE__ */
|
|
3154
|
+
return /* @__PURE__ */ jsxs10("div", { className: "flex flex-col items-center justify-center py-12 text-center", children: [
|
|
3155
|
+
/* @__PURE__ */ jsx12(Package, { className: "h-12 w-12 text-muted-foreground mb-3" }),
|
|
3156
|
+
/* @__PURE__ */ jsx12("h3", { className: "text-base font-medium", children: "Nenhuma capacidade dispon\xEDvel" }),
|
|
3157
|
+
/* @__PURE__ */ jsx12("p", { className: "text-sm text-muted-foreground mt-1 max-w-sm", children: "Este produto ainda n\xE3o possui capacidades registadas. As capacidades ser\xE3o adicionadas automaticamente quando o produto for configurado." })
|
|
2827
3158
|
] });
|
|
2828
3159
|
}
|
|
2829
|
-
return /* @__PURE__ */
|
|
2830
|
-
/* @__PURE__ */
|
|
2831
|
-
/* @__PURE__ */
|
|
2832
|
-
/* @__PURE__ */
|
|
2833
|
-
/* @__PURE__ */
|
|
3160
|
+
return /* @__PURE__ */ jsxs10("div", { className: "space-y-4", children: [
|
|
3161
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between", children: [
|
|
3162
|
+
/* @__PURE__ */ jsxs10("div", { children: [
|
|
3163
|
+
/* @__PURE__ */ jsx12("h3", { className: "text-sm font-medium", children: "Capacidades do agente" }),
|
|
3164
|
+
/* @__PURE__ */ jsx12("p", { className: "text-xs text-muted-foreground mt-0.5", children: "Ative ou desative m\xF3dulos e opera\xE7\xF5es dispon\xEDveis para este agente." })
|
|
2834
3165
|
] }),
|
|
2835
|
-
/* @__PURE__ */
|
|
2836
|
-
/* @__PURE__ */
|
|
2837
|
-
/* @__PURE__ */
|
|
3166
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2", children: [
|
|
3167
|
+
/* @__PURE__ */ jsx12(Button9, { variant: "outline", size: "sm", onClick: enableAll, children: "Ativar tudo" }),
|
|
3168
|
+
/* @__PURE__ */ jsx12(Button9, { variant: "outline", size: "sm", onClick: disableAll, children: "Desativar tudo" })
|
|
2838
3169
|
] })
|
|
2839
3170
|
] }),
|
|
2840
|
-
/* @__PURE__ */
|
|
3171
|
+
/* @__PURE__ */ jsx12(Accordion, { type: "multiple", className: "space-y-2", children: registry.categories.map((cat) => {
|
|
2841
3172
|
const Icon = getCategoryIcon(cat.slug);
|
|
2842
3173
|
const activeCount = countActiveModules(cat);
|
|
2843
3174
|
const totalModules = cat.modules.length;
|
|
2844
|
-
return /* @__PURE__ */
|
|
3175
|
+
return /* @__PURE__ */ jsxs10(
|
|
2845
3176
|
AccordionItem,
|
|
2846
3177
|
{
|
|
2847
3178
|
value: cat.slug,
|
|
2848
3179
|
className: "border rounded-lg px-4",
|
|
2849
3180
|
children: [
|
|
2850
|
-
/* @__PURE__ */
|
|
2851
|
-
/* @__PURE__ */
|
|
2852
|
-
/* @__PURE__ */
|
|
2853
|
-
/* @__PURE__ */
|
|
3181
|
+
/* @__PURE__ */ jsx12(AccordionTrigger, { className: "hover:no-underline py-3", children: /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-3 flex-1", children: [
|
|
3182
|
+
/* @__PURE__ */ jsx12(Icon, { className: "h-4 w-4 text-muted-foreground" }),
|
|
3183
|
+
/* @__PURE__ */ jsx12("span", { className: "font-medium text-sm", children: cat.label }),
|
|
3184
|
+
/* @__PURE__ */ jsxs10(Badge5, { variant: "secondary", className: "text-xs", children: [
|
|
2854
3185
|
activeCount,
|
|
2855
3186
|
" de ",
|
|
2856
3187
|
totalModules,
|
|
2857
3188
|
" m\xF3dulos ativos"
|
|
2858
3189
|
] })
|
|
2859
3190
|
] }) }),
|
|
2860
|
-
/* @__PURE__ */
|
|
3191
|
+
/* @__PURE__ */ jsx12(AccordionContent, { className: "pb-3 !h-auto", children: /* @__PURE__ */ jsx12("div", { className: "space-y-1", children: cat.modules.map((mod) => {
|
|
2861
3192
|
const enabledOps = localState.get(mod.slug);
|
|
2862
3193
|
const isModuleOn = (enabledOps?.size ?? 0) > 0;
|
|
2863
3194
|
const allOpsEnabled = enabledOps?.size === mod.operations.length;
|
|
2864
3195
|
const modInstructions = localInstructions.get(mod.slug) ?? {};
|
|
2865
|
-
return /* @__PURE__ */
|
|
3196
|
+
return /* @__PURE__ */ jsx12(
|
|
2866
3197
|
ModuleRow,
|
|
2867
3198
|
{
|
|
2868
3199
|
module: mod,
|
|
@@ -2882,12 +3213,12 @@ function CapabilitiesTab({ config, agentId }) {
|
|
|
2882
3213
|
cat.slug
|
|
2883
3214
|
);
|
|
2884
3215
|
}) }),
|
|
2885
|
-
hasChanges && /* @__PURE__ */
|
|
2886
|
-
/* @__PURE__ */
|
|
2887
|
-
/* @__PURE__ */
|
|
2888
|
-
/* @__PURE__ */
|
|
2889
|
-
/* @__PURE__ */
|
|
2890
|
-
updateMutation.isPending && /* @__PURE__ */
|
|
3216
|
+
hasChanges && /* @__PURE__ */ jsxs10("div", { className: "sticky bottom-0 z-10 flex items-center justify-between gap-2 rounded-lg border bg-background p-3 shadow-sm", children: [
|
|
3217
|
+
/* @__PURE__ */ jsx12("p", { className: "text-sm text-muted-foreground", children: "Voc\xEA tem altera\xE7\xF5es n\xE3o salvas." }),
|
|
3218
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex gap-2", children: [
|
|
3219
|
+
/* @__PURE__ */ jsx12(Button9, { variant: "ghost", size: "sm", onClick: discard, disabled: updateMutation.isPending, children: "Descartar" }),
|
|
3220
|
+
/* @__PURE__ */ jsxs10(Button9, { size: "sm", onClick: saveNow, disabled: updateMutation.isPending, children: [
|
|
3221
|
+
updateMutation.isPending && /* @__PURE__ */ jsx12(Loader24, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
2891
3222
|
"Salvar"
|
|
2892
3223
|
] })
|
|
2893
3224
|
] })
|
|
@@ -2903,11 +3234,11 @@ function ModuleRow({
|
|
|
2903
3234
|
onToggleOperation,
|
|
2904
3235
|
onUpdateInstruction
|
|
2905
3236
|
}) {
|
|
2906
|
-
const [expanded, setExpanded] =
|
|
2907
|
-
const [editingOp, setEditingOp] =
|
|
2908
|
-
return /* @__PURE__ */
|
|
2909
|
-
/* @__PURE__ */
|
|
2910
|
-
/* @__PURE__ */
|
|
3237
|
+
const [expanded, setExpanded] = useState10(false);
|
|
3238
|
+
const [editingOp, setEditingOp] = useState10(null);
|
|
3239
|
+
return /* @__PURE__ */ jsxs10("div", { className: "rounded-md border px-3 py-2", children: [
|
|
3240
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between", children: [
|
|
3241
|
+
/* @__PURE__ */ jsxs10(
|
|
2911
3242
|
"button",
|
|
2912
3243
|
{
|
|
2913
3244
|
type: "button",
|
|
@@ -2916,18 +3247,18 @@ function ModuleRow({
|
|
|
2916
3247
|
"aria-expanded": expanded,
|
|
2917
3248
|
"aria-label": `Expandir ${mod.label}`,
|
|
2918
3249
|
children: [
|
|
2919
|
-
/* @__PURE__ */
|
|
2920
|
-
|
|
3250
|
+
/* @__PURE__ */ jsx12(
|
|
3251
|
+
ChevronDown,
|
|
2921
3252
|
{
|
|
2922
3253
|
className: `h-3.5 w-3.5 text-muted-foreground transition-transform ${expanded ? "rotate-0" : "-rotate-90"}`
|
|
2923
3254
|
}
|
|
2924
3255
|
),
|
|
2925
|
-
/* @__PURE__ */
|
|
2926
|
-
mod.description && /* @__PURE__ */
|
|
3256
|
+
/* @__PURE__ */ jsx12("span", { className: "text-sm font-medium", children: mod.label }),
|
|
3257
|
+
mod.description && /* @__PURE__ */ jsxs10("span", { className: "text-xs text-muted-foreground hidden sm:inline", children: [
|
|
2927
3258
|
"\u2014 ",
|
|
2928
3259
|
mod.description
|
|
2929
3260
|
] }),
|
|
2930
|
-
isOn && /* @__PURE__ */
|
|
3261
|
+
isOn && /* @__PURE__ */ jsxs10(Badge5, { variant: "secondary", className: "text-xs ml-1", children: [
|
|
2931
3262
|
enabledOps.size,
|
|
2932
3263
|
"/",
|
|
2933
3264
|
mod.operations.length
|
|
@@ -2935,7 +3266,7 @@ function ModuleRow({
|
|
|
2935
3266
|
]
|
|
2936
3267
|
}
|
|
2937
3268
|
),
|
|
2938
|
-
/* @__PURE__ */
|
|
3269
|
+
/* @__PURE__ */ jsx12(
|
|
2939
3270
|
Switch4,
|
|
2940
3271
|
{
|
|
2941
3272
|
checked: isOn,
|
|
@@ -2944,14 +3275,14 @@ function ModuleRow({
|
|
|
2944
3275
|
}
|
|
2945
3276
|
)
|
|
2946
3277
|
] }),
|
|
2947
|
-
expanded && /* @__PURE__ */
|
|
3278
|
+
expanded && /* @__PURE__ */ jsx12("div", { className: "mt-2 ml-6 space-y-1.5 pb-1", children: mod.operations.map((op) => {
|
|
2948
3279
|
const checked = enabledOps.has(op);
|
|
2949
3280
|
const fnSlug = getOperationFunctionSlug(op, mod.slug);
|
|
2950
3281
|
const isEditing = editingOp === op;
|
|
2951
3282
|
const currentInstruction = instructions[op] ?? getDefaultInstruction(op, mod.label);
|
|
2952
|
-
return /* @__PURE__ */
|
|
2953
|
-
/* @__PURE__ */
|
|
2954
|
-
/* @__PURE__ */
|
|
3283
|
+
return /* @__PURE__ */ jsxs10("div", { className: "space-y-1", children: [
|
|
3284
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-1.5", children: [
|
|
3285
|
+
/* @__PURE__ */ jsx12(
|
|
2955
3286
|
Checkbox,
|
|
2956
3287
|
{
|
|
2957
3288
|
checked,
|
|
@@ -2959,24 +3290,24 @@ function ModuleRow({
|
|
|
2959
3290
|
"aria-label": `${getOperationLabel(op)} em ${mod.label}`
|
|
2960
3291
|
}
|
|
2961
3292
|
),
|
|
2962
|
-
/* @__PURE__ */
|
|
2963
|
-
/* @__PURE__ */
|
|
3293
|
+
/* @__PURE__ */ jsx12("span", { className: cn("text-sm", checked ? "" : "text-muted-foreground"), children: getOperationLabel(op) }),
|
|
3294
|
+
/* @__PURE__ */ jsxs10("span", { className: "text-xs text-muted-foreground", children: [
|
|
2964
3295
|
"(",
|
|
2965
3296
|
fnSlug,
|
|
2966
3297
|
")"
|
|
2967
3298
|
] }),
|
|
2968
|
-
/* @__PURE__ */
|
|
3299
|
+
/* @__PURE__ */ jsx12(
|
|
2969
3300
|
"button",
|
|
2970
3301
|
{
|
|
2971
3302
|
type: "button",
|
|
2972
3303
|
className: "p-0.5 rounded hover:bg-muted/50 transition-colors ml-auto",
|
|
2973
3304
|
onClick: () => setEditingOp(isEditing ? null : op),
|
|
2974
3305
|
"aria-label": `Editar instru\xE7\xF5es de ${getOperationLabel(op)}`,
|
|
2975
|
-
children: /* @__PURE__ */
|
|
3306
|
+
children: /* @__PURE__ */ jsx12(Pencil3, { className: "h-3 w-3 text-muted-foreground" })
|
|
2976
3307
|
}
|
|
2977
3308
|
)
|
|
2978
3309
|
] }),
|
|
2979
|
-
isEditing && /* @__PURE__ */
|
|
3310
|
+
isEditing && /* @__PURE__ */ jsx12("div", { className: "ml-5", children: /* @__PURE__ */ jsx12(
|
|
2980
3311
|
"textarea",
|
|
2981
3312
|
{
|
|
2982
3313
|
className: "w-full rounded-md border bg-background px-3 py-2 text-sm resize-y min-h-[56px] focus:outline-none focus:ring-1 focus:ring-ring",
|
|
@@ -2992,12 +3323,12 @@ function ModuleRow({
|
|
|
2992
3323
|
}
|
|
2993
3324
|
|
|
2994
3325
|
// src/components/capabilities/integrations-tab.tsx
|
|
2995
|
-
import { useCallback as
|
|
2996
|
-
import { Switch as Switch5, Tooltip as Tooltip2, TooltipContent as TooltipContent2, TooltipTrigger as TooltipTrigger2, Checkbox as Checkbox2, Button as
|
|
2997
|
-
import { Plug, Loader2 as Loader25, ChevronDown as
|
|
2998
|
-
import { toast as
|
|
3326
|
+
import { useCallback as useCallback6, useState as useState11, useEffect as useEffect5, useMemo as useMemo7 } from "react";
|
|
3327
|
+
import { Switch as Switch5, Tooltip as Tooltip2, TooltipContent as TooltipContent2, TooltipTrigger as TooltipTrigger2, Checkbox as Checkbox2, Button as Button10 } from "@greatapps/greatauth-ui/ui";
|
|
3328
|
+
import { Plug, Loader2 as Loader25, ChevronDown as ChevronDown2, Pencil as Pencil4 } from "lucide-react";
|
|
3329
|
+
import { toast as toast8 } from "sonner";
|
|
2999
3330
|
import { CalendarSync } from "lucide-react";
|
|
3000
|
-
import { jsx as
|
|
3331
|
+
import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3001
3332
|
var ICON_MAP = {
|
|
3002
3333
|
CalendarSync,
|
|
3003
3334
|
Plug
|
|
@@ -3013,17 +3344,19 @@ var INTEGRATION_FUNCTIONS = {
|
|
|
3013
3344
|
{ slug: "delete_google_calendar_event", label: "Remover Evento", description: "Cancelar/remover evento", defaultInstructions: "Remover evento do Google Calendar" }
|
|
3014
3345
|
]
|
|
3015
3346
|
};
|
|
3016
|
-
function buildCustomInstructions(integrationSlug, selectedFunctions, functionInstructions) {
|
|
3347
|
+
function buildCustomInstructions(integrationSlug, integrationName, selectedFunctions, functionInstructions) {
|
|
3017
3348
|
const fns = INTEGRATION_FUNCTIONS[integrationSlug];
|
|
3018
3349
|
if (!fns) return "";
|
|
3019
3350
|
const activeFns = fns.filter((f) => selectedFunctions.has(f.slug));
|
|
3020
3351
|
if (activeFns.length === 0) return "";
|
|
3021
|
-
const lines =
|
|
3352
|
+
const lines = [];
|
|
3353
|
+
lines.push(`## ${integrationName} (${integrationSlug})`);
|
|
3354
|
+
for (const f of activeFns) {
|
|
3022
3355
|
const instruction = functionInstructions[f.slug] || f.defaultInstructions;
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3356
|
+
lines.push(`### ${f.slug}`);
|
|
3357
|
+
lines.push(instruction);
|
|
3358
|
+
}
|
|
3359
|
+
return lines.join("\n");
|
|
3027
3360
|
}
|
|
3028
3361
|
function IntegrationsTab({
|
|
3029
3362
|
config,
|
|
@@ -3038,12 +3371,12 @@ function IntegrationsTab({
|
|
|
3038
3371
|
const createTool = useCreateTool(config);
|
|
3039
3372
|
const agentTools = agentToolsData?.data ?? [];
|
|
3040
3373
|
const allTools = toolsData?.data ?? [];
|
|
3041
|
-
const [localState, setLocalState] =
|
|
3042
|
-
const [serverState, setServerState] =
|
|
3043
|
-
const [initialized, setInitialized] =
|
|
3044
|
-
const [isSaving, setIsSaving] =
|
|
3045
|
-
const [editingFunction, setEditingFunction] =
|
|
3046
|
-
const [expandedCards, setExpandedCards] =
|
|
3374
|
+
const [localState, setLocalState] = useState11({});
|
|
3375
|
+
const [serverState, setServerState] = useState11({});
|
|
3376
|
+
const [initialized, setInitialized] = useState11(false);
|
|
3377
|
+
const [isSaving, setIsSaving] = useState11(false);
|
|
3378
|
+
const [editingFunction, setEditingFunction] = useState11(null);
|
|
3379
|
+
const [expandedCards, setExpandedCards] = useState11(/* @__PURE__ */ new Set());
|
|
3047
3380
|
const connectedCards = cards.filter(
|
|
3048
3381
|
(c) => !c.isAddNew && (c.state === "connected" || c.state === "expired")
|
|
3049
3382
|
);
|
|
@@ -3080,7 +3413,7 @@ function IntegrationsTab({
|
|
|
3080
3413
|
setServerState(JSON.parse(JSON.stringify(state, (_k, v) => v instanceof Set ? [...v] : v)));
|
|
3081
3414
|
setInitialized(true);
|
|
3082
3415
|
}, [connectedCards, agentTools, initialized]);
|
|
3083
|
-
const hasChanges =
|
|
3416
|
+
const hasChanges = useMemo7(() => {
|
|
3084
3417
|
if (!initialized) return false;
|
|
3085
3418
|
const localKeys = Object.keys(localState);
|
|
3086
3419
|
for (const slug of localKeys) {
|
|
@@ -3099,7 +3432,7 @@ function IntegrationsTab({
|
|
|
3099
3432
|
}
|
|
3100
3433
|
return false;
|
|
3101
3434
|
}, [localState, serverState, initialized]);
|
|
3102
|
-
const handleToggle =
|
|
3435
|
+
const handleToggle = useCallback6(
|
|
3103
3436
|
(card, checked) => {
|
|
3104
3437
|
const slug = card.definition.slug;
|
|
3105
3438
|
setLocalState((prev) => ({
|
|
@@ -3115,7 +3448,7 @@ function IntegrationsTab({
|
|
|
3115
3448
|
},
|
|
3116
3449
|
[]
|
|
3117
3450
|
);
|
|
3118
|
-
const handleToggleFunction =
|
|
3451
|
+
const handleToggleFunction = useCallback6(
|
|
3119
3452
|
(slug, fnSlug, checked) => {
|
|
3120
3453
|
setLocalState((prev) => {
|
|
3121
3454
|
const current = prev[slug];
|
|
@@ -3128,7 +3461,7 @@ function IntegrationsTab({
|
|
|
3128
3461
|
},
|
|
3129
3462
|
[]
|
|
3130
3463
|
);
|
|
3131
|
-
const handleUpdateInstruction =
|
|
3464
|
+
const handleUpdateInstruction = useCallback6(
|
|
3132
3465
|
(slug, fnSlug, instruction) => {
|
|
3133
3466
|
setLocalState((prev) => {
|
|
3134
3467
|
const current = prev[slug];
|
|
@@ -3144,7 +3477,7 @@ function IntegrationsTab({
|
|
|
3144
3477
|
},
|
|
3145
3478
|
[]
|
|
3146
3479
|
);
|
|
3147
|
-
const saveNow =
|
|
3480
|
+
const saveNow = useCallback6(async () => {
|
|
3148
3481
|
setIsSaving(true);
|
|
3149
3482
|
try {
|
|
3150
3483
|
for (const slug of Object.keys(localState)) {
|
|
@@ -3171,7 +3504,7 @@ function IntegrationsTab({
|
|
|
3171
3504
|
if (!toolId) continue;
|
|
3172
3505
|
}
|
|
3173
3506
|
}
|
|
3174
|
-
const customInstructions = buildCustomInstructions(slug, local.selectedFunctions, local.functionInstructions);
|
|
3507
|
+
const customInstructions = buildCustomInstructions(slug, card.definition.name, local.selectedFunctions, local.functionInstructions);
|
|
3175
3508
|
await addAgentTool.mutateAsync({
|
|
3176
3509
|
idAgent: agentId,
|
|
3177
3510
|
body: { id_tool: toolId, enabled: true, ...customInstructions ? { custom_instructions: customInstructions } : {} }
|
|
@@ -3189,7 +3522,7 @@ function IntegrationsTab({
|
|
|
3189
3522
|
if (toolId) {
|
|
3190
3523
|
const agentTool = agentTools.find((at) => at.id_tool === toolId);
|
|
3191
3524
|
if (agentTool) {
|
|
3192
|
-
const customInstructions = buildCustomInstructions(slug, local.selectedFunctions, local.functionInstructions);
|
|
3525
|
+
const customInstructions = buildCustomInstructions(slug, card.definition.name, local.selectedFunctions, local.functionInstructions);
|
|
3193
3526
|
await updateAgentTool.mutateAsync({
|
|
3194
3527
|
idAgent: agentId,
|
|
3195
3528
|
id: agentTool.id,
|
|
@@ -3200,14 +3533,14 @@ function IntegrationsTab({
|
|
|
3200
3533
|
}
|
|
3201
3534
|
}
|
|
3202
3535
|
setServerState(JSON.parse(JSON.stringify(localState, (_k, v) => v instanceof Set ? [...v] : v)));
|
|
3203
|
-
|
|
3536
|
+
toast8.success("Integra\xE7\xF5es salvas");
|
|
3204
3537
|
} catch {
|
|
3205
|
-
|
|
3538
|
+
toast8.error("Erro ao salvar integra\xE7\xF5es");
|
|
3206
3539
|
} finally {
|
|
3207
3540
|
setIsSaving(false);
|
|
3208
3541
|
}
|
|
3209
3542
|
}, [localState, serverState, connectedCards, allTools, agentTools, agentId, addAgentTool, removeAgentTool, updateAgentTool, createTool]);
|
|
3210
|
-
const discard =
|
|
3543
|
+
const discard = useCallback6(() => {
|
|
3211
3544
|
const restored = {};
|
|
3212
3545
|
for (const [slug, entry] of Object.entries(serverState)) {
|
|
3213
3546
|
restored[slug] = {
|
|
@@ -3218,18 +3551,18 @@ function IntegrationsTab({
|
|
|
3218
3551
|
setLocalState(restored);
|
|
3219
3552
|
}, [serverState]);
|
|
3220
3553
|
if (isLoading || agentToolsLoading) {
|
|
3221
|
-
return /* @__PURE__ */
|
|
3554
|
+
return /* @__PURE__ */ jsx13("div", { className: "flex items-center justify-center py-16", children: /* @__PURE__ */ jsx13(Loader25, { className: "h-6 w-6 animate-spin text-muted-foreground" }) });
|
|
3222
3555
|
}
|
|
3223
3556
|
if (connectedCards.length === 0) {
|
|
3224
|
-
return /* @__PURE__ */
|
|
3225
|
-
/* @__PURE__ */
|
|
3226
|
-
/* @__PURE__ */
|
|
3227
|
-
/* @__PURE__ */
|
|
3557
|
+
return /* @__PURE__ */ jsxs11("div", { className: "flex flex-col items-center justify-center gap-3 py-16 text-muted-foreground", children: [
|
|
3558
|
+
/* @__PURE__ */ jsx13(Plug, { className: "h-10 w-10" }),
|
|
3559
|
+
/* @__PURE__ */ jsx13("p", { className: "text-sm font-medium", children: "Nenhuma integra\xE7\xE3o conectada" }),
|
|
3560
|
+
/* @__PURE__ */ jsx13("p", { className: "text-xs text-center max-w-sm", children: "Conecte integra\xE7\xF5es na p\xE1gina de Integra\xE7\xF5es da conta para que possam ser ativadas neste agente." })
|
|
3228
3561
|
] });
|
|
3229
3562
|
}
|
|
3230
|
-
return /* @__PURE__ */
|
|
3231
|
-
/* @__PURE__ */
|
|
3232
|
-
/* @__PURE__ */
|
|
3563
|
+
return /* @__PURE__ */ jsxs11("div", { className: "space-y-4", children: [
|
|
3564
|
+
/* @__PURE__ */ jsx13("p", { className: "text-xs text-muted-foreground", children: "Ative ou desative as integra\xE7\xF5es conectadas na conta para este agente." }),
|
|
3565
|
+
/* @__PURE__ */ jsx13("div", { className: "grid grid-cols-1 gap-3", children: connectedCards.map((card) => {
|
|
3233
3566
|
const Icon = resolveIcon(card.definition.icon);
|
|
3234
3567
|
const integrationSlug = card.definition.slug;
|
|
3235
3568
|
const local = localState[integrationSlug];
|
|
@@ -3238,7 +3571,7 @@ function IntegrationsTab({
|
|
|
3238
3571
|
const isExpanded = expandedCards.has(integrationSlug);
|
|
3239
3572
|
const selected = local?.selectedFunctions ?? /* @__PURE__ */ new Set();
|
|
3240
3573
|
const instructions = local?.functionInstructions ?? {};
|
|
3241
|
-
return /* @__PURE__ */
|
|
3574
|
+
return /* @__PURE__ */ jsxs11(
|
|
3242
3575
|
"div",
|
|
3243
3576
|
{
|
|
3244
3577
|
className: cn(
|
|
@@ -3246,17 +3579,17 @@ function IntegrationsTab({
|
|
|
3246
3579
|
isLinked ? "border-primary/30 shadow-sm" : "opacity-75"
|
|
3247
3580
|
),
|
|
3248
3581
|
children: [
|
|
3249
|
-
/* @__PURE__ */
|
|
3250
|
-
/* @__PURE__ */
|
|
3251
|
-
/* @__PURE__ */
|
|
3252
|
-
/* @__PURE__ */
|
|
3253
|
-
card.accountLabel && /* @__PURE__ */
|
|
3254
|
-
/* @__PURE__ */
|
|
3255
|
-
/* @__PURE__ */
|
|
3582
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-3 p-4", children: [
|
|
3583
|
+
/* @__PURE__ */ jsx13("div", { className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary", children: /* @__PURE__ */ jsx13(Icon, { className: "h-4.5 w-4.5" }) }),
|
|
3584
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex-1 min-w-0", children: [
|
|
3585
|
+
/* @__PURE__ */ jsx13("h4", { className: "text-sm font-medium leading-tight truncate", children: card.definition.name }),
|
|
3586
|
+
card.accountLabel && /* @__PURE__ */ jsxs11(Tooltip2, { children: [
|
|
3587
|
+
/* @__PURE__ */ jsx13(TooltipTrigger2, { asChild: true, children: /* @__PURE__ */ jsx13("p", { className: "text-xs text-muted-foreground truncate", title: card.accountLabel, children: card.accountLabel }) }),
|
|
3588
|
+
/* @__PURE__ */ jsx13(TooltipContent2, { children: card.accountLabel })
|
|
3256
3589
|
] }),
|
|
3257
|
-
card.state === "expired" && /* @__PURE__ */
|
|
3590
|
+
card.state === "expired" && /* @__PURE__ */ jsx13("p", { className: "text-xs text-amber-600 dark:text-amber-400", children: "Expirado" })
|
|
3258
3591
|
] }),
|
|
3259
|
-
isLinked && fns && /* @__PURE__ */
|
|
3592
|
+
isLinked && fns && /* @__PURE__ */ jsx13(
|
|
3260
3593
|
"button",
|
|
3261
3594
|
{
|
|
3262
3595
|
type: "button",
|
|
@@ -3271,8 +3604,8 @@ function IntegrationsTab({
|
|
|
3271
3604
|
return next;
|
|
3272
3605
|
}),
|
|
3273
3606
|
"aria-label": "Expandir fun\xE7\xF5es",
|
|
3274
|
-
children: /* @__PURE__ */
|
|
3275
|
-
|
|
3607
|
+
children: /* @__PURE__ */ jsx13(
|
|
3608
|
+
ChevronDown2,
|
|
3276
3609
|
{
|
|
3277
3610
|
className: cn(
|
|
3278
3611
|
"h-4 w-4 text-muted-foreground transition-transform",
|
|
@@ -3282,7 +3615,7 @@ function IntegrationsTab({
|
|
|
3282
3615
|
)
|
|
3283
3616
|
}
|
|
3284
3617
|
),
|
|
3285
|
-
/* @__PURE__ */
|
|
3618
|
+
/* @__PURE__ */ jsx13(
|
|
3286
3619
|
Switch5,
|
|
3287
3620
|
{
|
|
3288
3621
|
checked: isLinked,
|
|
@@ -3292,15 +3625,15 @@ function IntegrationsTab({
|
|
|
3292
3625
|
}
|
|
3293
3626
|
)
|
|
3294
3627
|
] }),
|
|
3295
|
-
isLinked && fns && isExpanded && /* @__PURE__ */
|
|
3296
|
-
/* @__PURE__ */
|
|
3628
|
+
isLinked && fns && isExpanded && /* @__PURE__ */ jsxs11("div", { className: "border-t px-4 py-3 space-y-2", children: [
|
|
3629
|
+
/* @__PURE__ */ jsx13("p", { className: "text-xs text-muted-foreground mb-2", children: "Selecione as fun\xE7\xF5es dispon\xEDveis para o agente:" }),
|
|
3297
3630
|
fns.map((fn) => {
|
|
3298
3631
|
const isSelected = selected.has(fn.slug);
|
|
3299
3632
|
const isEditing = editingFunction === `${integrationSlug}:${fn.slug}`;
|
|
3300
3633
|
const currentInstruction = instructions[fn.slug] ?? fn.defaultInstructions;
|
|
3301
|
-
return /* @__PURE__ */
|
|
3302
|
-
/* @__PURE__ */
|
|
3303
|
-
/* @__PURE__ */
|
|
3634
|
+
return /* @__PURE__ */ jsxs11("div", { className: "space-y-1", children: [
|
|
3635
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2", children: [
|
|
3636
|
+
/* @__PURE__ */ jsx13(
|
|
3304
3637
|
Checkbox2,
|
|
3305
3638
|
{
|
|
3306
3639
|
checked: isSelected,
|
|
@@ -3308,15 +3641,15 @@ function IntegrationsTab({
|
|
|
3308
3641
|
"aria-label": fn.label
|
|
3309
3642
|
}
|
|
3310
3643
|
),
|
|
3311
|
-
/* @__PURE__ */
|
|
3312
|
-
/* @__PURE__ */
|
|
3313
|
-
/* @__PURE__ */
|
|
3644
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex-1 min-w-0", children: [
|
|
3645
|
+
/* @__PURE__ */ jsx13("span", { className: cn("text-sm", isSelected ? "" : "text-muted-foreground"), children: fn.label }),
|
|
3646
|
+
/* @__PURE__ */ jsxs11("span", { className: "text-xs text-muted-foreground ml-1.5", children: [
|
|
3314
3647
|
"(",
|
|
3315
3648
|
fn.slug,
|
|
3316
3649
|
")"
|
|
3317
3650
|
] })
|
|
3318
3651
|
] }),
|
|
3319
|
-
/* @__PURE__ */
|
|
3652
|
+
/* @__PURE__ */ jsx13(
|
|
3320
3653
|
"button",
|
|
3321
3654
|
{
|
|
3322
3655
|
type: "button",
|
|
@@ -3325,11 +3658,11 @@ function IntegrationsTab({
|
|
|
3325
3658
|
isEditing ? null : `${integrationSlug}:${fn.slug}`
|
|
3326
3659
|
),
|
|
3327
3660
|
"aria-label": `Editar instru\xE7\xF5es de ${fn.label}`,
|
|
3328
|
-
children: /* @__PURE__ */
|
|
3661
|
+
children: /* @__PURE__ */ jsx13(Pencil4, { className: "h-3 w-3 text-muted-foreground" })
|
|
3329
3662
|
}
|
|
3330
3663
|
)
|
|
3331
3664
|
] }),
|
|
3332
|
-
isEditing && /* @__PURE__ */
|
|
3665
|
+
isEditing && /* @__PURE__ */ jsx13("div", { className: "ml-6", children: /* @__PURE__ */ jsx13(
|
|
3333
3666
|
"textarea",
|
|
3334
3667
|
{
|
|
3335
3668
|
className: "w-full rounded-md border bg-background px-3 py-2 text-sm resize-y min-h-[60px] focus:outline-none focus:ring-1 focus:ring-ring",
|
|
@@ -3347,12 +3680,12 @@ function IntegrationsTab({
|
|
|
3347
3680
|
`${integrationSlug}-cred-${card.credentialId}`
|
|
3348
3681
|
);
|
|
3349
3682
|
}) }),
|
|
3350
|
-
hasChanges && /* @__PURE__ */
|
|
3351
|
-
/* @__PURE__ */
|
|
3352
|
-
/* @__PURE__ */
|
|
3353
|
-
/* @__PURE__ */
|
|
3354
|
-
/* @__PURE__ */
|
|
3355
|
-
isSaving && /* @__PURE__ */
|
|
3683
|
+
hasChanges && /* @__PURE__ */ jsxs11("div", { className: "sticky bottom-0 z-10 flex items-center justify-between gap-2 rounded-lg border bg-background p-3 shadow-sm", children: [
|
|
3684
|
+
/* @__PURE__ */ jsx13("p", { className: "text-sm text-muted-foreground", children: "Voc\xEA tem altera\xE7\xF5es n\xE3o salvas." }),
|
|
3685
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex gap-2", children: [
|
|
3686
|
+
/* @__PURE__ */ jsx13(Button10, { variant: "ghost", size: "sm", onClick: discard, disabled: isSaving, children: "Descartar" }),
|
|
3687
|
+
/* @__PURE__ */ jsxs11(Button10, { size: "sm", onClick: saveNow, disabled: isSaving, children: [
|
|
3688
|
+
isSaving && /* @__PURE__ */ jsx13(Loader25, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
3356
3689
|
"Salvar"
|
|
3357
3690
|
] })
|
|
3358
3691
|
] })
|
|
@@ -3367,57 +3700,62 @@ import {
|
|
|
3367
3700
|
TabsTrigger,
|
|
3368
3701
|
TabsContent
|
|
3369
3702
|
} from "@greatapps/greatauth-ui/ui";
|
|
3370
|
-
import { Target as Target2,
|
|
3371
|
-
import { jsx as
|
|
3703
|
+
import { Target as Target2, Settings2, MessageCircle as MessageCircle2, Blocks, Plug as Plug2, History } from "lucide-react";
|
|
3704
|
+
import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3372
3705
|
function AgentTabs({
|
|
3373
3706
|
agent,
|
|
3374
3707
|
config,
|
|
3375
3708
|
renderChatLink
|
|
3376
3709
|
}) {
|
|
3377
|
-
return /* @__PURE__ */
|
|
3378
|
-
/* @__PURE__ */
|
|
3379
|
-
/* @__PURE__ */
|
|
3380
|
-
/* @__PURE__ */
|
|
3381
|
-
"
|
|
3710
|
+
return /* @__PURE__ */ jsxs12(Tabs, { defaultValue: "definicao", children: [
|
|
3711
|
+
/* @__PURE__ */ jsxs12(TabsList, { children: [
|
|
3712
|
+
/* @__PURE__ */ jsxs12(TabsTrigger, { value: "definicao", className: "flex items-center gap-1.5", children: [
|
|
3713
|
+
/* @__PURE__ */ jsx14(Settings2, { "aria-hidden": "true", className: "h-3.5 w-3.5" }),
|
|
3714
|
+
"Defini\xE7\xE3o"
|
|
3382
3715
|
] }),
|
|
3383
|
-
/* @__PURE__ */
|
|
3384
|
-
/* @__PURE__ */
|
|
3716
|
+
/* @__PURE__ */ jsxs12(TabsTrigger, { value: "objetivos", className: "flex items-center gap-1.5", children: [
|
|
3717
|
+
/* @__PURE__ */ jsx14(Target2, { "aria-hidden": "true", className: "h-3.5 w-3.5" }),
|
|
3385
3718
|
"Objetivos"
|
|
3386
3719
|
] }),
|
|
3387
|
-
/* @__PURE__ */
|
|
3388
|
-
/* @__PURE__ */
|
|
3720
|
+
/* @__PURE__ */ jsxs12(TabsTrigger, { value: "capacidades", className: "flex items-center gap-1.5", children: [
|
|
3721
|
+
/* @__PURE__ */ jsx14(Blocks, { "aria-hidden": "true", className: "h-3.5 w-3.5" }),
|
|
3389
3722
|
"Capacidades"
|
|
3390
3723
|
] }),
|
|
3391
|
-
/* @__PURE__ */
|
|
3392
|
-
/* @__PURE__ */
|
|
3724
|
+
/* @__PURE__ */ jsxs12(TabsTrigger, { value: "integracoes", className: "flex items-center gap-1.5", children: [
|
|
3725
|
+
/* @__PURE__ */ jsx14(Plug2, { "aria-hidden": "true", className: "h-3.5 w-3.5" }),
|
|
3393
3726
|
"Integra\xE7\xF5es"
|
|
3394
3727
|
] }),
|
|
3395
|
-
/* @__PURE__ */
|
|
3396
|
-
/* @__PURE__ */
|
|
3728
|
+
/* @__PURE__ */ jsxs12(TabsTrigger, { value: "conversas", className: "flex items-center gap-1.5", children: [
|
|
3729
|
+
/* @__PURE__ */ jsx14(MessageCircle2, { "aria-hidden": "true", className: "h-3.5 w-3.5" }),
|
|
3397
3730
|
"Conversas"
|
|
3731
|
+
] }),
|
|
3732
|
+
/* @__PURE__ */ jsxs12(TabsTrigger, { value: "revisao", className: "flex items-center gap-1.5", children: [
|
|
3733
|
+
/* @__PURE__ */ jsx14(History, { "aria-hidden": "true", className: "h-3.5 w-3.5" }),
|
|
3734
|
+
"Revis\xE3o"
|
|
3398
3735
|
] })
|
|
3399
3736
|
] }),
|
|
3400
|
-
/* @__PURE__ */
|
|
3401
|
-
/* @__PURE__ */
|
|
3402
|
-
/* @__PURE__ */
|
|
3403
|
-
/* @__PURE__ */
|
|
3404
|
-
/* @__PURE__ */
|
|
3737
|
+
/* @__PURE__ */ jsx14(TabsContent, { value: "definicao", className: "mt-4", children: /* @__PURE__ */ jsx14(AgentDefinitionEditor, { agent, config }) }),
|
|
3738
|
+
/* @__PURE__ */ jsx14(TabsContent, { value: "objetivos", className: "mt-4", children: /* @__PURE__ */ jsx14(AgentObjectivesList, { agent, config }) }),
|
|
3739
|
+
/* @__PURE__ */ jsx14(TabsContent, { value: "capacidades", className: "mt-4", children: /* @__PURE__ */ jsx14(CapabilitiesTab, { config, agentId: agent.id }) }),
|
|
3740
|
+
/* @__PURE__ */ jsx14(TabsContent, { value: "integracoes", className: "mt-4", children: /* @__PURE__ */ jsx14(IntegrationsTab, { config, agentId: agent.id }) }),
|
|
3741
|
+
/* @__PURE__ */ jsx14(TabsContent, { value: "conversas", className: "mt-4", children: /* @__PURE__ */ jsx14(
|
|
3405
3742
|
AgentConversationsPanel,
|
|
3406
3743
|
{
|
|
3407
3744
|
agent,
|
|
3408
3745
|
config,
|
|
3409
3746
|
renderChatLink
|
|
3410
3747
|
}
|
|
3411
|
-
) })
|
|
3748
|
+
) }),
|
|
3749
|
+
/* @__PURE__ */ jsx14(TabsContent, { value: "revisao", className: "mt-4", children: /* @__PURE__ */ jsx14(AgentRevisionTab, { agent, config }) })
|
|
3412
3750
|
] });
|
|
3413
3751
|
}
|
|
3414
3752
|
|
|
3415
3753
|
// src/components/agents/agent-tools-list.tsx
|
|
3416
|
-
import { useState as
|
|
3754
|
+
import { useState as useState12 } from "react";
|
|
3417
3755
|
import {
|
|
3418
3756
|
Switch as Switch6,
|
|
3419
3757
|
Badge as Badge6,
|
|
3420
|
-
Button as
|
|
3758
|
+
Button as Button11,
|
|
3421
3759
|
Skeleton as Skeleton6,
|
|
3422
3760
|
AlertDialog as AlertDialog3,
|
|
3423
3761
|
AlertDialogAction as AlertDialogAction3,
|
|
@@ -3430,14 +3768,14 @@ import {
|
|
|
3430
3768
|
Popover,
|
|
3431
3769
|
PopoverContent,
|
|
3432
3770
|
PopoverTrigger,
|
|
3433
|
-
Input as
|
|
3771
|
+
Input as Input7,
|
|
3434
3772
|
Textarea as Textarea2,
|
|
3435
|
-
Dialog as
|
|
3436
|
-
DialogContent as
|
|
3437
|
-
DialogHeader as
|
|
3438
|
-
DialogTitle as
|
|
3773
|
+
Dialog as Dialog5,
|
|
3774
|
+
DialogContent as DialogContent5,
|
|
3775
|
+
DialogHeader as DialogHeader5,
|
|
3776
|
+
DialogTitle as DialogTitle5,
|
|
3439
3777
|
DialogFooter as DialogFooter4,
|
|
3440
|
-
Label as
|
|
3778
|
+
Label as Label5,
|
|
3441
3779
|
Select,
|
|
3442
3780
|
SelectContent,
|
|
3443
3781
|
SelectItem,
|
|
@@ -3445,25 +3783,25 @@ import {
|
|
|
3445
3783
|
SelectValue
|
|
3446
3784
|
} from "@greatapps/greatauth-ui/ui";
|
|
3447
3785
|
import {
|
|
3448
|
-
Trash2 as
|
|
3449
|
-
Plus as
|
|
3786
|
+
Trash2 as Trash24,
|
|
3787
|
+
Plus as Plus3,
|
|
3450
3788
|
Wrench,
|
|
3451
|
-
Settings2
|
|
3789
|
+
Settings2 as Settings22
|
|
3452
3790
|
} from "lucide-react";
|
|
3453
|
-
import { toast as
|
|
3454
|
-
import { jsx as
|
|
3791
|
+
import { toast as toast9 } from "sonner";
|
|
3792
|
+
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3455
3793
|
function AgentToolsList({ agent, config }) {
|
|
3456
3794
|
const { data: agentToolsData, isLoading } = useAgentTools(config, agent.id);
|
|
3457
3795
|
const { data: allToolsData } = useTools(config);
|
|
3458
3796
|
const addMutation = useAddAgentTool(config);
|
|
3459
3797
|
const removeMutation = useRemoveAgentTool(config);
|
|
3460
3798
|
const updateMutation = useUpdateAgentTool(config);
|
|
3461
|
-
const [removeTarget, setRemoveTarget] =
|
|
3462
|
-
const [addOpen, setAddOpen] =
|
|
3463
|
-
const [search, setSearch] =
|
|
3464
|
-
const [configTarget, setConfigTarget] =
|
|
3465
|
-
const [configInstructions, setConfigInstructions] =
|
|
3466
|
-
const [configCredentialId, setConfigCredentialId] =
|
|
3799
|
+
const [removeTarget, setRemoveTarget] = useState12(null);
|
|
3800
|
+
const [addOpen, setAddOpen] = useState12(false);
|
|
3801
|
+
const [search, setSearch] = useState12("");
|
|
3802
|
+
const [configTarget, setConfigTarget] = useState12(null);
|
|
3803
|
+
const [configInstructions, setConfigInstructions] = useState12("");
|
|
3804
|
+
const [configCredentialId, setConfigCredentialId] = useState12("");
|
|
3467
3805
|
const { data: credentialsData } = useToolCredentials(config);
|
|
3468
3806
|
const allCredentials = credentialsData?.data || [];
|
|
3469
3807
|
const agentTools = agentToolsData?.data || [];
|
|
@@ -3487,9 +3825,9 @@ function AgentToolsList({ agent, config }) {
|
|
|
3487
3825
|
id: agentTool.id,
|
|
3488
3826
|
body: { enabled: checked }
|
|
3489
3827
|
});
|
|
3490
|
-
|
|
3828
|
+
toast9.success(checked ? "Ferramenta ativada" : "Ferramenta desativada");
|
|
3491
3829
|
} catch (err) {
|
|
3492
|
-
|
|
3830
|
+
toast9.error(
|
|
3493
3831
|
err instanceof Error ? err.message : "Erro ao alterar estado da ferramenta"
|
|
3494
3832
|
);
|
|
3495
3833
|
}
|
|
@@ -3500,11 +3838,11 @@ function AgentToolsList({ agent, config }) {
|
|
|
3500
3838
|
idAgent: agent.id,
|
|
3501
3839
|
body: { id_tool: tool.id }
|
|
3502
3840
|
});
|
|
3503
|
-
|
|
3841
|
+
toast9.success("Ferramenta adicionada");
|
|
3504
3842
|
setAddOpen(false);
|
|
3505
3843
|
setSearch("");
|
|
3506
3844
|
} catch (err) {
|
|
3507
|
-
|
|
3845
|
+
toast9.error(
|
|
3508
3846
|
err instanceof Error ? err.message : "Erro ao adicionar ferramenta"
|
|
3509
3847
|
);
|
|
3510
3848
|
}
|
|
@@ -3516,9 +3854,9 @@ function AgentToolsList({ agent, config }) {
|
|
|
3516
3854
|
idAgent: agent.id,
|
|
3517
3855
|
id: removeTarget.id
|
|
3518
3856
|
});
|
|
3519
|
-
|
|
3857
|
+
toast9.success("Ferramenta removida");
|
|
3520
3858
|
} catch (err) {
|
|
3521
|
-
|
|
3859
|
+
toast9.error(
|
|
3522
3860
|
err instanceof Error ? err.message : "Erro ao remover ferramenta"
|
|
3523
3861
|
);
|
|
3524
3862
|
} finally {
|
|
@@ -3542,34 +3880,34 @@ function AgentToolsList({ agent, config }) {
|
|
|
3542
3880
|
id_tool_credential: newCredentialId
|
|
3543
3881
|
}
|
|
3544
3882
|
});
|
|
3545
|
-
|
|
3883
|
+
toast9.success("Configura\xE7\xE3o atualizada");
|
|
3546
3884
|
setConfigTarget(null);
|
|
3547
3885
|
} catch (err) {
|
|
3548
|
-
|
|
3886
|
+
toast9.error(
|
|
3549
3887
|
err instanceof Error ? err.message : "Erro ao atualizar configura\xE7\xE3o"
|
|
3550
3888
|
);
|
|
3551
3889
|
}
|
|
3552
3890
|
}
|
|
3553
3891
|
if (isLoading) {
|
|
3554
|
-
return /* @__PURE__ */
|
|
3892
|
+
return /* @__PURE__ */ jsx15("div", { className: "space-y-3 p-4", children: Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ jsx15(Skeleton6, { className: "h-14 w-full" }, i)) });
|
|
3555
3893
|
}
|
|
3556
|
-
return /* @__PURE__ */
|
|
3557
|
-
/* @__PURE__ */
|
|
3558
|
-
/* @__PURE__ */
|
|
3894
|
+
return /* @__PURE__ */ jsxs13("div", { className: "space-y-4 p-4", children: [
|
|
3895
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex items-center justify-between", children: [
|
|
3896
|
+
/* @__PURE__ */ jsxs13("h3", { className: "text-sm font-medium text-muted-foreground", children: [
|
|
3559
3897
|
visibleAgentTools.length,
|
|
3560
3898
|
" ferramenta",
|
|
3561
3899
|
visibleAgentTools.length !== 1 ? "s" : "",
|
|
3562
3900
|
" associada",
|
|
3563
3901
|
visibleAgentTools.length !== 1 ? "s" : ""
|
|
3564
3902
|
] }),
|
|
3565
|
-
/* @__PURE__ */
|
|
3566
|
-
/* @__PURE__ */
|
|
3567
|
-
/* @__PURE__ */
|
|
3903
|
+
/* @__PURE__ */ jsxs13(Popover, { open: addOpen, onOpenChange: setAddOpen, children: [
|
|
3904
|
+
/* @__PURE__ */ jsx15(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs13(Button11, { size: "sm", disabled: availableTools.length === 0, children: [
|
|
3905
|
+
/* @__PURE__ */ jsx15(Plus3, { className: "mr-2 h-4 w-4" }),
|
|
3568
3906
|
"Adicionar Ferramenta"
|
|
3569
3907
|
] }) }),
|
|
3570
|
-
/* @__PURE__ */
|
|
3571
|
-
/* @__PURE__ */
|
|
3572
|
-
|
|
3908
|
+
/* @__PURE__ */ jsxs13(PopoverContent, { className: "w-72 p-0", align: "end", children: [
|
|
3909
|
+
/* @__PURE__ */ jsx15("div", { className: "p-2", children: /* @__PURE__ */ jsx15(
|
|
3910
|
+
Input7,
|
|
3573
3911
|
{
|
|
3574
3912
|
placeholder: "Buscar ferramenta\\u2026",
|
|
3575
3913
|
"aria-label": "Buscar ferramenta",
|
|
@@ -3579,7 +3917,7 @@ function AgentToolsList({ agent, config }) {
|
|
|
3579
3917
|
className: "h-8"
|
|
3580
3918
|
}
|
|
3581
3919
|
) }),
|
|
3582
|
-
/* @__PURE__ */
|
|
3920
|
+
/* @__PURE__ */ jsx15("div", { className: "max-h-48 overflow-y-auto", children: filteredAvailable.length === 0 ? /* @__PURE__ */ jsx15("p", { className: "p-3 text-center text-sm text-muted-foreground", children: "Nenhuma ferramenta dispon\xEDvel" }) : filteredAvailable.map((tool) => /* @__PURE__ */ jsxs13(
|
|
3583
3921
|
"button",
|
|
3584
3922
|
{
|
|
3585
3923
|
type: "button",
|
|
@@ -3587,9 +3925,9 @@ function AgentToolsList({ agent, config }) {
|
|
|
3587
3925
|
onClick: () => handleAdd(tool),
|
|
3588
3926
|
disabled: addMutation.isPending,
|
|
3589
3927
|
children: [
|
|
3590
|
-
/* @__PURE__ */
|
|
3591
|
-
/* @__PURE__ */
|
|
3592
|
-
/* @__PURE__ */
|
|
3928
|
+
/* @__PURE__ */ jsx15(Wrench, { className: "h-4 w-4 text-muted-foreground" }),
|
|
3929
|
+
/* @__PURE__ */ jsx15("span", { className: "flex-1 font-medium", children: tool.name }),
|
|
3930
|
+
/* @__PURE__ */ jsx15(Badge6, { variant: "secondary", className: "text-xs", children: tool.type })
|
|
3593
3931
|
]
|
|
3594
3932
|
},
|
|
3595
3933
|
tool.id
|
|
@@ -3597,24 +3935,24 @@ function AgentToolsList({ agent, config }) {
|
|
|
3597
3935
|
] })
|
|
3598
3936
|
] })
|
|
3599
3937
|
] }),
|
|
3600
|
-
visibleAgentTools.length === 0 ? /* @__PURE__ */
|
|
3601
|
-
/* @__PURE__ */
|
|
3602
|
-
/* @__PURE__ */
|
|
3603
|
-
] }) : /* @__PURE__ */
|
|
3938
|
+
visibleAgentTools.length === 0 ? /* @__PURE__ */ jsxs13("div", { className: "flex flex-col items-center justify-center rounded-lg border border-dashed p-8 text-center", children: [
|
|
3939
|
+
/* @__PURE__ */ jsx15(Wrench, { className: "mb-2 h-8 w-8 text-muted-foreground" }),
|
|
3940
|
+
/* @__PURE__ */ jsx15("p", { className: "text-sm text-muted-foreground", children: "Nenhuma ferramenta associada. Clique em 'Adicionar Ferramenta' para come\xE7ar." })
|
|
3941
|
+
] }) : /* @__PURE__ */ jsx15("div", { className: "space-y-2", children: visibleAgentTools.map((agentTool) => {
|
|
3604
3942
|
const tool = getToolInfo(agentTool.id_tool);
|
|
3605
|
-
return /* @__PURE__ */
|
|
3943
|
+
return /* @__PURE__ */ jsxs13(
|
|
3606
3944
|
"div",
|
|
3607
3945
|
{
|
|
3608
3946
|
className: "flex items-center gap-3 rounded-lg border bg-card p-3",
|
|
3609
3947
|
children: [
|
|
3610
|
-
/* @__PURE__ */
|
|
3611
|
-
/* @__PURE__ */
|
|
3612
|
-
/* @__PURE__ */
|
|
3613
|
-
tool?.type && /* @__PURE__ */
|
|
3948
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex flex-1 flex-col gap-1 min-w-0", children: [
|
|
3949
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2", children: [
|
|
3950
|
+
/* @__PURE__ */ jsx15("span", { className: "truncate font-medium", children: tool?.name || `Ferramenta #${agentTool.id_tool}` }),
|
|
3951
|
+
tool?.type && /* @__PURE__ */ jsx15(Badge6, { variant: "secondary", className: "shrink-0 text-xs", children: tool.type })
|
|
3614
3952
|
] }),
|
|
3615
|
-
agentTool.custom_instructions && /* @__PURE__ */
|
|
3953
|
+
agentTool.custom_instructions && /* @__PURE__ */ jsx15("p", { className: "truncate text-xs text-muted-foreground", children: agentTool.custom_instructions })
|
|
3616
3954
|
] }),
|
|
3617
|
-
/* @__PURE__ */
|
|
3955
|
+
/* @__PURE__ */ jsx15(
|
|
3618
3956
|
Switch6,
|
|
3619
3957
|
{
|
|
3620
3958
|
"aria-label": "Ativar/Desativar",
|
|
@@ -3623,8 +3961,8 @@ function AgentToolsList({ agent, config }) {
|
|
|
3623
3961
|
disabled: updateMutation.isPending
|
|
3624
3962
|
}
|
|
3625
3963
|
),
|
|
3626
|
-
/* @__PURE__ */
|
|
3627
|
-
|
|
3964
|
+
/* @__PURE__ */ jsx15(
|
|
3965
|
+
Button11,
|
|
3628
3966
|
{
|
|
3629
3967
|
variant: "ghost",
|
|
3630
3968
|
size: "icon",
|
|
@@ -3632,18 +3970,18 @@ function AgentToolsList({ agent, config }) {
|
|
|
3632
3970
|
className: "shrink-0 text-muted-foreground hover:text-foreground",
|
|
3633
3971
|
onClick: () => openConfig(agentTool),
|
|
3634
3972
|
title: "Configurar instru\xE7\xF5es",
|
|
3635
|
-
children: /* @__PURE__ */
|
|
3973
|
+
children: /* @__PURE__ */ jsx15(Settings22, { className: "h-4 w-4" })
|
|
3636
3974
|
}
|
|
3637
3975
|
),
|
|
3638
|
-
/* @__PURE__ */
|
|
3639
|
-
|
|
3976
|
+
/* @__PURE__ */ jsx15(
|
|
3977
|
+
Button11,
|
|
3640
3978
|
{
|
|
3641
3979
|
variant: "ghost",
|
|
3642
3980
|
size: "icon",
|
|
3643
3981
|
"aria-label": "Remover",
|
|
3644
3982
|
className: "shrink-0 text-muted-foreground hover:text-destructive",
|
|
3645
3983
|
onClick: () => setRemoveTarget(agentTool),
|
|
3646
|
-
children: /* @__PURE__ */
|
|
3984
|
+
children: /* @__PURE__ */ jsx15(Trash24, { className: "h-4 w-4" })
|
|
3647
3985
|
}
|
|
3648
3986
|
)
|
|
3649
3987
|
]
|
|
@@ -3651,35 +3989,35 @@ function AgentToolsList({ agent, config }) {
|
|
|
3651
3989
|
agentTool.id
|
|
3652
3990
|
);
|
|
3653
3991
|
}) }),
|
|
3654
|
-
/* @__PURE__ */
|
|
3655
|
-
|
|
3992
|
+
/* @__PURE__ */ jsx15(
|
|
3993
|
+
Dialog5,
|
|
3656
3994
|
{
|
|
3657
3995
|
open: !!configTarget,
|
|
3658
3996
|
onOpenChange: (open) => !open && setConfigTarget(null),
|
|
3659
|
-
children: /* @__PURE__ */
|
|
3660
|
-
/* @__PURE__ */
|
|
3661
|
-
/* @__PURE__ */
|
|
3662
|
-
configTarget && getToolInfo(configTarget.id_tool)?.type !== "none" && /* @__PURE__ */
|
|
3663
|
-
/* @__PURE__ */
|
|
3664
|
-
/* @__PURE__ */
|
|
3997
|
+
children: /* @__PURE__ */ jsxs13(DialogContent5, { className: "sm:max-w-lg", children: [
|
|
3998
|
+
/* @__PURE__ */ jsx15(DialogHeader5, { children: /* @__PURE__ */ jsx15(DialogTitle5, { children: "Instru\xE7\xF5es da Ferramenta" }) }),
|
|
3999
|
+
/* @__PURE__ */ jsxs13("div", { className: "space-y-4", children: [
|
|
4000
|
+
configTarget && getToolInfo(configTarget.id_tool)?.type !== "none" && /* @__PURE__ */ jsxs13("div", { className: "space-y-2", children: [
|
|
4001
|
+
/* @__PURE__ */ jsx15(Label5, { htmlFor: "tool-credential", children: "Credencial" }),
|
|
4002
|
+
/* @__PURE__ */ jsxs13(
|
|
3665
4003
|
Select,
|
|
3666
4004
|
{
|
|
3667
4005
|
value: configCredentialId || void 0,
|
|
3668
4006
|
onValueChange: (val) => setConfigCredentialId(val === "__none__" ? "" : val),
|
|
3669
4007
|
children: [
|
|
3670
|
-
/* @__PURE__ */
|
|
3671
|
-
/* @__PURE__ */
|
|
3672
|
-
/* @__PURE__ */
|
|
3673
|
-
allCredentials.filter((c) => configTarget && c.id_tool === configTarget.id_tool && c.status === "active").map((c) => /* @__PURE__ */
|
|
4008
|
+
/* @__PURE__ */ jsx15(SelectTrigger, { id: "tool-credential", children: /* @__PURE__ */ jsx15(SelectValue, { placeholder: "Selecione uma credencial (opcional)" }) }),
|
|
4009
|
+
/* @__PURE__ */ jsxs13(SelectContent, { children: [
|
|
4010
|
+
/* @__PURE__ */ jsx15(SelectItem, { value: "__none__", children: "Nenhuma (autom\xE1tico)" }),
|
|
4011
|
+
allCredentials.filter((c) => configTarget && c.id_tool === configTarget.id_tool && c.status === "active").map((c) => /* @__PURE__ */ jsx15(SelectItem, { value: String(c.id), children: c.label || `Credencial #${c.id}` }, c.id))
|
|
3674
4012
|
] })
|
|
3675
4013
|
]
|
|
3676
4014
|
}
|
|
3677
4015
|
),
|
|
3678
|
-
/* @__PURE__ */
|
|
4016
|
+
/* @__PURE__ */ jsx15("p", { className: "text-xs text-muted-foreground", children: "Vincule uma credencial espec\xEDfica a esta ferramenta neste agente." })
|
|
3679
4017
|
] }),
|
|
3680
|
-
/* @__PURE__ */
|
|
3681
|
-
/* @__PURE__ */
|
|
3682
|
-
/* @__PURE__ */
|
|
4018
|
+
/* @__PURE__ */ jsxs13("div", { className: "space-y-2", children: [
|
|
4019
|
+
/* @__PURE__ */ jsx15(Label5, { htmlFor: "tool-instructions", children: "Instru\xE7\xF5es Personalizadas" }),
|
|
4020
|
+
/* @__PURE__ */ jsx15(
|
|
3683
4021
|
Textarea2,
|
|
3684
4022
|
{
|
|
3685
4023
|
id: "tool-instructions",
|
|
@@ -3690,20 +4028,20 @@ function AgentToolsList({ agent, config }) {
|
|
|
3690
4028
|
rows: 6
|
|
3691
4029
|
}
|
|
3692
4030
|
),
|
|
3693
|
-
/* @__PURE__ */
|
|
4031
|
+
/* @__PURE__ */ jsx15("p", { className: "text-xs text-muted-foreground", children: "Este texto \xE9 adicionado ao prompt do agente para orientar o uso da ferramenta." })
|
|
3694
4032
|
] })
|
|
3695
4033
|
] }),
|
|
3696
|
-
/* @__PURE__ */
|
|
3697
|
-
/* @__PURE__ */
|
|
3698
|
-
|
|
4034
|
+
/* @__PURE__ */ jsxs13(DialogFooter4, { children: [
|
|
4035
|
+
/* @__PURE__ */ jsx15(
|
|
4036
|
+
Button11,
|
|
3699
4037
|
{
|
|
3700
4038
|
variant: "outline",
|
|
3701
4039
|
onClick: () => setConfigTarget(null),
|
|
3702
4040
|
children: "Cancelar"
|
|
3703
4041
|
}
|
|
3704
4042
|
),
|
|
3705
|
-
/* @__PURE__ */
|
|
3706
|
-
|
|
4043
|
+
/* @__PURE__ */ jsx15(
|
|
4044
|
+
Button11,
|
|
3707
4045
|
{
|
|
3708
4046
|
onClick: handleSaveConfig,
|
|
3709
4047
|
disabled: updateMutation.isPending,
|
|
@@ -3714,19 +4052,19 @@ function AgentToolsList({ agent, config }) {
|
|
|
3714
4052
|
] })
|
|
3715
4053
|
}
|
|
3716
4054
|
),
|
|
3717
|
-
/* @__PURE__ */
|
|
4055
|
+
/* @__PURE__ */ jsx15(
|
|
3718
4056
|
AlertDialog3,
|
|
3719
4057
|
{
|
|
3720
4058
|
open: !!removeTarget,
|
|
3721
4059
|
onOpenChange: (open) => !open && setRemoveTarget(null),
|
|
3722
|
-
children: /* @__PURE__ */
|
|
3723
|
-
/* @__PURE__ */
|
|
3724
|
-
/* @__PURE__ */
|
|
3725
|
-
/* @__PURE__ */
|
|
4060
|
+
children: /* @__PURE__ */ jsxs13(AlertDialogContent3, { children: [
|
|
4061
|
+
/* @__PURE__ */ jsxs13(AlertDialogHeader3, { children: [
|
|
4062
|
+
/* @__PURE__ */ jsx15(AlertDialogTitle3, { children: "Remover ferramenta?" }),
|
|
4063
|
+
/* @__PURE__ */ jsx15(AlertDialogDescription3, { children: "A ferramenta ser\xE1 desassociada deste agente." })
|
|
3726
4064
|
] }),
|
|
3727
|
-
/* @__PURE__ */
|
|
3728
|
-
/* @__PURE__ */
|
|
3729
|
-
/* @__PURE__ */
|
|
4065
|
+
/* @__PURE__ */ jsxs13(AlertDialogFooter3, { children: [
|
|
4066
|
+
/* @__PURE__ */ jsx15(AlertDialogCancel3, { children: "Cancelar" }),
|
|
4067
|
+
/* @__PURE__ */ jsx15(
|
|
3730
4068
|
AlertDialogAction3,
|
|
3731
4069
|
{
|
|
3732
4070
|
onClick: handleRemove,
|
|
@@ -3742,10 +4080,10 @@ function AgentToolsList({ agent, config }) {
|
|
|
3742
4080
|
}
|
|
3743
4081
|
|
|
3744
4082
|
// src/components/tools/tools-table.tsx
|
|
3745
|
-
import { useMemo as
|
|
4083
|
+
import { useMemo as useMemo8, useState as useState13 } from "react";
|
|
3746
4084
|
import { DataTable as DataTable2 } from "@greatapps/greatauth-ui";
|
|
3747
4085
|
import {
|
|
3748
|
-
Input as
|
|
4086
|
+
Input as Input8,
|
|
3749
4087
|
Badge as Badge7,
|
|
3750
4088
|
Tooltip as Tooltip3,
|
|
3751
4089
|
TooltipTrigger as TooltipTrigger3,
|
|
@@ -3758,44 +4096,44 @@ import {
|
|
|
3758
4096
|
AlertDialogFooter as AlertDialogFooter4,
|
|
3759
4097
|
AlertDialogHeader as AlertDialogHeader4,
|
|
3760
4098
|
AlertDialogTitle as AlertDialogTitle4,
|
|
3761
|
-
Button as
|
|
4099
|
+
Button as Button12
|
|
3762
4100
|
} from "@greatapps/greatauth-ui/ui";
|
|
3763
|
-
import { Pencil as Pencil5, Trash2 as
|
|
4101
|
+
import { Pencil as Pencil5, Trash2 as Trash25, Search as Search2 } from "lucide-react";
|
|
3764
4102
|
import { format as format2 } from "date-fns";
|
|
3765
4103
|
import { ptBR as ptBR2 } from "date-fns/locale";
|
|
3766
|
-
import { toast as
|
|
3767
|
-
import { Fragment as
|
|
4104
|
+
import { toast as toast10 } from "sonner";
|
|
4105
|
+
import { Fragment as Fragment3, jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3768
4106
|
function useColumns2(onEdit, onDelete) {
|
|
3769
4107
|
return [
|
|
3770
4108
|
{
|
|
3771
4109
|
accessorKey: "name",
|
|
3772
4110
|
header: "Nome",
|
|
3773
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
4111
|
+
cell: ({ row }) => /* @__PURE__ */ jsx16("span", { className: "font-medium", children: row.original.name }),
|
|
3774
4112
|
sortingFn: (rowA, rowB) => rowA.original.name.toLowerCase().localeCompare(rowB.original.name.toLowerCase())
|
|
3775
4113
|
},
|
|
3776
4114
|
{
|
|
3777
4115
|
accessorKey: "slug",
|
|
3778
4116
|
header: "Slug",
|
|
3779
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
4117
|
+
cell: ({ row }) => /* @__PURE__ */ jsx16("span", { className: "text-muted-foreground text-sm font-mono", children: row.original.slug || "\u2014" })
|
|
3780
4118
|
},
|
|
3781
4119
|
{
|
|
3782
4120
|
accessorKey: "type",
|
|
3783
4121
|
header: "Tipo",
|
|
3784
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
4122
|
+
cell: ({ row }) => /* @__PURE__ */ jsx16(Badge7, { variant: "secondary", children: row.original.type })
|
|
3785
4123
|
},
|
|
3786
4124
|
{
|
|
3787
4125
|
accessorKey: "description",
|
|
3788
4126
|
header: "Descri\xE7\xE3o",
|
|
3789
4127
|
cell: ({ row }) => {
|
|
3790
4128
|
const desc = row.original.description;
|
|
3791
|
-
if (!desc) return /* @__PURE__ */
|
|
3792
|
-
return /* @__PURE__ */
|
|
4129
|
+
if (!desc) return /* @__PURE__ */ jsx16("span", { className: "text-muted-foreground text-sm", children: "\u2014" });
|
|
4130
|
+
return /* @__PURE__ */ jsx16("span", { className: "text-muted-foreground text-sm", children: desc.length > 50 ? `${desc.slice(0, 50)}\u2026` : desc });
|
|
3793
4131
|
}
|
|
3794
4132
|
},
|
|
3795
4133
|
{
|
|
3796
4134
|
accessorKey: "datetime_add",
|
|
3797
4135
|
header: "Criado em",
|
|
3798
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
4136
|
+
cell: ({ row }) => /* @__PURE__ */ jsx16("span", { className: "text-muted-foreground text-sm", children: format2(new Date(row.original.datetime_add), "dd/MM/yyyy", {
|
|
3799
4137
|
locale: ptBR2
|
|
3800
4138
|
}) })
|
|
3801
4139
|
},
|
|
@@ -3803,43 +4141,43 @@ function useColumns2(onEdit, onDelete) {
|
|
|
3803
4141
|
id: "actions",
|
|
3804
4142
|
size: 80,
|
|
3805
4143
|
enableSorting: false,
|
|
3806
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
3807
|
-
/* @__PURE__ */
|
|
3808
|
-
/* @__PURE__ */
|
|
3809
|
-
|
|
4144
|
+
cell: ({ row }) => /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-1", children: [
|
|
4145
|
+
/* @__PURE__ */ jsxs14(Tooltip3, { children: [
|
|
4146
|
+
/* @__PURE__ */ jsx16(TooltipTrigger3, { asChild: true, children: /* @__PURE__ */ jsx16(
|
|
4147
|
+
Button12,
|
|
3810
4148
|
{
|
|
3811
4149
|
variant: "ghost",
|
|
3812
4150
|
size: "icon",
|
|
3813
4151
|
className: "h-8 w-8",
|
|
3814
4152
|
"aria-label": "Editar",
|
|
3815
4153
|
onClick: () => onEdit(row.original),
|
|
3816
|
-
children: /* @__PURE__ */
|
|
4154
|
+
children: /* @__PURE__ */ jsx16(Pencil5, { className: "h-4 w-4" })
|
|
3817
4155
|
}
|
|
3818
4156
|
) }),
|
|
3819
|
-
/* @__PURE__ */
|
|
4157
|
+
/* @__PURE__ */ jsx16(TooltipContent3, { children: "Editar" })
|
|
3820
4158
|
] }),
|
|
3821
|
-
/* @__PURE__ */
|
|
3822
|
-
/* @__PURE__ */
|
|
3823
|
-
|
|
4159
|
+
/* @__PURE__ */ jsxs14(Tooltip3, { children: [
|
|
4160
|
+
/* @__PURE__ */ jsx16(TooltipTrigger3, { asChild: true, children: /* @__PURE__ */ jsx16(
|
|
4161
|
+
Button12,
|
|
3824
4162
|
{
|
|
3825
4163
|
variant: "ghost",
|
|
3826
4164
|
size: "icon",
|
|
3827
4165
|
className: "h-8 w-8 text-destructive hover:text-destructive",
|
|
3828
4166
|
"aria-label": "Excluir",
|
|
3829
4167
|
onClick: () => onDelete(row.original.id),
|
|
3830
|
-
children: /* @__PURE__ */
|
|
4168
|
+
children: /* @__PURE__ */ jsx16(Trash25, { className: "h-4 w-4" })
|
|
3831
4169
|
}
|
|
3832
4170
|
) }),
|
|
3833
|
-
/* @__PURE__ */
|
|
4171
|
+
/* @__PURE__ */ jsx16(TooltipContent3, { children: "Excluir" })
|
|
3834
4172
|
] })
|
|
3835
4173
|
] })
|
|
3836
4174
|
}
|
|
3837
4175
|
];
|
|
3838
4176
|
}
|
|
3839
4177
|
function ToolsTable({ onEdit, config }) {
|
|
3840
|
-
const [search, setSearch] =
|
|
3841
|
-
const [page, setPage] =
|
|
3842
|
-
const queryParams =
|
|
4178
|
+
const [search, setSearch] = useState13("");
|
|
4179
|
+
const [page, setPage] = useState13(1);
|
|
4180
|
+
const queryParams = useMemo8(() => {
|
|
3843
4181
|
const params = {
|
|
3844
4182
|
limit: "15",
|
|
3845
4183
|
page: String(page)
|
|
@@ -3851,7 +4189,7 @@ function ToolsTable({ onEdit, config }) {
|
|
|
3851
4189
|
}, [search, page]);
|
|
3852
4190
|
const { data, isLoading } = useTools(config, queryParams);
|
|
3853
4191
|
const deleteTool = useDeleteTool(config);
|
|
3854
|
-
const [deleteId, setDeleteId] =
|
|
4192
|
+
const [deleteId, setDeleteId] = useState13(null);
|
|
3855
4193
|
const rawTools = data?.data || [];
|
|
3856
4194
|
const tools = rawTools.filter((t) => !t.slug?.startsWith("gclinic_"));
|
|
3857
4195
|
const total = tools.length;
|
|
@@ -3863,21 +4201,21 @@ function ToolsTable({ onEdit, config }) {
|
|
|
3863
4201
|
if (!deleteId) return;
|
|
3864
4202
|
deleteTool.mutate(deleteId, {
|
|
3865
4203
|
onSuccess: () => {
|
|
3866
|
-
|
|
4204
|
+
toast10.success("Ferramenta exclu\xEDda");
|
|
3867
4205
|
setDeleteId(null);
|
|
3868
4206
|
},
|
|
3869
|
-
onError: () =>
|
|
4207
|
+
onError: () => toast10.error("Erro ao excluir ferramenta")
|
|
3870
4208
|
});
|
|
3871
4209
|
}
|
|
3872
4210
|
function handleSearchChange(value) {
|
|
3873
4211
|
setSearch(value);
|
|
3874
4212
|
setPage(1);
|
|
3875
4213
|
}
|
|
3876
|
-
return /* @__PURE__ */
|
|
3877
|
-
/* @__PURE__ */
|
|
3878
|
-
/* @__PURE__ */
|
|
3879
|
-
/* @__PURE__ */
|
|
3880
|
-
|
|
4214
|
+
return /* @__PURE__ */ jsxs14(Fragment3, { children: [
|
|
4215
|
+
/* @__PURE__ */ jsx16("div", { className: "flex items-center gap-3", children: /* @__PURE__ */ jsxs14("div", { className: "relative flex-1 max-w-md", children: [
|
|
4216
|
+
/* @__PURE__ */ jsx16(Search2, { "aria-hidden": "true", className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
|
|
4217
|
+
/* @__PURE__ */ jsx16(
|
|
4218
|
+
Input8,
|
|
3881
4219
|
{
|
|
3882
4220
|
placeholder: "Buscar ferramentas\\u2026",
|
|
3883
4221
|
"aria-label": "Buscar ferramentas",
|
|
@@ -3889,7 +4227,7 @@ function ToolsTable({ onEdit, config }) {
|
|
|
3889
4227
|
}
|
|
3890
4228
|
)
|
|
3891
4229
|
] }) }),
|
|
3892
|
-
/* @__PURE__ */
|
|
4230
|
+
/* @__PURE__ */ jsx16(
|
|
3893
4231
|
DataTable2,
|
|
3894
4232
|
{
|
|
3895
4233
|
columns,
|
|
@@ -3902,19 +4240,19 @@ function ToolsTable({ onEdit, config }) {
|
|
|
3902
4240
|
pageSize: 15
|
|
3903
4241
|
}
|
|
3904
4242
|
),
|
|
3905
|
-
/* @__PURE__ */
|
|
4243
|
+
/* @__PURE__ */ jsx16(
|
|
3906
4244
|
AlertDialog4,
|
|
3907
4245
|
{
|
|
3908
4246
|
open: !!deleteId,
|
|
3909
4247
|
onOpenChange: (open) => !open && setDeleteId(null),
|
|
3910
|
-
children: /* @__PURE__ */
|
|
3911
|
-
/* @__PURE__ */
|
|
3912
|
-
/* @__PURE__ */
|
|
3913
|
-
/* @__PURE__ */
|
|
4248
|
+
children: /* @__PURE__ */ jsxs14(AlertDialogContent4, { children: [
|
|
4249
|
+
/* @__PURE__ */ jsxs14(AlertDialogHeader4, { children: [
|
|
4250
|
+
/* @__PURE__ */ jsx16(AlertDialogTitle4, { children: "Excluir ferramenta?" }),
|
|
4251
|
+
/* @__PURE__ */ jsx16(AlertDialogDescription4, { children: "Esta a\xE7\xE3o n\xE3o pode ser desfeita. A ferramenta ser\xE1 removida permanentemente." })
|
|
3914
4252
|
] }),
|
|
3915
|
-
/* @__PURE__ */
|
|
3916
|
-
/* @__PURE__ */
|
|
3917
|
-
/* @__PURE__ */
|
|
4253
|
+
/* @__PURE__ */ jsxs14(AlertDialogFooter4, { children: [
|
|
4254
|
+
/* @__PURE__ */ jsx16(AlertDialogCancel4, { variant: "outline", size: "default", children: "Cancelar" }),
|
|
4255
|
+
/* @__PURE__ */ jsx16(
|
|
3918
4256
|
AlertDialogAction4,
|
|
3919
4257
|
{
|
|
3920
4258
|
variant: "default",
|
|
@@ -3932,17 +4270,17 @@ function ToolsTable({ onEdit, config }) {
|
|
|
3932
4270
|
}
|
|
3933
4271
|
|
|
3934
4272
|
// src/components/tools/tool-form-dialog.tsx
|
|
3935
|
-
import { useState as
|
|
4273
|
+
import { useState as useState14 } from "react";
|
|
3936
4274
|
import {
|
|
3937
|
-
Dialog as
|
|
3938
|
-
DialogContent as
|
|
3939
|
-
DialogHeader as
|
|
3940
|
-
DialogTitle as
|
|
4275
|
+
Dialog as Dialog6,
|
|
4276
|
+
DialogContent as DialogContent6,
|
|
4277
|
+
DialogHeader as DialogHeader6,
|
|
4278
|
+
DialogTitle as DialogTitle6,
|
|
3941
4279
|
DialogFooter as DialogFooter5,
|
|
3942
|
-
Button as
|
|
3943
|
-
Input as
|
|
4280
|
+
Button as Button13,
|
|
4281
|
+
Input as Input9,
|
|
3944
4282
|
Textarea as Textarea3,
|
|
3945
|
-
Label as
|
|
4283
|
+
Label as Label6,
|
|
3946
4284
|
Select as Select2,
|
|
3947
4285
|
SelectContent as SelectContent2,
|
|
3948
4286
|
SelectItem as SelectItem2,
|
|
@@ -3950,8 +4288,8 @@ import {
|
|
|
3950
4288
|
SelectValue as SelectValue2
|
|
3951
4289
|
} from "@greatapps/greatauth-ui/ui";
|
|
3952
4290
|
import { Loader2 as Loader26 } from "lucide-react";
|
|
3953
|
-
import { toast as
|
|
3954
|
-
import { jsx as
|
|
4291
|
+
import { toast as toast11 } from "sonner";
|
|
4292
|
+
import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3955
4293
|
var TOOL_AUTH_TYPES = [
|
|
3956
4294
|
{ value: "none", label: "Nenhuma" },
|
|
3957
4295
|
{ value: "api_key", label: "API Key" },
|
|
@@ -3998,9 +4336,9 @@ function ToolFormDialog({
|
|
|
3998
4336
|
const isEditing = !!tool;
|
|
3999
4337
|
const createTool = useCreateTool(config);
|
|
4000
4338
|
const updateTool = useUpdateTool(config);
|
|
4001
|
-
const [form, setForm] =
|
|
4002
|
-
const [slugManuallyEdited, setSlugManuallyEdited] =
|
|
4003
|
-
const [lastResetKey, setLastResetKey] =
|
|
4339
|
+
const [form, setForm] = useState14(() => toolToFormState(tool));
|
|
4340
|
+
const [slugManuallyEdited, setSlugManuallyEdited] = useState14(false);
|
|
4341
|
+
const [lastResetKey, setLastResetKey] = useState14(
|
|
4004
4342
|
() => `${tool?.id}-${open}`
|
|
4005
4343
|
);
|
|
4006
4344
|
const resetKey = `${tool?.id}-${open}`;
|
|
@@ -4047,27 +4385,27 @@ function ToolFormDialog({
|
|
|
4047
4385
|
try {
|
|
4048
4386
|
if (isEditing) {
|
|
4049
4387
|
await updateTool.mutateAsync({ id: tool.id, body });
|
|
4050
|
-
|
|
4388
|
+
toast11.success("Ferramenta atualizada");
|
|
4051
4389
|
} else {
|
|
4052
4390
|
await createTool.mutateAsync(
|
|
4053
4391
|
body
|
|
4054
4392
|
);
|
|
4055
|
-
|
|
4393
|
+
toast11.success("Ferramenta criada");
|
|
4056
4394
|
}
|
|
4057
4395
|
onOpenChange(false);
|
|
4058
4396
|
} catch (err) {
|
|
4059
|
-
|
|
4397
|
+
toast11.error(
|
|
4060
4398
|
err instanceof Error ? err.message : isEditing ? "Erro ao atualizar ferramenta" : "Erro ao criar ferramenta"
|
|
4061
4399
|
);
|
|
4062
4400
|
}
|
|
4063
4401
|
}
|
|
4064
|
-
return /* @__PURE__ */
|
|
4065
|
-
/* @__PURE__ */
|
|
4066
|
-
/* @__PURE__ */
|
|
4067
|
-
/* @__PURE__ */
|
|
4068
|
-
/* @__PURE__ */
|
|
4069
|
-
/* @__PURE__ */
|
|
4070
|
-
|
|
4402
|
+
return /* @__PURE__ */ jsx17(Dialog6, { open, onOpenChange, children: /* @__PURE__ */ jsxs15(DialogContent6, { className: "sm:max-w-lg", children: [
|
|
4403
|
+
/* @__PURE__ */ jsx17(DialogHeader6, { children: /* @__PURE__ */ jsx17(DialogTitle6, { children: isEditing ? "Editar Ferramenta" : "Nova Ferramenta" }) }),
|
|
4404
|
+
/* @__PURE__ */ jsxs15("form", { onSubmit: handleSubmit, className: "space-y-4", children: [
|
|
4405
|
+
/* @__PURE__ */ jsxs15("div", { className: "space-y-2", children: [
|
|
4406
|
+
/* @__PURE__ */ jsx17(Label6, { htmlFor: "tool-name", children: "Nome *" }),
|
|
4407
|
+
/* @__PURE__ */ jsx17(
|
|
4408
|
+
Input9,
|
|
4071
4409
|
{
|
|
4072
4410
|
id: "tool-name",
|
|
4073
4411
|
name: "name",
|
|
@@ -4085,12 +4423,12 @@ function ToolFormDialog({
|
|
|
4085
4423
|
disabled: isPending
|
|
4086
4424
|
}
|
|
4087
4425
|
),
|
|
4088
|
-
form.nameError && /* @__PURE__ */
|
|
4426
|
+
form.nameError && /* @__PURE__ */ jsx17("p", { className: "text-sm text-destructive", children: "Nome \xE9 obrigat\xF3rio" })
|
|
4089
4427
|
] }),
|
|
4090
|
-
/* @__PURE__ */
|
|
4091
|
-
/* @__PURE__ */
|
|
4092
|
-
/* @__PURE__ */
|
|
4093
|
-
|
|
4428
|
+
/* @__PURE__ */ jsxs15("div", { className: "space-y-2", children: [
|
|
4429
|
+
/* @__PURE__ */ jsx17(Label6, { htmlFor: "tool-slug", children: "Slug (identificador \xFAnico) *" }),
|
|
4430
|
+
/* @__PURE__ */ jsx17(
|
|
4431
|
+
Input9,
|
|
4094
4432
|
{
|
|
4095
4433
|
id: "tool-slug",
|
|
4096
4434
|
name: "slug",
|
|
@@ -4107,12 +4445,12 @@ function ToolFormDialog({
|
|
|
4107
4445
|
disabled: isPending
|
|
4108
4446
|
}
|
|
4109
4447
|
),
|
|
4110
|
-
/* @__PURE__ */
|
|
4111
|
-
form.slugError && /* @__PURE__ */
|
|
4448
|
+
/* @__PURE__ */ jsx17("p", { className: "text-xs text-muted-foreground", children: "Gerado automaticamente a partir do nome. Usado internamente para identificar a ferramenta." }),
|
|
4449
|
+
form.slugError && /* @__PURE__ */ jsx17("p", { className: "text-sm text-destructive", children: "Slug \xE9 obrigat\xF3rio" })
|
|
4112
4450
|
] }),
|
|
4113
|
-
/* @__PURE__ */
|
|
4114
|
-
/* @__PURE__ */
|
|
4115
|
-
/* @__PURE__ */
|
|
4451
|
+
/* @__PURE__ */ jsxs15("div", { className: "space-y-2", children: [
|
|
4452
|
+
/* @__PURE__ */ jsx17(Label6, { htmlFor: "tool-type", children: "Tipo de Autentica\xE7\xE3o *" }),
|
|
4453
|
+
/* @__PURE__ */ jsxs15(
|
|
4116
4454
|
Select2,
|
|
4117
4455
|
{
|
|
4118
4456
|
value: form.type,
|
|
@@ -4125,17 +4463,17 @@ function ToolFormDialog({
|
|
|
4125
4463
|
},
|
|
4126
4464
|
disabled: isPending,
|
|
4127
4465
|
children: [
|
|
4128
|
-
/* @__PURE__ */
|
|
4129
|
-
/* @__PURE__ */
|
|
4466
|
+
/* @__PURE__ */ jsx17(SelectTrigger2, { id: "tool-type", children: /* @__PURE__ */ jsx17(SelectValue2, { placeholder: "Selecione o tipo" }) }),
|
|
4467
|
+
/* @__PURE__ */ jsx17(SelectContent2, { children: TOOL_AUTH_TYPES.map((t) => /* @__PURE__ */ jsx17(SelectItem2, { value: t.value, children: t.label }, t.value)) })
|
|
4130
4468
|
]
|
|
4131
4469
|
}
|
|
4132
4470
|
),
|
|
4133
|
-
/* @__PURE__ */
|
|
4134
|
-
form.typeError && /* @__PURE__ */
|
|
4471
|
+
/* @__PURE__ */ jsx17("p", { className: "text-xs text-muted-foreground", children: "Define se a ferramenta requer credenciais para funcionar." }),
|
|
4472
|
+
form.typeError && /* @__PURE__ */ jsx17("p", { className: "text-sm text-destructive", children: "Tipo \xE9 obrigat\xF3rio" })
|
|
4135
4473
|
] }),
|
|
4136
|
-
/* @__PURE__ */
|
|
4137
|
-
/* @__PURE__ */
|
|
4138
|
-
/* @__PURE__ */
|
|
4474
|
+
/* @__PURE__ */ jsxs15("div", { className: "space-y-2", children: [
|
|
4475
|
+
/* @__PURE__ */ jsx17(Label6, { htmlFor: "tool-description", children: "Descri\xE7\xE3o" }),
|
|
4476
|
+
/* @__PURE__ */ jsx17(
|
|
4139
4477
|
Textarea3,
|
|
4140
4478
|
{
|
|
4141
4479
|
id: "tool-description",
|
|
@@ -4148,9 +4486,9 @@ function ToolFormDialog({
|
|
|
4148
4486
|
}
|
|
4149
4487
|
)
|
|
4150
4488
|
] }),
|
|
4151
|
-
/* @__PURE__ */
|
|
4152
|
-
/* @__PURE__ */
|
|
4153
|
-
/* @__PURE__ */
|
|
4489
|
+
/* @__PURE__ */ jsxs15("div", { className: "space-y-2", children: [
|
|
4490
|
+
/* @__PURE__ */ jsx17(Label6, { htmlFor: "tool-function-defs", children: "Defini\xE7\xF5es de Fun\xE7\xE3o (JSON)" }),
|
|
4491
|
+
/* @__PURE__ */ jsx17(
|
|
4154
4492
|
Textarea3,
|
|
4155
4493
|
{
|
|
4156
4494
|
id: "tool-function-defs",
|
|
@@ -4182,12 +4520,12 @@ function ToolFormDialog({
|
|
|
4182
4520
|
disabled: isPending
|
|
4183
4521
|
}
|
|
4184
4522
|
),
|
|
4185
|
-
/* @__PURE__ */
|
|
4186
|
-
form.jsonError && /* @__PURE__ */
|
|
4523
|
+
/* @__PURE__ */ jsx17("p", { className: "text-xs text-muted-foreground", children: "Array de defini\xE7\xF5es no formato OpenAI Function Calling." }),
|
|
4524
|
+
form.jsonError && /* @__PURE__ */ jsx17("p", { className: "text-sm text-destructive", children: "JSON inv\xE1lido" })
|
|
4187
4525
|
] }),
|
|
4188
|
-
/* @__PURE__ */
|
|
4189
|
-
/* @__PURE__ */
|
|
4190
|
-
|
|
4526
|
+
/* @__PURE__ */ jsxs15(DialogFooter5, { children: [
|
|
4527
|
+
/* @__PURE__ */ jsx17(
|
|
4528
|
+
Button13,
|
|
4191
4529
|
{
|
|
4192
4530
|
type: "button",
|
|
4193
4531
|
variant: "outline",
|
|
@@ -4196,8 +4534,8 @@ function ToolFormDialog({
|
|
|
4196
4534
|
children: "Cancelar"
|
|
4197
4535
|
}
|
|
4198
4536
|
),
|
|
4199
|
-
/* @__PURE__ */
|
|
4200
|
-
isPending ? /* @__PURE__ */
|
|
4537
|
+
/* @__PURE__ */ jsxs15(Button13, { type: "submit", disabled: isPending, children: [
|
|
4538
|
+
isPending ? /* @__PURE__ */ jsx17(Loader26, { "aria-hidden": "true", className: "mr-2 h-4 w-4 animate-spin" }) : null,
|
|
4201
4539
|
isEditing ? "Salvar" : "Criar"
|
|
4202
4540
|
] })
|
|
4203
4541
|
] })
|
|
@@ -4206,11 +4544,11 @@ function ToolFormDialog({
|
|
|
4206
4544
|
}
|
|
4207
4545
|
|
|
4208
4546
|
// src/components/tools/tool-credentials-form.tsx
|
|
4209
|
-
import { useMemo as
|
|
4547
|
+
import { useMemo as useMemo9, useState as useState15 } from "react";
|
|
4210
4548
|
import { DataTable as DataTable3 } from "@greatapps/greatauth-ui";
|
|
4211
4549
|
import {
|
|
4212
|
-
Input as
|
|
4213
|
-
Button as
|
|
4550
|
+
Input as Input10,
|
|
4551
|
+
Button as Button14,
|
|
4214
4552
|
Badge as Badge8,
|
|
4215
4553
|
Tooltip as Tooltip4,
|
|
4216
4554
|
TooltipTrigger as TooltipTrigger4,
|
|
@@ -4224,11 +4562,11 @@ import {
|
|
|
4224
4562
|
AlertDialogHeader as AlertDialogHeader5,
|
|
4225
4563
|
AlertDialogTitle as AlertDialogTitle5
|
|
4226
4564
|
} from "@greatapps/greatauth-ui/ui";
|
|
4227
|
-
import { Trash2 as
|
|
4565
|
+
import { Trash2 as Trash26, Search as Search3 } from "lucide-react";
|
|
4228
4566
|
import { format as format3 } from "date-fns";
|
|
4229
4567
|
import { ptBR as ptBR3 } from "date-fns/locale";
|
|
4230
|
-
import { toast as
|
|
4231
|
-
import { jsx as
|
|
4568
|
+
import { toast as toast12 } from "sonner";
|
|
4569
|
+
import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
4232
4570
|
function formatDate2(dateStr) {
|
|
4233
4571
|
if (!dateStr) return "Sem expira\xE7\xE3o";
|
|
4234
4572
|
return format3(new Date(dateStr), "dd/MM/yyyy", { locale: ptBR3 });
|
|
@@ -4243,17 +4581,17 @@ function useColumns3(tools, onRemove) {
|
|
|
4243
4581
|
{
|
|
4244
4582
|
accessorKey: "label",
|
|
4245
4583
|
header: "Label",
|
|
4246
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
4584
|
+
cell: ({ row }) => /* @__PURE__ */ jsx18("span", { className: "font-medium", children: row.original.label || "\u2014" })
|
|
4247
4585
|
},
|
|
4248
4586
|
{
|
|
4249
4587
|
accessorKey: "id_tool",
|
|
4250
4588
|
header: "Ferramenta",
|
|
4251
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
4589
|
+
cell: ({ row }) => /* @__PURE__ */ jsx18("span", { className: "text-sm", children: getToolName(row.original.id_tool) })
|
|
4252
4590
|
},
|
|
4253
4591
|
{
|
|
4254
4592
|
accessorKey: "status",
|
|
4255
4593
|
header: "Status",
|
|
4256
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
4594
|
+
cell: ({ row }) => /* @__PURE__ */ jsx18(
|
|
4257
4595
|
Badge8,
|
|
4258
4596
|
{
|
|
4259
4597
|
variant: row.original.status === "active" ? "default" : "destructive",
|
|
@@ -4264,31 +4602,31 @@ function useColumns3(tools, onRemove) {
|
|
|
4264
4602
|
{
|
|
4265
4603
|
accessorKey: "expires_at",
|
|
4266
4604
|
header: "Expira em",
|
|
4267
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
4605
|
+
cell: ({ row }) => /* @__PURE__ */ jsx18("span", { className: "text-muted-foreground text-sm", children: formatDate2(row.original.expires_at) })
|
|
4268
4606
|
},
|
|
4269
4607
|
{
|
|
4270
4608
|
accessorKey: "datetime_add",
|
|
4271
4609
|
header: "Criado em",
|
|
4272
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
4610
|
+
cell: ({ row }) => /* @__PURE__ */ jsx18("span", { className: "text-muted-foreground text-sm", children: formatDate2(row.original.datetime_add) })
|
|
4273
4611
|
},
|
|
4274
4612
|
{
|
|
4275
4613
|
id: "actions",
|
|
4276
4614
|
header: "A\xE7\xF5es",
|
|
4277
4615
|
size: 100,
|
|
4278
4616
|
enableSorting: false,
|
|
4279
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
4280
|
-
/* @__PURE__ */
|
|
4281
|
-
|
|
4617
|
+
cell: ({ row }) => /* @__PURE__ */ jsx18("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ jsxs16(Tooltip4, { children: [
|
|
4618
|
+
/* @__PURE__ */ jsx18(TooltipTrigger4, { asChild: true, children: /* @__PURE__ */ jsx18(
|
|
4619
|
+
Button14,
|
|
4282
4620
|
{
|
|
4283
4621
|
variant: "ghost",
|
|
4284
4622
|
size: "icon",
|
|
4285
4623
|
className: "h-8 w-8 text-destructive hover:text-destructive",
|
|
4286
4624
|
"aria-label": "Excluir",
|
|
4287
4625
|
onClick: () => onRemove(row.original),
|
|
4288
|
-
children: /* @__PURE__ */
|
|
4626
|
+
children: /* @__PURE__ */ jsx18(Trash26, { className: "h-4 w-4" })
|
|
4289
4627
|
}
|
|
4290
4628
|
) }),
|
|
4291
|
-
/* @__PURE__ */
|
|
4629
|
+
/* @__PURE__ */ jsx18(TooltipContent4, { children: "Remover" })
|
|
4292
4630
|
] }) })
|
|
4293
4631
|
}
|
|
4294
4632
|
];
|
|
@@ -4302,15 +4640,15 @@ function ToolCredentialsForm({
|
|
|
4302
4640
|
const deleteMutation = useDeleteToolCredential(config);
|
|
4303
4641
|
const { data: toolsData } = useTools(config);
|
|
4304
4642
|
const tools = (toolsData?.data || []).filter((t) => !t.slug?.startsWith("gclinic_"));
|
|
4305
|
-
const [search, setSearch] =
|
|
4306
|
-
const [removeTarget, setRemoveTarget] =
|
|
4307
|
-
const internalToolIds =
|
|
4643
|
+
const [search, setSearch] = useState15("");
|
|
4644
|
+
const [removeTarget, setRemoveTarget] = useState15(null);
|
|
4645
|
+
const internalToolIds = useMemo9(() => {
|
|
4308
4646
|
const allRawTools = toolsData?.data || [];
|
|
4309
4647
|
return new Set(
|
|
4310
4648
|
allRawTools.filter((t) => t.slug?.startsWith("gclinic_")).map((t) => t.id)
|
|
4311
4649
|
);
|
|
4312
4650
|
}, [toolsData]);
|
|
4313
|
-
const filteredCredentials =
|
|
4651
|
+
const filteredCredentials = useMemo9(() => {
|
|
4314
4652
|
const visible = credentials.filter(
|
|
4315
4653
|
(cred) => !cred.id_tool || !internalToolIds.has(cred.id_tool)
|
|
4316
4654
|
);
|
|
@@ -4330,21 +4668,21 @@ function ToolCredentialsForm({
|
|
|
4330
4668
|
try {
|
|
4331
4669
|
const result = await deleteMutation.mutateAsync(removeTarget.id);
|
|
4332
4670
|
if (result.status === 1) {
|
|
4333
|
-
|
|
4671
|
+
toast12.success("Credencial removida");
|
|
4334
4672
|
} else {
|
|
4335
|
-
|
|
4673
|
+
toast12.error(result.message || "Erro ao remover credencial");
|
|
4336
4674
|
}
|
|
4337
4675
|
} catch {
|
|
4338
|
-
|
|
4676
|
+
toast12.error("Erro ao remover credencial");
|
|
4339
4677
|
} finally {
|
|
4340
4678
|
setRemoveTarget(null);
|
|
4341
4679
|
}
|
|
4342
4680
|
}
|
|
4343
|
-
return /* @__PURE__ */
|
|
4344
|
-
/* @__PURE__ */
|
|
4345
|
-
/* @__PURE__ */
|
|
4346
|
-
/* @__PURE__ */
|
|
4347
|
-
|
|
4681
|
+
return /* @__PURE__ */ jsxs16("div", { className: "space-y-4", children: [
|
|
4682
|
+
/* @__PURE__ */ jsx18("div", { className: "flex items-center gap-3", children: /* @__PURE__ */ jsxs16("div", { className: "relative flex-1 max-w-md", children: [
|
|
4683
|
+
/* @__PURE__ */ jsx18(Search3, { "aria-hidden": "true", className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
|
|
4684
|
+
/* @__PURE__ */ jsx18(
|
|
4685
|
+
Input10,
|
|
4348
4686
|
{
|
|
4349
4687
|
placeholder: "Buscar credenciais\\u2026",
|
|
4350
4688
|
"aria-label": "Buscar credenciais",
|
|
@@ -4356,7 +4694,7 @@ function ToolCredentialsForm({
|
|
|
4356
4694
|
}
|
|
4357
4695
|
)
|
|
4358
4696
|
] }) }),
|
|
4359
|
-
/* @__PURE__ */
|
|
4697
|
+
/* @__PURE__ */ jsx18(
|
|
4360
4698
|
DataTable3,
|
|
4361
4699
|
{
|
|
4362
4700
|
columns,
|
|
@@ -4365,19 +4703,19 @@ function ToolCredentialsForm({
|
|
|
4365
4703
|
emptyMessage: "Nenhuma credencial encontrada"
|
|
4366
4704
|
}
|
|
4367
4705
|
),
|
|
4368
|
-
/* @__PURE__ */
|
|
4706
|
+
/* @__PURE__ */ jsx18(
|
|
4369
4707
|
AlertDialog5,
|
|
4370
4708
|
{
|
|
4371
4709
|
open: !!removeTarget,
|
|
4372
4710
|
onOpenChange: (open) => !open && setRemoveTarget(null),
|
|
4373
|
-
children: /* @__PURE__ */
|
|
4374
|
-
/* @__PURE__ */
|
|
4375
|
-
/* @__PURE__ */
|
|
4376
|
-
/* @__PURE__ */
|
|
4711
|
+
children: /* @__PURE__ */ jsxs16(AlertDialogContent5, { children: [
|
|
4712
|
+
/* @__PURE__ */ jsxs16(AlertDialogHeader5, { children: [
|
|
4713
|
+
/* @__PURE__ */ jsx18(AlertDialogTitle5, { children: "Remover credencial?" }),
|
|
4714
|
+
/* @__PURE__ */ jsx18(AlertDialogDescription5, { children: "A credencial ser\xE1 removida permanentemente." })
|
|
4377
4715
|
] }),
|
|
4378
|
-
/* @__PURE__ */
|
|
4379
|
-
/* @__PURE__ */
|
|
4380
|
-
/* @__PURE__ */
|
|
4716
|
+
/* @__PURE__ */ jsxs16(AlertDialogFooter5, { children: [
|
|
4717
|
+
/* @__PURE__ */ jsx18(AlertDialogCancel5, { children: "Cancelar" }),
|
|
4718
|
+
/* @__PURE__ */ jsx18(
|
|
4381
4719
|
AlertDialogAction5,
|
|
4382
4720
|
{
|
|
4383
4721
|
onClick: handleRemove,
|
|
@@ -4393,10 +4731,10 @@ function ToolCredentialsForm({
|
|
|
4393
4731
|
}
|
|
4394
4732
|
|
|
4395
4733
|
// src/components/capabilities/integration-card.tsx
|
|
4396
|
-
import { useState as
|
|
4734
|
+
import { useState as useState16 } from "react";
|
|
4397
4735
|
import {
|
|
4398
4736
|
Badge as Badge9,
|
|
4399
|
-
Button as
|
|
4737
|
+
Button as Button15,
|
|
4400
4738
|
DropdownMenu,
|
|
4401
4739
|
DropdownMenuContent,
|
|
4402
4740
|
DropdownMenuItem,
|
|
@@ -4416,18 +4754,18 @@ import {
|
|
|
4416
4754
|
Settings as Settings3,
|
|
4417
4755
|
RefreshCw,
|
|
4418
4756
|
Clock,
|
|
4419
|
-
Plus as
|
|
4757
|
+
Plus as Plus4,
|
|
4420
4758
|
Unplug,
|
|
4421
|
-
Trash2 as
|
|
4759
|
+
Trash2 as Trash27
|
|
4422
4760
|
} from "lucide-react";
|
|
4423
|
-
import { Fragment as
|
|
4761
|
+
import { Fragment as Fragment4, jsx as jsx19, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
4424
4762
|
var ICON_MAP2 = {
|
|
4425
4763
|
CalendarSync: CalendarSync2,
|
|
4426
4764
|
Plug: Plug3,
|
|
4427
4765
|
Settings: Settings3,
|
|
4428
4766
|
RefreshCw,
|
|
4429
4767
|
Clock,
|
|
4430
|
-
Plus:
|
|
4768
|
+
Plus: Plus4
|
|
4431
4769
|
};
|
|
4432
4770
|
function resolveIcon2(name) {
|
|
4433
4771
|
return ICON_MAP2[name] ?? Plug3;
|
|
@@ -4461,9 +4799,9 @@ function IntegrationCard({
|
|
|
4461
4799
|
const Icon = resolveIcon2(definition.icon);
|
|
4462
4800
|
const isComingSoon = state === "coming_soon";
|
|
4463
4801
|
const isConnected = state === "connected" || state === "expired";
|
|
4464
|
-
const [deleteDialogOpen, setDeleteDialogOpen] =
|
|
4802
|
+
const [deleteDialogOpen, setDeleteDialogOpen] = useState16(false);
|
|
4465
4803
|
if (isAddNew) {
|
|
4466
|
-
return /* @__PURE__ */
|
|
4804
|
+
return /* @__PURE__ */ jsxs17(
|
|
4467
4805
|
"div",
|
|
4468
4806
|
{
|
|
4469
4807
|
className: cn(
|
|
@@ -4481,15 +4819,15 @@ function IntegrationCard({
|
|
|
4481
4819
|
}
|
|
4482
4820
|
},
|
|
4483
4821
|
children: [
|
|
4484
|
-
/* @__PURE__ */
|
|
4485
|
-
/* @__PURE__ */
|
|
4486
|
-
/* @__PURE__ */
|
|
4487
|
-
/* @__PURE__ */
|
|
4488
|
-
/* @__PURE__ */
|
|
4822
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex items-start gap-3", children: [
|
|
4823
|
+
/* @__PURE__ */ jsx19("div", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/5 text-primary/60", children: /* @__PURE__ */ jsx19(Icon, { className: "h-5 w-5" }) }),
|
|
4824
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex-1 min-w-0 space-y-0.5", children: [
|
|
4825
|
+
/* @__PURE__ */ jsx19("h3", { className: "text-sm font-semibold leading-tight text-foreground", children: definition.name }),
|
|
4826
|
+
/* @__PURE__ */ jsx19("p", { className: "text-xs text-muted-foreground leading-relaxed", children: "Conectar nova conta" })
|
|
4489
4827
|
] })
|
|
4490
4828
|
] }),
|
|
4491
|
-
/* @__PURE__ */
|
|
4492
|
-
|
|
4829
|
+
/* @__PURE__ */ jsx19("div", { className: "mt-auto flex items-center justify-end pt-1", children: /* @__PURE__ */ jsx19(
|
|
4830
|
+
Button15,
|
|
4493
4831
|
{
|
|
4494
4832
|
variant: "outline",
|
|
4495
4833
|
size: "sm",
|
|
@@ -4507,84 +4845,84 @@ function IntegrationCard({
|
|
|
4507
4845
|
}
|
|
4508
4846
|
if (isComingSoon) {
|
|
4509
4847
|
const badge2 = STATE_BADGES[state];
|
|
4510
|
-
return /* @__PURE__ */
|
|
4848
|
+
return /* @__PURE__ */ jsxs17(
|
|
4511
4849
|
"div",
|
|
4512
4850
|
{
|
|
4513
4851
|
className: "group relative flex flex-col gap-3 rounded-xl border bg-card p-5 opacity-60 cursor-default",
|
|
4514
4852
|
"aria-disabled": true,
|
|
4515
4853
|
children: [
|
|
4516
|
-
/* @__PURE__ */
|
|
4517
|
-
/* @__PURE__ */
|
|
4518
|
-
/* @__PURE__ */
|
|
4854
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex items-start justify-between gap-2", children: [
|
|
4855
|
+
/* @__PURE__ */ jsx19("div", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary", children: /* @__PURE__ */ jsx19(Icon, { className: "h-5 w-5" }) }),
|
|
4856
|
+
/* @__PURE__ */ jsx19(Badge9, { variant: "outline", className: cn("text-xs", badge2.className), children: badge2.label })
|
|
4519
4857
|
] }),
|
|
4520
|
-
/* @__PURE__ */
|
|
4521
|
-
/* @__PURE__ */
|
|
4522
|
-
/* @__PURE__ */
|
|
4858
|
+
/* @__PURE__ */ jsxs17("div", { className: "space-y-1", children: [
|
|
4859
|
+
/* @__PURE__ */ jsx19("h3", { className: "text-sm font-semibold leading-tight", children: definition.name }),
|
|
4860
|
+
/* @__PURE__ */ jsx19("p", { className: "text-xs text-muted-foreground leading-relaxed", children: definition.description })
|
|
4523
4861
|
] })
|
|
4524
4862
|
]
|
|
4525
4863
|
}
|
|
4526
4864
|
);
|
|
4527
4865
|
}
|
|
4528
4866
|
const badge = STATE_BADGES[state];
|
|
4529
|
-
return /* @__PURE__ */
|
|
4530
|
-
/* @__PURE__ */
|
|
4867
|
+
return /* @__PURE__ */ jsxs17(Fragment4, { children: [
|
|
4868
|
+
/* @__PURE__ */ jsxs17(
|
|
4531
4869
|
"div",
|
|
4532
4870
|
{
|
|
4533
4871
|
className: "group relative flex flex-col gap-3 rounded-xl border bg-card p-5 transition-shadow hover:shadow-md",
|
|
4534
4872
|
children: [
|
|
4535
|
-
/* @__PURE__ */
|
|
4536
|
-
/* @__PURE__ */
|
|
4537
|
-
/* @__PURE__ */
|
|
4538
|
-
/* @__PURE__ */
|
|
4539
|
-
/* @__PURE__ */
|
|
4540
|
-
accountLabel && /* @__PURE__ */
|
|
4873
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex items-start justify-between gap-2", children: [
|
|
4874
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex items-start gap-3 min-w-0 flex-1", children: [
|
|
4875
|
+
/* @__PURE__ */ jsx19("div", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary", children: /* @__PURE__ */ jsx19(Icon, { className: "h-5 w-5" }) }),
|
|
4876
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex-1 min-w-0 space-y-0.5", children: [
|
|
4877
|
+
/* @__PURE__ */ jsx19("h3", { className: "text-sm font-semibold leading-tight", children: definition.name }),
|
|
4878
|
+
accountLabel && /* @__PURE__ */ jsx19("p", { className: "text-xs text-muted-foreground leading-relaxed truncate", title: accountLabel, children: accountLabel })
|
|
4541
4879
|
] })
|
|
4542
4880
|
] }),
|
|
4543
|
-
/* @__PURE__ */
|
|
4881
|
+
/* @__PURE__ */ jsx19(Badge9, { variant: "outline", className: cn("text-xs shrink-0", badge.className), children: badge.label })
|
|
4544
4882
|
] }),
|
|
4545
|
-
/* @__PURE__ */
|
|
4546
|
-
/* @__PURE__ */
|
|
4547
|
-
|
|
4883
|
+
/* @__PURE__ */ jsx19("div", { className: "mt-auto flex items-center justify-end gap-2 pt-1", children: /* @__PURE__ */ jsxs17(DropdownMenu, { children: [
|
|
4884
|
+
/* @__PURE__ */ jsx19(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs17(
|
|
4885
|
+
Button15,
|
|
4548
4886
|
{
|
|
4549
4887
|
variant: "outline",
|
|
4550
4888
|
size: "sm",
|
|
4551
4889
|
className: "text-xs gap-1.5",
|
|
4552
4890
|
children: [
|
|
4553
|
-
/* @__PURE__ */
|
|
4891
|
+
/* @__PURE__ */ jsx19(Settings3, { className: "h-3.5 w-3.5" }),
|
|
4554
4892
|
"Configurar"
|
|
4555
4893
|
]
|
|
4556
4894
|
}
|
|
4557
4895
|
) }),
|
|
4558
|
-
/* @__PURE__ */
|
|
4559
|
-
/* @__PURE__ */
|
|
4896
|
+
/* @__PURE__ */ jsxs17(DropdownMenuContent, { align: "end", children: [
|
|
4897
|
+
/* @__PURE__ */ jsxs17(
|
|
4560
4898
|
DropdownMenuItem,
|
|
4561
4899
|
{
|
|
4562
4900
|
onClick: () => onReconnect?.(card),
|
|
4563
4901
|
className: "gap-2",
|
|
4564
4902
|
children: [
|
|
4565
|
-
/* @__PURE__ */
|
|
4903
|
+
/* @__PURE__ */ jsx19(RefreshCw, { className: "h-4 w-4" }),
|
|
4566
4904
|
"Reconectar"
|
|
4567
4905
|
]
|
|
4568
4906
|
}
|
|
4569
4907
|
),
|
|
4570
|
-
/* @__PURE__ */
|
|
4908
|
+
/* @__PURE__ */ jsxs17(
|
|
4571
4909
|
DropdownMenuItem,
|
|
4572
4910
|
{
|
|
4573
4911
|
onClick: () => onDisconnect?.(card),
|
|
4574
4912
|
className: "gap-2",
|
|
4575
4913
|
children: [
|
|
4576
|
-
/* @__PURE__ */
|
|
4914
|
+
/* @__PURE__ */ jsx19(Unplug, { className: "h-4 w-4" }),
|
|
4577
4915
|
"Desconectar"
|
|
4578
4916
|
]
|
|
4579
4917
|
}
|
|
4580
4918
|
),
|
|
4581
|
-
/* @__PURE__ */
|
|
4919
|
+
/* @__PURE__ */ jsxs17(
|
|
4582
4920
|
DropdownMenuItem,
|
|
4583
4921
|
{
|
|
4584
4922
|
onClick: () => setDeleteDialogOpen(true),
|
|
4585
4923
|
className: "gap-2 text-destructive focus:text-destructive",
|
|
4586
4924
|
children: [
|
|
4587
|
-
/* @__PURE__ */
|
|
4925
|
+
/* @__PURE__ */ jsx19(Trash27, { className: "h-4 w-4" }),
|
|
4588
4926
|
"Remover"
|
|
4589
4927
|
]
|
|
4590
4928
|
}
|
|
@@ -4594,10 +4932,10 @@ function IntegrationCard({
|
|
|
4594
4932
|
]
|
|
4595
4933
|
}
|
|
4596
4934
|
),
|
|
4597
|
-
/* @__PURE__ */
|
|
4598
|
-
/* @__PURE__ */
|
|
4599
|
-
/* @__PURE__ */
|
|
4600
|
-
/* @__PURE__ */
|
|
4935
|
+
/* @__PURE__ */ jsx19(AlertDialog6, { open: deleteDialogOpen, onOpenChange: setDeleteDialogOpen, children: /* @__PURE__ */ jsxs17(AlertDialogContent6, { children: [
|
|
4936
|
+
/* @__PURE__ */ jsxs17(AlertDialogHeader6, { children: [
|
|
4937
|
+
/* @__PURE__ */ jsx19(AlertDialogTitle6, { children: "Remover integra\xE7\xE3o?" }),
|
|
4938
|
+
/* @__PURE__ */ jsxs17(AlertDialogDescription6, { children: [
|
|
4601
4939
|
"Esta a\xE7\xE3o vai remover a credencial",
|
|
4602
4940
|
accountLabel ? ` (${accountLabel})` : "",
|
|
4603
4941
|
" de ",
|
|
@@ -4605,9 +4943,9 @@ function IntegrationCard({
|
|
|
4605
4943
|
". Esta a\xE7\xE3o n\xE3o pode ser desfeita."
|
|
4606
4944
|
] })
|
|
4607
4945
|
] }),
|
|
4608
|
-
/* @__PURE__ */
|
|
4609
|
-
/* @__PURE__ */
|
|
4610
|
-
/* @__PURE__ */
|
|
4946
|
+
/* @__PURE__ */ jsxs17(AlertDialogFooter6, { children: [
|
|
4947
|
+
/* @__PURE__ */ jsx19(AlertDialogCancel6, { children: "Cancelar" }),
|
|
4948
|
+
/* @__PURE__ */ jsx19(
|
|
4611
4949
|
AlertDialogAction6,
|
|
4612
4950
|
{
|
|
4613
4951
|
onClick: () => {
|
|
@@ -4624,12 +4962,12 @@ function IntegrationCard({
|
|
|
4624
4962
|
}
|
|
4625
4963
|
|
|
4626
4964
|
// src/components/capabilities/advanced-tab.tsx
|
|
4627
|
-
import { useState as
|
|
4965
|
+
import { useState as useState17 } from "react";
|
|
4628
4966
|
import { Info } from "lucide-react";
|
|
4629
|
-
import { jsx as
|
|
4967
|
+
import { jsx as jsx20, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
4630
4968
|
function AdvancedTab({ config, agentId, gagentsApiUrl }) {
|
|
4631
|
-
const [editingTool, setEditingTool] =
|
|
4632
|
-
const [showToolForm, setShowToolForm] =
|
|
4969
|
+
const [editingTool, setEditingTool] = useState17(null);
|
|
4970
|
+
const [showToolForm, setShowToolForm] = useState17(false);
|
|
4633
4971
|
function handleEditTool(tool) {
|
|
4634
4972
|
setEditingTool(tool);
|
|
4635
4973
|
setShowToolForm(true);
|
|
@@ -4638,22 +4976,22 @@ function AdvancedTab({ config, agentId, gagentsApiUrl }) {
|
|
|
4638
4976
|
setShowToolForm(open);
|
|
4639
4977
|
if (!open) setEditingTool(null);
|
|
4640
4978
|
}
|
|
4641
|
-
return /* @__PURE__ */
|
|
4642
|
-
/* @__PURE__ */
|
|
4643
|
-
/* @__PURE__ */
|
|
4644
|
-
/* @__PURE__ */
|
|
4979
|
+
return /* @__PURE__ */ jsxs18("div", { className: "space-y-8", children: [
|
|
4980
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex items-start gap-3 rounded-lg border border-blue-200 bg-blue-50 p-4 dark:border-blue-900 dark:bg-blue-950/30", children: [
|
|
4981
|
+
/* @__PURE__ */ jsx20(Info, { className: "mt-0.5 h-4 w-4 shrink-0 text-blue-600 dark:text-blue-400" }),
|
|
4982
|
+
/* @__PURE__ */ jsxs18("p", { className: "text-sm text-blue-800 dark:text-blue-300", children: [
|
|
4645
4983
|
"Use as abas ",
|
|
4646
|
-
/* @__PURE__ */
|
|
4984
|
+
/* @__PURE__ */ jsx20("strong", { children: "Capacidades" }),
|
|
4647
4985
|
" e ",
|
|
4648
|
-
/* @__PURE__ */
|
|
4986
|
+
/* @__PURE__ */ jsx20("strong", { children: "Integra\xE7\xF5es" }),
|
|
4649
4987
|
" para configura\xE7\xE3o simplificada. Esta aba oferece controlo manual avan\xE7ado sobre ferramentas. As credenciais s\xE3o geridas dentro de cada ferramenta."
|
|
4650
4988
|
] })
|
|
4651
4989
|
] }),
|
|
4652
|
-
/* @__PURE__ */
|
|
4653
|
-
/* @__PURE__ */
|
|
4654
|
-
/* @__PURE__ */
|
|
4990
|
+
/* @__PURE__ */ jsxs18("section", { className: "space-y-3", children: [
|
|
4991
|
+
/* @__PURE__ */ jsx20("h3", { className: "text-sm font-medium", children: "Ferramentas" }),
|
|
4992
|
+
/* @__PURE__ */ jsx20(ToolsTable, { onEdit: handleEditTool, config })
|
|
4655
4993
|
] }),
|
|
4656
|
-
/* @__PURE__ */
|
|
4994
|
+
/* @__PURE__ */ jsx20(
|
|
4657
4995
|
ToolFormDialog,
|
|
4658
4996
|
{
|
|
4659
4997
|
open: showToolForm,
|
|
@@ -4666,43 +5004,43 @@ function AdvancedTab({ config, agentId, gagentsApiUrl }) {
|
|
|
4666
5004
|
}
|
|
4667
5005
|
|
|
4668
5006
|
// src/components/capabilities/integration-wizard.tsx
|
|
4669
|
-
import { useCallback as
|
|
5007
|
+
import { useCallback as useCallback7, useEffect as useEffect6, useRef as useRef3, useState as useState18 } from "react";
|
|
4670
5008
|
import {
|
|
4671
|
-
Dialog as
|
|
4672
|
-
DialogContent as
|
|
5009
|
+
Dialog as Dialog7,
|
|
5010
|
+
DialogContent as DialogContent7,
|
|
4673
5011
|
DialogFooter as DialogFooter6,
|
|
4674
|
-
DialogHeader as
|
|
4675
|
-
DialogTitle as
|
|
4676
|
-
Button as
|
|
5012
|
+
DialogHeader as DialogHeader7,
|
|
5013
|
+
DialogTitle as DialogTitle7,
|
|
5014
|
+
Button as Button17
|
|
4677
5015
|
} from "@greatapps/greatauth-ui/ui";
|
|
4678
5016
|
import { Loader2 as Loader29, ChevronLeft, ChevronRight, Check as Check2 } from "lucide-react";
|
|
4679
|
-
import { toast as
|
|
5017
|
+
import { toast as toast13 } from "sonner";
|
|
4680
5018
|
|
|
4681
5019
|
// src/components/capabilities/wizard-steps/info-step.tsx
|
|
4682
5020
|
import { Check, Info as Info2 } from "lucide-react";
|
|
4683
|
-
import { jsx as
|
|
5021
|
+
import { jsx as jsx21, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
4684
5022
|
function InfoStep({ integration, meta }) {
|
|
4685
|
-
return /* @__PURE__ */
|
|
4686
|
-
/* @__PURE__ */
|
|
4687
|
-
meta.icon && /* @__PURE__ */
|
|
4688
|
-
/* @__PURE__ */
|
|
4689
|
-
/* @__PURE__ */
|
|
4690
|
-
/* @__PURE__ */
|
|
5023
|
+
return /* @__PURE__ */ jsxs19("div", { className: "space-y-6", children: [
|
|
5024
|
+
/* @__PURE__ */ jsxs19("div", { className: "flex items-start gap-4", children: [
|
|
5025
|
+
meta.icon && /* @__PURE__ */ jsx21("div", { className: "flex h-12 w-12 shrink-0 items-center justify-center rounded-lg bg-muted", children: meta.icon }),
|
|
5026
|
+
/* @__PURE__ */ jsxs19("div", { className: "space-y-1", children: [
|
|
5027
|
+
/* @__PURE__ */ jsx21("h3", { className: "text-lg font-semibold", children: integration.name }),
|
|
5028
|
+
/* @__PURE__ */ jsx21("p", { className: "text-sm text-muted-foreground", children: integration.description })
|
|
4691
5029
|
] })
|
|
4692
5030
|
] }),
|
|
4693
|
-
meta.capabilities.length > 0 && /* @__PURE__ */
|
|
4694
|
-
/* @__PURE__ */
|
|
4695
|
-
/* @__PURE__ */
|
|
4696
|
-
/* @__PURE__ */
|
|
5031
|
+
meta.capabilities.length > 0 && /* @__PURE__ */ jsxs19("div", { className: "space-y-3", children: [
|
|
5032
|
+
/* @__PURE__ */ jsx21("h4", { className: "text-sm font-medium", children: "O que esta integra\xE7\xE3o permite:" }),
|
|
5033
|
+
/* @__PURE__ */ jsx21("ul", { className: "space-y-2", children: meta.capabilities.map((cap, i) => /* @__PURE__ */ jsxs19("li", { className: "flex items-start gap-2 text-sm", children: [
|
|
5034
|
+
/* @__PURE__ */ jsx21(
|
|
4697
5035
|
Check,
|
|
4698
5036
|
{
|
|
4699
5037
|
"aria-hidden": "true",
|
|
4700
5038
|
className: "mt-0.5 h-4 w-4 shrink-0 text-green-600"
|
|
4701
5039
|
}
|
|
4702
5040
|
),
|
|
4703
|
-
/* @__PURE__ */
|
|
4704
|
-
/* @__PURE__ */
|
|
4705
|
-
cap.description && /* @__PURE__ */
|
|
5041
|
+
/* @__PURE__ */ jsxs19("div", { children: [
|
|
5042
|
+
/* @__PURE__ */ jsx21("span", { className: "font-medium", children: cap.label }),
|
|
5043
|
+
cap.description && /* @__PURE__ */ jsxs19("span", { className: "text-muted-foreground", children: [
|
|
4706
5044
|
" ",
|
|
4707
5045
|
"\u2014 ",
|
|
4708
5046
|
cap.description
|
|
@@ -4710,21 +5048,21 @@ function InfoStep({ integration, meta }) {
|
|
|
4710
5048
|
] })
|
|
4711
5049
|
] }, i)) })
|
|
4712
5050
|
] }),
|
|
4713
|
-
meta.requirements.length > 0 && /* @__PURE__ */
|
|
4714
|
-
/* @__PURE__ */
|
|
4715
|
-
/* @__PURE__ */
|
|
5051
|
+
meta.requirements.length > 0 && /* @__PURE__ */ jsxs19("div", { className: "space-y-3", children: [
|
|
5052
|
+
/* @__PURE__ */ jsx21("h4", { className: "text-sm font-medium", children: "Requisitos:" }),
|
|
5053
|
+
/* @__PURE__ */ jsx21("ul", { className: "space-y-2", children: meta.requirements.map((req, i) => /* @__PURE__ */ jsxs19(
|
|
4716
5054
|
"li",
|
|
4717
5055
|
{
|
|
4718
5056
|
className: "flex items-start gap-2 text-sm text-muted-foreground",
|
|
4719
5057
|
children: [
|
|
4720
|
-
/* @__PURE__ */
|
|
5058
|
+
/* @__PURE__ */ jsx21(
|
|
4721
5059
|
Info2,
|
|
4722
5060
|
{
|
|
4723
5061
|
"aria-hidden": "true",
|
|
4724
5062
|
className: "mt-0.5 h-4 w-4 shrink-0 text-blue-500"
|
|
4725
5063
|
}
|
|
4726
5064
|
),
|
|
4727
|
-
/* @__PURE__ */
|
|
5065
|
+
/* @__PURE__ */ jsx21("span", { children: req })
|
|
4728
5066
|
]
|
|
4729
5067
|
},
|
|
4730
5068
|
i
|
|
@@ -4735,8 +5073,8 @@ function InfoStep({ integration, meta }) {
|
|
|
4735
5073
|
|
|
4736
5074
|
// src/components/capabilities/wizard-steps/credentials-step.tsx
|
|
4737
5075
|
import { CheckCircle2, Loader2 as Loader27, AlertCircle, Shield } from "lucide-react";
|
|
4738
|
-
import { Button as
|
|
4739
|
-
import { jsx as
|
|
5076
|
+
import { Button as Button16, Input as Input11, Label as Label7 } from "@greatapps/greatauth-ui/ui";
|
|
5077
|
+
import { jsx as jsx22, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
4740
5078
|
function CredentialsStep({
|
|
4741
5079
|
integration,
|
|
4742
5080
|
meta,
|
|
@@ -4748,7 +5086,7 @@ function CredentialsStep({
|
|
|
4748
5086
|
isReconnect = false
|
|
4749
5087
|
}) {
|
|
4750
5088
|
if (integration.authType === "oauth2") {
|
|
4751
|
-
return /* @__PURE__ */
|
|
5089
|
+
return /* @__PURE__ */ jsx22(
|
|
4752
5090
|
OAuthCredentials,
|
|
4753
5091
|
{
|
|
4754
5092
|
integration,
|
|
@@ -4760,7 +5098,7 @@ function CredentialsStep({
|
|
|
4760
5098
|
}
|
|
4761
5099
|
);
|
|
4762
5100
|
}
|
|
4763
|
-
return /* @__PURE__ */
|
|
5101
|
+
return /* @__PURE__ */ jsx22(ApiKeyCredentials, { apiKey, onApiKeyChange });
|
|
4764
5102
|
}
|
|
4765
5103
|
function OAuthCredentials({
|
|
4766
5104
|
integration,
|
|
@@ -4771,14 +5109,14 @@ function OAuthCredentials({
|
|
|
4771
5109
|
isReconnect
|
|
4772
5110
|
}) {
|
|
4773
5111
|
const providerLabel = meta.providerLabel || integration.name;
|
|
4774
|
-
return /* @__PURE__ */
|
|
4775
|
-
/* @__PURE__ */
|
|
4776
|
-
/* @__PURE__ */
|
|
4777
|
-
/* @__PURE__ */
|
|
5112
|
+
return /* @__PURE__ */ jsxs20("div", { className: "space-y-6", children: [
|
|
5113
|
+
/* @__PURE__ */ jsxs20("div", { className: "space-y-2", children: [
|
|
5114
|
+
/* @__PURE__ */ jsx22("h3", { className: "text-lg font-semibold", children: "Autentica\xE7\xE3o" }),
|
|
5115
|
+
/* @__PURE__ */ jsx22("p", { className: "text-sm text-muted-foreground", children: isReconnect ? `Reconecte sua conta ${providerLabel} para renovar a autoriza\xE7\xE3o.` : `Conecte sua conta ${providerLabel} para permitir o acesso.` })
|
|
4778
5116
|
] }),
|
|
4779
|
-
/* @__PURE__ */
|
|
4780
|
-
oauthStatus === "idle" && /* @__PURE__ */
|
|
4781
|
-
|
|
5117
|
+
/* @__PURE__ */ jsxs20("div", { className: "flex flex-col items-center gap-4 rounded-lg border p-6", children: [
|
|
5118
|
+
oauthStatus === "idle" && /* @__PURE__ */ jsxs20(
|
|
5119
|
+
Button16,
|
|
4782
5120
|
{
|
|
4783
5121
|
onClick: onStartOAuth,
|
|
4784
5122
|
size: "lg",
|
|
@@ -4789,56 +5127,56 @@ function OAuthCredentials({
|
|
|
4789
5127
|
]
|
|
4790
5128
|
}
|
|
4791
5129
|
),
|
|
4792
|
-
oauthStatus === "waiting" && /* @__PURE__ */
|
|
4793
|
-
/* @__PURE__ */
|
|
5130
|
+
oauthStatus === "waiting" && /* @__PURE__ */ jsxs20("div", { className: "flex flex-col items-center gap-3 text-center", children: [
|
|
5131
|
+
/* @__PURE__ */ jsx22(
|
|
4794
5132
|
Loader27,
|
|
4795
5133
|
{
|
|
4796
5134
|
"aria-hidden": "true",
|
|
4797
5135
|
className: "h-8 w-8 animate-spin text-muted-foreground"
|
|
4798
5136
|
}
|
|
4799
5137
|
),
|
|
4800
|
-
/* @__PURE__ */
|
|
4801
|
-
/* @__PURE__ */
|
|
4802
|
-
/* @__PURE__ */
|
|
5138
|
+
/* @__PURE__ */ jsxs20("div", { children: [
|
|
5139
|
+
/* @__PURE__ */ jsx22("p", { className: "text-sm font-medium", children: "Aguardando autoriza\xE7\xE3o..." }),
|
|
5140
|
+
/* @__PURE__ */ jsx22("p", { className: "text-xs text-muted-foreground", children: "Complete o login na janela que foi aberta." })
|
|
4803
5141
|
] })
|
|
4804
5142
|
] }),
|
|
4805
|
-
oauthStatus === "success" && oauthResult && /* @__PURE__ */
|
|
4806
|
-
/* @__PURE__ */
|
|
5143
|
+
oauthStatus === "success" && oauthResult && /* @__PURE__ */ jsxs20("div", { className: "flex flex-col items-center gap-3 text-center", children: [
|
|
5144
|
+
/* @__PURE__ */ jsx22(
|
|
4807
5145
|
CheckCircle2,
|
|
4808
5146
|
{
|
|
4809
5147
|
"aria-hidden": "true",
|
|
4810
5148
|
className: "h-8 w-8 text-green-600"
|
|
4811
5149
|
}
|
|
4812
5150
|
),
|
|
4813
|
-
/* @__PURE__ */
|
|
4814
|
-
/* @__PURE__ */
|
|
4815
|
-
oauthResult.email && /* @__PURE__ */
|
|
5151
|
+
/* @__PURE__ */ jsxs20("div", { children: [
|
|
5152
|
+
/* @__PURE__ */ jsx22("p", { className: "text-sm font-medium text-green-700", children: "Conectado com sucesso!" }),
|
|
5153
|
+
oauthResult.email && /* @__PURE__ */ jsx22("p", { className: "text-xs text-muted-foreground", children: oauthResult.email })
|
|
4816
5154
|
] })
|
|
4817
5155
|
] }),
|
|
4818
|
-
oauthStatus === "error" && /* @__PURE__ */
|
|
4819
|
-
/* @__PURE__ */
|
|
5156
|
+
oauthStatus === "error" && /* @__PURE__ */ jsxs20("div", { className: "flex flex-col items-center gap-3 text-center", children: [
|
|
5157
|
+
/* @__PURE__ */ jsx22(
|
|
4820
5158
|
AlertCircle,
|
|
4821
5159
|
{
|
|
4822
5160
|
"aria-hidden": "true",
|
|
4823
5161
|
className: "h-8 w-8 text-destructive"
|
|
4824
5162
|
}
|
|
4825
5163
|
),
|
|
4826
|
-
/* @__PURE__ */
|
|
4827
|
-
/* @__PURE__ */
|
|
4828
|
-
oauthResult?.error && /* @__PURE__ */
|
|
5164
|
+
/* @__PURE__ */ jsxs20("div", { children: [
|
|
5165
|
+
/* @__PURE__ */ jsx22("p", { className: "text-sm font-medium text-destructive", children: "Falha na conex\xE3o" }),
|
|
5166
|
+
oauthResult?.error && /* @__PURE__ */ jsx22("p", { className: "text-xs text-muted-foreground", children: oauthResult.error })
|
|
4829
5167
|
] }),
|
|
4830
|
-
/* @__PURE__ */
|
|
5168
|
+
/* @__PURE__ */ jsx22(Button16, { variant: "outline", onClick: onStartOAuth, size: "sm", children: "Tentar novamente" })
|
|
4831
5169
|
] })
|
|
4832
5170
|
] }),
|
|
4833
|
-
/* @__PURE__ */
|
|
4834
|
-
/* @__PURE__ */
|
|
5171
|
+
/* @__PURE__ */ jsxs20("div", { className: "flex items-start gap-2 rounded-md bg-muted/50 p-3", children: [
|
|
5172
|
+
/* @__PURE__ */ jsx22(
|
|
4835
5173
|
Shield,
|
|
4836
5174
|
{
|
|
4837
5175
|
"aria-hidden": "true",
|
|
4838
5176
|
className: "mt-0.5 h-4 w-4 shrink-0 text-green-600"
|
|
4839
5177
|
}
|
|
4840
5178
|
),
|
|
4841
|
-
/* @__PURE__ */
|
|
5179
|
+
/* @__PURE__ */ jsxs20("p", { className: "text-xs text-muted-foreground", children: [
|
|
4842
5180
|
"Seus dados est\xE3o seguros. Usamos OAuth 2.0 para autentica\xE7\xE3o \u2014 nunca armazenamos sua senha. Voc\xEA pode revogar o acesso a qualquer momento nas configura\xE7\xF5es da sua conta ",
|
|
4843
5181
|
providerLabel,
|
|
4844
5182
|
"."
|
|
@@ -4850,15 +5188,15 @@ function ApiKeyCredentials({
|
|
|
4850
5188
|
apiKey,
|
|
4851
5189
|
onApiKeyChange
|
|
4852
5190
|
}) {
|
|
4853
|
-
return /* @__PURE__ */
|
|
4854
|
-
/* @__PURE__ */
|
|
4855
|
-
/* @__PURE__ */
|
|
4856
|
-
/* @__PURE__ */
|
|
5191
|
+
return /* @__PURE__ */ jsxs20("div", { className: "space-y-6", children: [
|
|
5192
|
+
/* @__PURE__ */ jsxs20("div", { className: "space-y-2", children: [
|
|
5193
|
+
/* @__PURE__ */ jsx22("h3", { className: "text-lg font-semibold", children: "Autentica\xE7\xE3o" }),
|
|
5194
|
+
/* @__PURE__ */ jsx22("p", { className: "text-sm text-muted-foreground", children: "Insira a chave de API para conectar a integra\xE7\xE3o." })
|
|
4857
5195
|
] }),
|
|
4858
|
-
/* @__PURE__ */
|
|
4859
|
-
/* @__PURE__ */
|
|
4860
|
-
/* @__PURE__ */
|
|
4861
|
-
|
|
5196
|
+
/* @__PURE__ */ jsxs20("div", { className: "space-y-2", children: [
|
|
5197
|
+
/* @__PURE__ */ jsx22(Label7, { htmlFor: "integration-api-key", children: "Chave de API" }),
|
|
5198
|
+
/* @__PURE__ */ jsx22(
|
|
5199
|
+
Input11,
|
|
4862
5200
|
{
|
|
4863
5201
|
id: "integration-api-key",
|
|
4864
5202
|
type: "password",
|
|
@@ -4869,15 +5207,15 @@ function ApiKeyCredentials({
|
|
|
4869
5207
|
}
|
|
4870
5208
|
)
|
|
4871
5209
|
] }),
|
|
4872
|
-
/* @__PURE__ */
|
|
4873
|
-
/* @__PURE__ */
|
|
5210
|
+
/* @__PURE__ */ jsxs20("div", { className: "flex items-start gap-2 rounded-md bg-muted/50 p-3", children: [
|
|
5211
|
+
/* @__PURE__ */ jsx22(
|
|
4874
5212
|
Shield,
|
|
4875
5213
|
{
|
|
4876
5214
|
"aria-hidden": "true",
|
|
4877
5215
|
className: "mt-0.5 h-4 w-4 shrink-0 text-green-600"
|
|
4878
5216
|
}
|
|
4879
5217
|
),
|
|
4880
|
-
/* @__PURE__ */
|
|
5218
|
+
/* @__PURE__ */ jsx22("p", { className: "text-xs text-muted-foreground", children: "Sua chave de API \xE9 armazenada de forma segura e encriptada. Nunca \xE9 exposta no frontend." })
|
|
4881
5219
|
] })
|
|
4882
5220
|
] });
|
|
4883
5221
|
}
|
|
@@ -4885,14 +5223,14 @@ function ApiKeyCredentials({
|
|
|
4885
5223
|
// src/components/capabilities/wizard-steps/config-step.tsx
|
|
4886
5224
|
import { Loader2 as Loader28 } from "lucide-react";
|
|
4887
5225
|
import {
|
|
4888
|
-
Label as
|
|
5226
|
+
Label as Label8,
|
|
4889
5227
|
Select as Select3,
|
|
4890
5228
|
SelectContent as SelectContent3,
|
|
4891
5229
|
SelectItem as SelectItem3,
|
|
4892
5230
|
SelectTrigger as SelectTrigger3,
|
|
4893
5231
|
SelectValue as SelectValue3
|
|
4894
5232
|
} from "@greatapps/greatauth-ui/ui";
|
|
4895
|
-
import { jsx as
|
|
5233
|
+
import { jsx as jsx23, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
4896
5234
|
function ConfigStep({
|
|
4897
5235
|
integration,
|
|
4898
5236
|
options,
|
|
@@ -4904,27 +5242,27 @@ function ConfigStep({
|
|
|
4904
5242
|
}) {
|
|
4905
5243
|
const label = selectLabel || getDefaultLabel(integration.slug);
|
|
4906
5244
|
const placeholder = selectPlaceholder || getDefaultPlaceholder(integration.slug);
|
|
4907
|
-
return /* @__PURE__ */
|
|
4908
|
-
/* @__PURE__ */
|
|
4909
|
-
/* @__PURE__ */
|
|
4910
|
-
/* @__PURE__ */
|
|
5245
|
+
return /* @__PURE__ */ jsxs21("div", { className: "space-y-6", children: [
|
|
5246
|
+
/* @__PURE__ */ jsxs21("div", { className: "space-y-2", children: [
|
|
5247
|
+
/* @__PURE__ */ jsx23("h3", { className: "text-lg font-semibold", children: "Configura\xE7\xE3o" }),
|
|
5248
|
+
/* @__PURE__ */ jsx23("p", { className: "text-sm text-muted-foreground", children: "Configure as op\xE7\xF5es espec\xEDficas da integra\xE7\xE3o." })
|
|
4911
5249
|
] }),
|
|
4912
|
-
isLoading ? /* @__PURE__ */
|
|
4913
|
-
/* @__PURE__ */
|
|
5250
|
+
isLoading ? /* @__PURE__ */ jsxs21("div", { className: "flex flex-col items-center gap-3 py-8", children: [
|
|
5251
|
+
/* @__PURE__ */ jsx23(
|
|
4914
5252
|
Loader28,
|
|
4915
5253
|
{
|
|
4916
5254
|
"aria-hidden": "true",
|
|
4917
5255
|
className: "h-6 w-6 animate-spin text-muted-foreground"
|
|
4918
5256
|
}
|
|
4919
5257
|
),
|
|
4920
|
-
/* @__PURE__ */
|
|
4921
|
-
] }) : options.length === 0 ? /* @__PURE__ */
|
|
4922
|
-
/* @__PURE__ */
|
|
4923
|
-
/* @__PURE__ */
|
|
4924
|
-
/* @__PURE__ */
|
|
4925
|
-
/* @__PURE__ */
|
|
4926
|
-
/* @__PURE__ */
|
|
4927
|
-
opt.description && /* @__PURE__ */
|
|
5258
|
+
/* @__PURE__ */ jsx23("p", { className: "text-sm text-muted-foreground", children: "Carregando op\xE7\xF5es..." })
|
|
5259
|
+
] }) : options.length === 0 ? /* @__PURE__ */ jsx23("div", { className: "rounded-lg border border-dashed p-6 text-center", children: /* @__PURE__ */ jsx23("p", { className: "text-sm text-muted-foreground", children: "Nenhuma op\xE7\xE3o dispon\xEDvel. A configura\xE7\xE3o padr\xE3o ser\xE1 usada." }) }) : /* @__PURE__ */ jsxs21("div", { className: "space-y-2", children: [
|
|
5260
|
+
/* @__PURE__ */ jsx23(Label8, { htmlFor: "integration-config-select", children: label }),
|
|
5261
|
+
/* @__PURE__ */ jsxs21(Select3, { value: selectedValue, onValueChange, children: [
|
|
5262
|
+
/* @__PURE__ */ jsx23(SelectTrigger3, { id: "integration-config-select", children: /* @__PURE__ */ jsx23(SelectValue3, { placeholder }) }),
|
|
5263
|
+
/* @__PURE__ */ jsx23(SelectContent3, { children: options.map((opt) => /* @__PURE__ */ jsxs21(SelectItem3, { value: opt.id, children: [
|
|
5264
|
+
/* @__PURE__ */ jsx23("span", { children: opt.label }),
|
|
5265
|
+
opt.description && /* @__PURE__ */ jsxs21("span", { className: "ml-2 text-xs text-muted-foreground", children: [
|
|
4928
5266
|
"(",
|
|
4929
5267
|
opt.description,
|
|
4930
5268
|
")"
|
|
@@ -4953,8 +5291,8 @@ function getDefaultPlaceholder(slug) {
|
|
|
4953
5291
|
|
|
4954
5292
|
// src/components/capabilities/wizard-steps/confirm-step.tsx
|
|
4955
5293
|
import { CheckCircle2 as CheckCircle22 } from "lucide-react";
|
|
4956
|
-
import { Label as
|
|
4957
|
-
import { jsx as
|
|
5294
|
+
import { Label as Label9 } from "@greatapps/greatauth-ui/ui";
|
|
5295
|
+
import { jsx as jsx24, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
4958
5296
|
function ConfirmStep({
|
|
4959
5297
|
integration,
|
|
4960
5298
|
oauthResult,
|
|
@@ -4962,22 +5300,22 @@ function ConfirmStep({
|
|
|
4962
5300
|
enableOnComplete,
|
|
4963
5301
|
onEnableChange
|
|
4964
5302
|
}) {
|
|
4965
|
-
return /* @__PURE__ */
|
|
4966
|
-
/* @__PURE__ */
|
|
4967
|
-
/* @__PURE__ */
|
|
4968
|
-
/* @__PURE__ */
|
|
5303
|
+
return /* @__PURE__ */ jsxs22("div", { className: "space-y-6", children: [
|
|
5304
|
+
/* @__PURE__ */ jsxs22("div", { className: "space-y-2", children: [
|
|
5305
|
+
/* @__PURE__ */ jsx24("h3", { className: "text-lg font-semibold", children: "Confirma\xE7\xE3o" }),
|
|
5306
|
+
/* @__PURE__ */ jsx24("p", { className: "text-sm text-muted-foreground", children: "Revise as configura\xE7\xF5es antes de concluir." })
|
|
4969
5307
|
] }),
|
|
4970
|
-
/* @__PURE__ */
|
|
4971
|
-
/* @__PURE__ */
|
|
4972
|
-
oauthResult?.email && /* @__PURE__ */
|
|
4973
|
-
selectedConfigOption && /* @__PURE__ */
|
|
5308
|
+
/* @__PURE__ */ jsxs22("div", { className: "space-y-3 rounded-lg border p-4", children: [
|
|
5309
|
+
/* @__PURE__ */ jsx24(SummaryRow, { label: "Integra\xE7\xE3o", value: integration.name }),
|
|
5310
|
+
oauthResult?.email && /* @__PURE__ */ jsx24(SummaryRow, { label: "Conta conectada", value: oauthResult.email }),
|
|
5311
|
+
selectedConfigOption && /* @__PURE__ */ jsx24(
|
|
4974
5312
|
SummaryRow,
|
|
4975
5313
|
{
|
|
4976
5314
|
label: getConfigLabel(integration.slug),
|
|
4977
5315
|
value: selectedConfigOption.label
|
|
4978
5316
|
}
|
|
4979
5317
|
),
|
|
4980
|
-
/* @__PURE__ */
|
|
5318
|
+
/* @__PURE__ */ jsx24(
|
|
4981
5319
|
SummaryRow,
|
|
4982
5320
|
{
|
|
4983
5321
|
label: "Tipo de autentica\xE7\xE3o",
|
|
@@ -4985,12 +5323,12 @@ function ConfirmStep({
|
|
|
4985
5323
|
}
|
|
4986
5324
|
)
|
|
4987
5325
|
] }),
|
|
4988
|
-
/* @__PURE__ */
|
|
4989
|
-
/* @__PURE__ */
|
|
4990
|
-
/* @__PURE__ */
|
|
4991
|
-
/* @__PURE__ */
|
|
5326
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-center justify-between rounded-lg border p-4", children: [
|
|
5327
|
+
/* @__PURE__ */ jsxs22("div", { className: "space-y-0.5", children: [
|
|
5328
|
+
/* @__PURE__ */ jsx24(Label9, { htmlFor: "enable-on-complete", className: "text-sm font-medium", children: "Ativar imediatamente" }),
|
|
5329
|
+
/* @__PURE__ */ jsx24("p", { className: "text-xs text-muted-foreground", children: "A integra\xE7\xE3o ficar\xE1 ativa assim que concluir o assistente." })
|
|
4992
5330
|
] }),
|
|
4993
|
-
/* @__PURE__ */
|
|
5331
|
+
/* @__PURE__ */ jsx24(
|
|
4994
5332
|
"button",
|
|
4995
5333
|
{
|
|
4996
5334
|
id: "enable-on-complete",
|
|
@@ -5004,7 +5342,7 @@ function ConfirmStep({
|
|
|
5004
5342
|
focus-visible:ring-ring focus-visible:ring-offset-2
|
|
5005
5343
|
${enableOnComplete ? "bg-primary" : "bg-muted"}
|
|
5006
5344
|
`,
|
|
5007
|
-
children: /* @__PURE__ */
|
|
5345
|
+
children: /* @__PURE__ */ jsx24(
|
|
5008
5346
|
"span",
|
|
5009
5347
|
{
|
|
5010
5348
|
"aria-hidden": "true",
|
|
@@ -5018,22 +5356,22 @@ function ConfirmStep({
|
|
|
5018
5356
|
}
|
|
5019
5357
|
)
|
|
5020
5358
|
] }),
|
|
5021
|
-
/* @__PURE__ */
|
|
5022
|
-
/* @__PURE__ */
|
|
5359
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-center gap-2 rounded-md bg-green-50 p-3 dark:bg-green-950/20", children: [
|
|
5360
|
+
/* @__PURE__ */ jsx24(
|
|
5023
5361
|
CheckCircle22,
|
|
5024
5362
|
{
|
|
5025
5363
|
"aria-hidden": "true",
|
|
5026
5364
|
className: "h-4 w-4 shrink-0 text-green-600"
|
|
5027
5365
|
}
|
|
5028
5366
|
),
|
|
5029
|
-
/* @__PURE__ */
|
|
5367
|
+
/* @__PURE__ */ jsx24("p", { className: "text-xs text-green-700 dark:text-green-400", children: 'Tudo pronto! Clique em "Concluir" para finalizar a configura\xE7\xE3o.' })
|
|
5030
5368
|
] })
|
|
5031
5369
|
] });
|
|
5032
5370
|
}
|
|
5033
5371
|
function SummaryRow({ label, value }) {
|
|
5034
|
-
return /* @__PURE__ */
|
|
5035
|
-
/* @__PURE__ */
|
|
5036
|
-
/* @__PURE__ */
|
|
5372
|
+
return /* @__PURE__ */ jsxs22("div", { className: "flex items-center justify-between text-sm", children: [
|
|
5373
|
+
/* @__PURE__ */ jsx24("span", { className: "text-muted-foreground", children: label }),
|
|
5374
|
+
/* @__PURE__ */ jsx24("span", { className: "font-medium", children: value })
|
|
5037
5375
|
] });
|
|
5038
5376
|
}
|
|
5039
5377
|
function getConfigLabel(slug) {
|
|
@@ -5046,7 +5384,7 @@ function getConfigLabel(slug) {
|
|
|
5046
5384
|
}
|
|
5047
5385
|
|
|
5048
5386
|
// src/components/capabilities/integration-wizard.tsx
|
|
5049
|
-
import { jsx as
|
|
5387
|
+
import { jsx as jsx25, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
5050
5388
|
var STEPS = ["info", "credentials", "config", "confirm"];
|
|
5051
5389
|
var STEP_LABELS = {
|
|
5052
5390
|
info: "Informa\xE7\xE3o",
|
|
@@ -5068,18 +5406,18 @@ function IntegrationWizard({
|
|
|
5068
5406
|
existingConfigValue
|
|
5069
5407
|
}) {
|
|
5070
5408
|
const isReconnect = !!existingCredentialId;
|
|
5071
|
-
const [currentStep, setCurrentStep] =
|
|
5409
|
+
const [currentStep, setCurrentStep] = useState18("info");
|
|
5072
5410
|
const currentIndex = STEPS.indexOf(currentStep);
|
|
5073
|
-
const [oauthStatus, setOauthStatus] =
|
|
5074
|
-
const [oauthResult, setOauthResult] =
|
|
5075
|
-
const popupRef =
|
|
5076
|
-
const popupPollRef =
|
|
5077
|
-
const [apiKey, setApiKey] =
|
|
5078
|
-
const [configOptions, setConfigOptions] =
|
|
5079
|
-
const [configLoading, setConfigLoading] =
|
|
5080
|
-
const [selectedConfigValue, setSelectedConfigValue] =
|
|
5081
|
-
const [enableOnComplete, setEnableOnComplete] =
|
|
5082
|
-
const [isSubmitting, setIsSubmitting] =
|
|
5411
|
+
const [oauthStatus, setOauthStatus] = useState18("idle");
|
|
5412
|
+
const [oauthResult, setOauthResult] = useState18(null);
|
|
5413
|
+
const popupRef = useRef3(null);
|
|
5414
|
+
const popupPollRef = useRef3(null);
|
|
5415
|
+
const [apiKey, setApiKey] = useState18("");
|
|
5416
|
+
const [configOptions, setConfigOptions] = useState18([]);
|
|
5417
|
+
const [configLoading, setConfigLoading] = useState18(false);
|
|
5418
|
+
const [selectedConfigValue, setSelectedConfigValue] = useState18("");
|
|
5419
|
+
const [enableOnComplete, setEnableOnComplete] = useState18(true);
|
|
5420
|
+
const [isSubmitting, setIsSubmitting] = useState18(false);
|
|
5083
5421
|
useEffect6(() => {
|
|
5084
5422
|
return () => {
|
|
5085
5423
|
if (popupPollRef.current) {
|
|
@@ -5108,7 +5446,7 @@ function IntegrationWizard({
|
|
|
5108
5446
|
}
|
|
5109
5447
|
}
|
|
5110
5448
|
}, [open]);
|
|
5111
|
-
const handleOAuthMessage =
|
|
5449
|
+
const handleOAuthMessage = useCallback7(
|
|
5112
5450
|
(event) => {
|
|
5113
5451
|
try {
|
|
5114
5452
|
if (event.origin !== new URL(gagentsApiUrl).origin) return;
|
|
@@ -5248,11 +5586,11 @@ function IntegrationWizard({
|
|
|
5248
5586
|
setIsSubmitting(true);
|
|
5249
5587
|
try {
|
|
5250
5588
|
onComplete();
|
|
5251
|
-
|
|
5589
|
+
toast13.success(
|
|
5252
5590
|
`${integration.name} ${isReconnect ? "reconectado" : "configurado"} com sucesso!`
|
|
5253
5591
|
);
|
|
5254
5592
|
} catch {
|
|
5255
|
-
|
|
5593
|
+
toast13.error("Erro ao finalizar configura\xE7\xE3o");
|
|
5256
5594
|
} finally {
|
|
5257
5595
|
setIsSubmitting(false);
|
|
5258
5596
|
}
|
|
@@ -5260,18 +5598,18 @@ function IntegrationWizard({
|
|
|
5260
5598
|
const selectedConfigOption = configOptions.find((o) => o.id === selectedConfigValue) || null;
|
|
5261
5599
|
const isLastStep = currentStep === "confirm";
|
|
5262
5600
|
const effectiveSteps = meta.hasConfigStep ? STEPS : STEPS.filter((s) => s !== "config");
|
|
5263
|
-
return /* @__PURE__ */
|
|
5264
|
-
/* @__PURE__ */
|
|
5265
|
-
/* @__PURE__ */
|
|
5266
|
-
/* @__PURE__ */
|
|
5267
|
-
currentStep === "info" && /* @__PURE__ */
|
|
5601
|
+
return /* @__PURE__ */ jsx25(Dialog7, { open, onOpenChange, children: /* @__PURE__ */ jsxs23(DialogContent7, { className: "sm:max-w-lg", children: [
|
|
5602
|
+
/* @__PURE__ */ jsx25(DialogHeader7, { children: /* @__PURE__ */ jsx25(DialogTitle7, { children: integration.name }) }),
|
|
5603
|
+
/* @__PURE__ */ jsx25(StepIndicator, { steps: effectiveSteps, currentStep }),
|
|
5604
|
+
/* @__PURE__ */ jsxs23("div", { className: "min-h-[280px] py-2", children: [
|
|
5605
|
+
currentStep === "info" && /* @__PURE__ */ jsx25(
|
|
5268
5606
|
InfoStep,
|
|
5269
5607
|
{
|
|
5270
5608
|
integration,
|
|
5271
5609
|
meta
|
|
5272
5610
|
}
|
|
5273
5611
|
),
|
|
5274
|
-
currentStep === "credentials" && /* @__PURE__ */
|
|
5612
|
+
currentStep === "credentials" && /* @__PURE__ */ jsx25(
|
|
5275
5613
|
CredentialsStep,
|
|
5276
5614
|
{
|
|
5277
5615
|
integration,
|
|
@@ -5284,7 +5622,7 @@ function IntegrationWizard({
|
|
|
5284
5622
|
isReconnect
|
|
5285
5623
|
}
|
|
5286
5624
|
),
|
|
5287
|
-
currentStep === "config" && /* @__PURE__ */
|
|
5625
|
+
currentStep === "config" && /* @__PURE__ */ jsx25(
|
|
5288
5626
|
ConfigStep,
|
|
5289
5627
|
{
|
|
5290
5628
|
integration,
|
|
@@ -5294,7 +5632,7 @@ function IntegrationWizard({
|
|
|
5294
5632
|
onValueChange: setSelectedConfigValue
|
|
5295
5633
|
}
|
|
5296
5634
|
),
|
|
5297
|
-
currentStep === "confirm" && /* @__PURE__ */
|
|
5635
|
+
currentStep === "confirm" && /* @__PURE__ */ jsx25(
|
|
5298
5636
|
ConfirmStep,
|
|
5299
5637
|
{
|
|
5300
5638
|
integration,
|
|
@@ -5305,48 +5643,48 @@ function IntegrationWizard({
|
|
|
5305
5643
|
}
|
|
5306
5644
|
)
|
|
5307
5645
|
] }),
|
|
5308
|
-
/* @__PURE__ */
|
|
5309
|
-
/* @__PURE__ */
|
|
5310
|
-
|
|
5646
|
+
/* @__PURE__ */ jsxs23(DialogFooter6, { className: "flex-row justify-between sm:justify-between", children: [
|
|
5647
|
+
/* @__PURE__ */ jsx25("div", { children: currentStep === "info" ? /* @__PURE__ */ jsx25(
|
|
5648
|
+
Button17,
|
|
5311
5649
|
{
|
|
5312
5650
|
type: "button",
|
|
5313
5651
|
variant: "outline",
|
|
5314
5652
|
onClick: () => onOpenChange(false),
|
|
5315
5653
|
children: "Cancelar"
|
|
5316
5654
|
}
|
|
5317
|
-
) : /* @__PURE__ */
|
|
5318
|
-
|
|
5655
|
+
) : /* @__PURE__ */ jsxs23(
|
|
5656
|
+
Button17,
|
|
5319
5657
|
{
|
|
5320
5658
|
type: "button",
|
|
5321
5659
|
variant: "outline",
|
|
5322
5660
|
onClick: goPrev,
|
|
5323
5661
|
className: "gap-1",
|
|
5324
5662
|
children: [
|
|
5325
|
-
/* @__PURE__ */
|
|
5663
|
+
/* @__PURE__ */ jsx25(ChevronLeft, { "aria-hidden": "true", className: "h-4 w-4" }),
|
|
5326
5664
|
"Voltar"
|
|
5327
5665
|
]
|
|
5328
5666
|
}
|
|
5329
5667
|
) }),
|
|
5330
|
-
/* @__PURE__ */
|
|
5331
|
-
|
|
5668
|
+
/* @__PURE__ */ jsx25("div", { children: isLastStep ? /* @__PURE__ */ jsxs23(
|
|
5669
|
+
Button17,
|
|
5332
5670
|
{
|
|
5333
5671
|
type: "button",
|
|
5334
5672
|
onClick: handleComplete,
|
|
5335
5673
|
disabled: isSubmitting,
|
|
5336
5674
|
className: "gap-1",
|
|
5337
5675
|
children: [
|
|
5338
|
-
isSubmitting ? /* @__PURE__ */
|
|
5676
|
+
isSubmitting ? /* @__PURE__ */ jsx25(
|
|
5339
5677
|
Loader29,
|
|
5340
5678
|
{
|
|
5341
5679
|
"aria-hidden": "true",
|
|
5342
5680
|
className: "h-4 w-4 animate-spin"
|
|
5343
5681
|
}
|
|
5344
|
-
) : /* @__PURE__ */
|
|
5682
|
+
) : /* @__PURE__ */ jsx25(Check2, { "aria-hidden": "true", className: "h-4 w-4" }),
|
|
5345
5683
|
"Concluir"
|
|
5346
5684
|
]
|
|
5347
5685
|
}
|
|
5348
|
-
) : /* @__PURE__ */
|
|
5349
|
-
|
|
5686
|
+
) : /* @__PURE__ */ jsxs23(
|
|
5687
|
+
Button17,
|
|
5350
5688
|
{
|
|
5351
5689
|
type: "button",
|
|
5352
5690
|
onClick: goNext,
|
|
@@ -5354,7 +5692,7 @@ function IntegrationWizard({
|
|
|
5354
5692
|
className: "gap-1",
|
|
5355
5693
|
children: [
|
|
5356
5694
|
"Continuar",
|
|
5357
|
-
/* @__PURE__ */
|
|
5695
|
+
/* @__PURE__ */ jsx25(ChevronRight, { "aria-hidden": "true", className: "h-4 w-4" })
|
|
5358
5696
|
]
|
|
5359
5697
|
}
|
|
5360
5698
|
) })
|
|
@@ -5366,7 +5704,7 @@ function StepIndicator({
|
|
|
5366
5704
|
currentStep
|
|
5367
5705
|
}) {
|
|
5368
5706
|
const currentIndex = steps.indexOf(currentStep);
|
|
5369
|
-
return /* @__PURE__ */
|
|
5707
|
+
return /* @__PURE__ */ jsx25(
|
|
5370
5708
|
"div",
|
|
5371
5709
|
{
|
|
5372
5710
|
className: "flex items-center justify-center gap-1 py-2",
|
|
@@ -5375,8 +5713,8 @@ function StepIndicator({
|
|
|
5375
5713
|
children: steps.map((step, i) => {
|
|
5376
5714
|
const isCompleted = i < currentIndex;
|
|
5377
5715
|
const isCurrent = step === currentStep;
|
|
5378
|
-
return /* @__PURE__ */
|
|
5379
|
-
/* @__PURE__ */
|
|
5716
|
+
return /* @__PURE__ */ jsxs23("div", { className: "flex items-center", role: "listitem", children: [
|
|
5717
|
+
/* @__PURE__ */ jsx25(
|
|
5380
5718
|
"div",
|
|
5381
5719
|
{
|
|
5382
5720
|
className: `
|
|
@@ -5386,10 +5724,10 @@ function StepIndicator({
|
|
|
5386
5724
|
`,
|
|
5387
5725
|
"aria-current": isCurrent ? "step" : void 0,
|
|
5388
5726
|
"aria-label": `${STEP_LABELS[step]}${isCompleted ? " (conclu\xEDdo)" : isCurrent ? " (atual)" : ""}`,
|
|
5389
|
-
children: isCompleted ? /* @__PURE__ */
|
|
5727
|
+
children: isCompleted ? /* @__PURE__ */ jsx25(Check2, { "aria-hidden": "true", className: "h-3.5 w-3.5" }) : i + 1
|
|
5390
5728
|
}
|
|
5391
5729
|
),
|
|
5392
|
-
/* @__PURE__ */
|
|
5730
|
+
/* @__PURE__ */ jsx25(
|
|
5393
5731
|
"span",
|
|
5394
5732
|
{
|
|
5395
5733
|
className: `
|
|
@@ -5399,7 +5737,7 @@ function StepIndicator({
|
|
|
5399
5737
|
children: STEP_LABELS[step]
|
|
5400
5738
|
}
|
|
5401
5739
|
),
|
|
5402
|
-
i < steps.length - 1 && /* @__PURE__ */
|
|
5740
|
+
i < steps.length - 1 && /* @__PURE__ */ jsx25(
|
|
5403
5741
|
"div",
|
|
5404
5742
|
{
|
|
5405
5743
|
className: `
|
|
@@ -5415,30 +5753,30 @@ function StepIndicator({
|
|
|
5415
5753
|
}
|
|
5416
5754
|
|
|
5417
5755
|
// src/pages/agents-page.tsx
|
|
5418
|
-
import { useState as
|
|
5419
|
-
import { Button as
|
|
5420
|
-
import { Plus as
|
|
5421
|
-
import { jsx as
|
|
5756
|
+
import { useState as useState19 } from "react";
|
|
5757
|
+
import { Button as Button18 } from "@greatapps/greatauth-ui/ui";
|
|
5758
|
+
import { Plus as Plus5 } from "lucide-react";
|
|
5759
|
+
import { jsx as jsx26, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
5422
5760
|
function AgentsPage({
|
|
5423
5761
|
config,
|
|
5424
5762
|
onNavigateToAgent,
|
|
5425
5763
|
title = "Agentes AI",
|
|
5426
5764
|
subtitle = "Gerencie seus agentes de atendimento inteligente"
|
|
5427
5765
|
}) {
|
|
5428
|
-
const [createOpen, setCreateOpen] =
|
|
5429
|
-
return /* @__PURE__ */
|
|
5430
|
-
/* @__PURE__ */
|
|
5431
|
-
/* @__PURE__ */
|
|
5432
|
-
/* @__PURE__ */
|
|
5433
|
-
/* @__PURE__ */
|
|
5766
|
+
const [createOpen, setCreateOpen] = useState19(false);
|
|
5767
|
+
return /* @__PURE__ */ jsxs24("div", { className: "flex flex-col gap-4 p-4 md:p-6", children: [
|
|
5768
|
+
/* @__PURE__ */ jsxs24("div", { className: "flex items-center justify-between", children: [
|
|
5769
|
+
/* @__PURE__ */ jsxs24("div", { children: [
|
|
5770
|
+
/* @__PURE__ */ jsx26("h1", { className: "text-xl font-semibold", children: title }),
|
|
5771
|
+
/* @__PURE__ */ jsx26("p", { className: "text-sm text-muted-foreground", children: subtitle })
|
|
5434
5772
|
] }),
|
|
5435
|
-
/* @__PURE__ */
|
|
5436
|
-
/* @__PURE__ */
|
|
5773
|
+
/* @__PURE__ */ jsxs24(Button18, { onClick: () => setCreateOpen(true), size: "sm", children: [
|
|
5774
|
+
/* @__PURE__ */ jsx26(Plus5, { className: "mr-2 h-4 w-4" }),
|
|
5437
5775
|
"Novo Agente"
|
|
5438
5776
|
] })
|
|
5439
5777
|
] }),
|
|
5440
|
-
/* @__PURE__ */
|
|
5441
|
-
/* @__PURE__ */
|
|
5778
|
+
/* @__PURE__ */ jsx26(AgentsTable, { config, onNavigateToAgent }),
|
|
5779
|
+
/* @__PURE__ */ jsx26(
|
|
5442
5780
|
AgentFormDialog,
|
|
5443
5781
|
{
|
|
5444
5782
|
config,
|
|
@@ -5450,11 +5788,11 @@ function AgentsPage({
|
|
|
5450
5788
|
}
|
|
5451
5789
|
|
|
5452
5790
|
// src/pages/agent-detail-page.tsx
|
|
5453
|
-
import { useState as
|
|
5454
|
-
import { Badge as Badge10, Button as
|
|
5791
|
+
import { useState as useState20 } from "react";
|
|
5792
|
+
import { Badge as Badge10, Button as Button19, Skeleton as Skeleton7 } from "@greatapps/greatauth-ui/ui";
|
|
5455
5793
|
import { EntityAvatar as EntityAvatar2 } from "@greatapps/greatauth-ui";
|
|
5456
5794
|
import { ArrowLeft, Pencil as Pencil6 } from "lucide-react";
|
|
5457
|
-
import { jsx as
|
|
5795
|
+
import { jsx as jsx27, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
5458
5796
|
function AgentDetailPage({
|
|
5459
5797
|
config,
|
|
5460
5798
|
agentId,
|
|
@@ -5462,42 +5800,42 @@ function AgentDetailPage({
|
|
|
5462
5800
|
renderChatLink
|
|
5463
5801
|
}) {
|
|
5464
5802
|
const { data: agent, isLoading } = useAgent(config, agentId);
|
|
5465
|
-
const [editOpen, setEditOpen] =
|
|
5803
|
+
const [editOpen, setEditOpen] = useState20(false);
|
|
5466
5804
|
if (isLoading) {
|
|
5467
|
-
return /* @__PURE__ */
|
|
5468
|
-
/* @__PURE__ */
|
|
5469
|
-
/* @__PURE__ */
|
|
5470
|
-
/* @__PURE__ */
|
|
5471
|
-
/* @__PURE__ */
|
|
5805
|
+
return /* @__PURE__ */ jsxs25("div", { className: "flex flex-col gap-4 p-4", children: [
|
|
5806
|
+
/* @__PURE__ */ jsx27(Skeleton7, { className: "h-4 w-32" }),
|
|
5807
|
+
/* @__PURE__ */ jsx27(Skeleton7, { className: "h-8 w-48" }),
|
|
5808
|
+
/* @__PURE__ */ jsx27(Skeleton7, { className: "h-10 w-full" }),
|
|
5809
|
+
/* @__PURE__ */ jsx27(Skeleton7, { className: "h-64 w-full" })
|
|
5472
5810
|
] });
|
|
5473
5811
|
}
|
|
5474
5812
|
if (!agent) {
|
|
5475
|
-
return /* @__PURE__ */
|
|
5476
|
-
/* @__PURE__ */
|
|
5477
|
-
onBack && /* @__PURE__ */
|
|
5478
|
-
/* @__PURE__ */
|
|
5813
|
+
return /* @__PURE__ */ jsxs25("div", { className: "flex flex-col items-center justify-center gap-2 p-8", children: [
|
|
5814
|
+
/* @__PURE__ */ jsx27("p", { className: "text-muted-foreground", children: "Agente n\xE3o encontrado" }),
|
|
5815
|
+
onBack && /* @__PURE__ */ jsxs25(Button19, { variant: "ghost", size: "sm", onClick: onBack, children: [
|
|
5816
|
+
/* @__PURE__ */ jsx27(ArrowLeft, { className: "mr-2 h-4 w-4" }),
|
|
5479
5817
|
"Voltar para agentes"
|
|
5480
5818
|
] })
|
|
5481
5819
|
] });
|
|
5482
5820
|
}
|
|
5483
|
-
return /* @__PURE__ */
|
|
5484
|
-
/* @__PURE__ */
|
|
5485
|
-
/* @__PURE__ */
|
|
5486
|
-
onBack && /* @__PURE__ */
|
|
5487
|
-
|
|
5821
|
+
return /* @__PURE__ */ jsxs25("div", { className: "flex flex-col gap-6 p-4 md:p-6", children: [
|
|
5822
|
+
/* @__PURE__ */ jsx27("div", { className: "rounded-lg border p-4 md:p-6", children: /* @__PURE__ */ jsxs25("div", { className: "flex flex-col gap-4 md:flex-row md:items-start md:gap-6", children: [
|
|
5823
|
+
/* @__PURE__ */ jsxs25("div", { className: "flex items-start gap-3 flex-1", children: [
|
|
5824
|
+
onBack && /* @__PURE__ */ jsx27(
|
|
5825
|
+
Button19,
|
|
5488
5826
|
{
|
|
5489
5827
|
variant: "ghost",
|
|
5490
5828
|
size: "icon",
|
|
5491
5829
|
"aria-label": "Voltar",
|
|
5492
5830
|
className: "shrink-0 mt-1",
|
|
5493
5831
|
onClick: onBack,
|
|
5494
|
-
children: /* @__PURE__ */
|
|
5832
|
+
children: /* @__PURE__ */ jsx27(ArrowLeft, { className: "h-4 w-4" })
|
|
5495
5833
|
}
|
|
5496
5834
|
),
|
|
5497
|
-
/* @__PURE__ */
|
|
5498
|
-
/* @__PURE__ */
|
|
5499
|
-
/* @__PURE__ */
|
|
5500
|
-
/* @__PURE__ */
|
|
5835
|
+
/* @__PURE__ */ jsx27(EntityAvatar2, { photo: agent.photo, name: agent.title, size: "xl" }),
|
|
5836
|
+
/* @__PURE__ */ jsx27("div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ jsxs25("div", { className: "flex items-center gap-2 flex-wrap", children: [
|
|
5837
|
+
/* @__PURE__ */ jsx27("h1", { className: "text-xl font-semibold", children: agent.title }),
|
|
5838
|
+
/* @__PURE__ */ jsx27(
|
|
5501
5839
|
Badge10,
|
|
5502
5840
|
{
|
|
5503
5841
|
variant: agent.active ? "default" : "destructive",
|
|
@@ -5507,21 +5845,21 @@ function AgentDetailPage({
|
|
|
5507
5845
|
)
|
|
5508
5846
|
] }) })
|
|
5509
5847
|
] }),
|
|
5510
|
-
/* @__PURE__ */
|
|
5511
|
-
|
|
5848
|
+
/* @__PURE__ */ jsxs25(
|
|
5849
|
+
Button19,
|
|
5512
5850
|
{
|
|
5513
5851
|
variant: "outline",
|
|
5514
5852
|
size: "sm",
|
|
5515
5853
|
className: "shrink-0 self-start",
|
|
5516
5854
|
onClick: () => setEditOpen(true),
|
|
5517
5855
|
children: [
|
|
5518
|
-
/* @__PURE__ */
|
|
5856
|
+
/* @__PURE__ */ jsx27(Pencil6, { className: "mr-2 h-4 w-4" }),
|
|
5519
5857
|
"Editar"
|
|
5520
5858
|
]
|
|
5521
5859
|
}
|
|
5522
5860
|
)
|
|
5523
5861
|
] }) }),
|
|
5524
|
-
/* @__PURE__ */
|
|
5862
|
+
/* @__PURE__ */ jsx27(
|
|
5525
5863
|
AgentTabs,
|
|
5526
5864
|
{
|
|
5527
5865
|
agent,
|
|
@@ -5529,7 +5867,7 @@ function AgentDetailPage({
|
|
|
5529
5867
|
renderChatLink
|
|
5530
5868
|
}
|
|
5531
5869
|
),
|
|
5532
|
-
editOpen && /* @__PURE__ */
|
|
5870
|
+
editOpen && /* @__PURE__ */ jsx27(
|
|
5533
5871
|
AgentEditForm,
|
|
5534
5872
|
{
|
|
5535
5873
|
agent,
|
|
@@ -5550,35 +5888,35 @@ import {
|
|
|
5550
5888
|
TabsContent as TabsContent2
|
|
5551
5889
|
} from "@greatapps/greatauth-ui/ui";
|
|
5552
5890
|
import { Blocks as Blocks2, Plug as Plug4, Settings as Settings4 } from "lucide-react";
|
|
5553
|
-
import { jsx as
|
|
5891
|
+
import { jsx as jsx28, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
5554
5892
|
function AgentCapabilitiesPage({
|
|
5555
5893
|
config,
|
|
5556
5894
|
agentId,
|
|
5557
5895
|
gagentsApiUrl
|
|
5558
5896
|
}) {
|
|
5559
|
-
return /* @__PURE__ */
|
|
5560
|
-
/* @__PURE__ */
|
|
5561
|
-
/* @__PURE__ */
|
|
5562
|
-
/* @__PURE__ */
|
|
5897
|
+
return /* @__PURE__ */ jsxs26("div", { className: "space-y-4", children: [
|
|
5898
|
+
/* @__PURE__ */ jsxs26("div", { children: [
|
|
5899
|
+
/* @__PURE__ */ jsx28("h2", { className: "text-lg font-semibold", children: "Capacidades e Integra\xE7\xF5es" }),
|
|
5900
|
+
/* @__PURE__ */ jsx28("p", { className: "text-sm text-muted-foreground", children: "Configure o que este agente pode fazer e quais integra\xE7\xF5es ele utiliza." })
|
|
5563
5901
|
] }),
|
|
5564
|
-
/* @__PURE__ */
|
|
5565
|
-
/* @__PURE__ */
|
|
5566
|
-
/* @__PURE__ */
|
|
5567
|
-
/* @__PURE__ */
|
|
5902
|
+
/* @__PURE__ */ jsxs26(Tabs2, { defaultValue: "capacidades", children: [
|
|
5903
|
+
/* @__PURE__ */ jsxs26(TabsList2, { children: [
|
|
5904
|
+
/* @__PURE__ */ jsxs26(TabsTrigger2, { value: "capacidades", className: "flex items-center gap-1.5", children: [
|
|
5905
|
+
/* @__PURE__ */ jsx28(Blocks2, { "aria-hidden": "true", className: "h-3.5 w-3.5" }),
|
|
5568
5906
|
"Capacidades"
|
|
5569
5907
|
] }),
|
|
5570
|
-
/* @__PURE__ */
|
|
5571
|
-
/* @__PURE__ */
|
|
5908
|
+
/* @__PURE__ */ jsxs26(TabsTrigger2, { value: "integracoes", className: "flex items-center gap-1.5", children: [
|
|
5909
|
+
/* @__PURE__ */ jsx28(Plug4, { "aria-hidden": "true", className: "h-3.5 w-3.5" }),
|
|
5572
5910
|
"Integra\xE7\xF5es"
|
|
5573
5911
|
] }),
|
|
5574
|
-
/* @__PURE__ */
|
|
5575
|
-
/* @__PURE__ */
|
|
5912
|
+
/* @__PURE__ */ jsxs26(TabsTrigger2, { value: "avancado", className: "flex items-center gap-1.5", children: [
|
|
5913
|
+
/* @__PURE__ */ jsx28(Settings4, { "aria-hidden": "true", className: "h-3.5 w-3.5" }),
|
|
5576
5914
|
"Avan\xE7ado"
|
|
5577
5915
|
] })
|
|
5578
5916
|
] }),
|
|
5579
|
-
/* @__PURE__ */
|
|
5580
|
-
/* @__PURE__ */
|
|
5581
|
-
/* @__PURE__ */
|
|
5917
|
+
/* @__PURE__ */ jsx28(TabsContent2, { value: "capacidades", className: "mt-4", children: /* @__PURE__ */ jsx28(CapabilitiesTab, { config, agentId }) }),
|
|
5918
|
+
/* @__PURE__ */ jsx28(TabsContent2, { value: "integracoes", className: "mt-4", children: /* @__PURE__ */ jsx28(IntegrationsTab, { config, agentId }) }),
|
|
5919
|
+
/* @__PURE__ */ jsx28(TabsContent2, { value: "avancado", className: "mt-4", children: /* @__PURE__ */ jsx28(
|
|
5582
5920
|
AdvancedTab,
|
|
5583
5921
|
{
|
|
5584
5922
|
config,
|
|
@@ -5591,30 +5929,30 @@ function AgentCapabilitiesPage({
|
|
|
5591
5929
|
}
|
|
5592
5930
|
|
|
5593
5931
|
// src/pages/tools-page.tsx
|
|
5594
|
-
import { useState as
|
|
5595
|
-
import { Button as
|
|
5596
|
-
import { Plus as
|
|
5597
|
-
import { jsx as
|
|
5932
|
+
import { useState as useState21 } from "react";
|
|
5933
|
+
import { Button as Button20 } from "@greatapps/greatauth-ui/ui";
|
|
5934
|
+
import { Plus as Plus6 } from "lucide-react";
|
|
5935
|
+
import { jsx as jsx29, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
5598
5936
|
function ToolsPage({
|
|
5599
5937
|
config,
|
|
5600
5938
|
title = "Ferramentas",
|
|
5601
5939
|
subtitle = "Gerencie as ferramentas dispon\xEDveis para seus agentes"
|
|
5602
5940
|
}) {
|
|
5603
|
-
const [createOpen, setCreateOpen] =
|
|
5604
|
-
const [editTool, setEditTool] =
|
|
5605
|
-
return /* @__PURE__ */
|
|
5606
|
-
/* @__PURE__ */
|
|
5607
|
-
/* @__PURE__ */
|
|
5608
|
-
/* @__PURE__ */
|
|
5609
|
-
/* @__PURE__ */
|
|
5941
|
+
const [createOpen, setCreateOpen] = useState21(false);
|
|
5942
|
+
const [editTool, setEditTool] = useState21(void 0);
|
|
5943
|
+
return /* @__PURE__ */ jsxs27("div", { className: "flex flex-col gap-4 p-4 md:p-6", children: [
|
|
5944
|
+
/* @__PURE__ */ jsxs27("div", { className: "flex items-center justify-between", children: [
|
|
5945
|
+
/* @__PURE__ */ jsxs27("div", { children: [
|
|
5946
|
+
/* @__PURE__ */ jsx29("h1", { className: "text-xl font-semibold", children: title }),
|
|
5947
|
+
/* @__PURE__ */ jsx29("p", { className: "text-sm text-muted-foreground", children: subtitle })
|
|
5610
5948
|
] }),
|
|
5611
|
-
/* @__PURE__ */
|
|
5612
|
-
/* @__PURE__ */
|
|
5949
|
+
/* @__PURE__ */ jsxs27(Button20, { onClick: () => setCreateOpen(true), size: "sm", children: [
|
|
5950
|
+
/* @__PURE__ */ jsx29(Plus6, { className: "mr-2 h-4 w-4" }),
|
|
5613
5951
|
"Nova Ferramenta"
|
|
5614
5952
|
] })
|
|
5615
5953
|
] }),
|
|
5616
|
-
/* @__PURE__ */
|
|
5617
|
-
/* @__PURE__ */
|
|
5954
|
+
/* @__PURE__ */ jsx29(ToolsTable, { config, onEdit: (tool) => setEditTool(tool) }),
|
|
5955
|
+
/* @__PURE__ */ jsx29(
|
|
5618
5956
|
ToolFormDialog,
|
|
5619
5957
|
{
|
|
5620
5958
|
config,
|
|
@@ -5622,7 +5960,7 @@ function ToolsPage({
|
|
|
5622
5960
|
onOpenChange: setCreateOpen
|
|
5623
5961
|
}
|
|
5624
5962
|
),
|
|
5625
|
-
/* @__PURE__ */
|
|
5963
|
+
/* @__PURE__ */ jsx29(
|
|
5626
5964
|
ToolFormDialog,
|
|
5627
5965
|
{
|
|
5628
5966
|
config,
|
|
@@ -5635,7 +5973,7 @@ function ToolsPage({
|
|
|
5635
5973
|
}
|
|
5636
5974
|
|
|
5637
5975
|
// src/pages/credentials-page.tsx
|
|
5638
|
-
import { jsx as
|
|
5976
|
+
import { jsx as jsx30, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
5639
5977
|
function CredentialsPage({
|
|
5640
5978
|
config,
|
|
5641
5979
|
gagentsApiUrl,
|
|
@@ -5644,12 +5982,12 @@ function CredentialsPage({
|
|
|
5644
5982
|
}) {
|
|
5645
5983
|
const { data: credentialsData, isLoading: credentialsLoading } = useToolCredentials(config);
|
|
5646
5984
|
const credentials = credentialsData?.data || [];
|
|
5647
|
-
return /* @__PURE__ */
|
|
5648
|
-
/* @__PURE__ */
|
|
5649
|
-
/* @__PURE__ */
|
|
5650
|
-
/* @__PURE__ */
|
|
5985
|
+
return /* @__PURE__ */ jsxs28("div", { className: "flex flex-col gap-4 p-4 md:p-6", children: [
|
|
5986
|
+
/* @__PURE__ */ jsx30("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsxs28("div", { children: [
|
|
5987
|
+
/* @__PURE__ */ jsx30("h1", { className: "text-xl font-semibold", children: title }),
|
|
5988
|
+
/* @__PURE__ */ jsx30("p", { className: "text-sm text-muted-foreground", children: subtitle })
|
|
5651
5989
|
] }) }),
|
|
5652
|
-
/* @__PURE__ */
|
|
5990
|
+
/* @__PURE__ */ jsx30(
|
|
5653
5991
|
ToolCredentialsForm,
|
|
5654
5992
|
{
|
|
5655
5993
|
config,
|
|
@@ -5662,10 +6000,10 @@ function CredentialsPage({
|
|
|
5662
6000
|
}
|
|
5663
6001
|
|
|
5664
6002
|
// src/pages/integrations-management-page.tsx
|
|
5665
|
-
import { useCallback as
|
|
6003
|
+
import { useCallback as useCallback8, useState as useState22 } from "react";
|
|
5666
6004
|
import { useQueryClient as useQueryClient7 } from "@tanstack/react-query";
|
|
5667
6005
|
import { Plug as Plug5, Loader2 as Loader210 } from "lucide-react";
|
|
5668
|
-
import { jsx as
|
|
6006
|
+
import { jsx as jsx31, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
5669
6007
|
function IntegrationsManagementPage({
|
|
5670
6008
|
config,
|
|
5671
6009
|
gagentsApiUrl,
|
|
@@ -5677,36 +6015,36 @@ function IntegrationsManagementPage({
|
|
|
5677
6015
|
}) {
|
|
5678
6016
|
const queryClient = useQueryClient7();
|
|
5679
6017
|
const { cards, isLoading: cardsLoading } = useIntegrationState(config, null);
|
|
5680
|
-
const [wizardOpen, setWizardOpen] =
|
|
5681
|
-
const [activeCard, setActiveCard] =
|
|
6018
|
+
const [wizardOpen, setWizardOpen] = useState22(false);
|
|
6019
|
+
const [activeCard, setActiveCard] = useState22(null);
|
|
5682
6020
|
const deleteCredential = useDeleteToolCredential(config);
|
|
5683
6021
|
const updateCredential = useUpdateToolCredential(config);
|
|
5684
|
-
const handleConnect =
|
|
6022
|
+
const handleConnect = useCallback8((card) => {
|
|
5685
6023
|
setActiveCard(card);
|
|
5686
6024
|
setWizardOpen(true);
|
|
5687
6025
|
}, []);
|
|
5688
|
-
const handleReconnect =
|
|
6026
|
+
const handleReconnect = useCallback8((card) => {
|
|
5689
6027
|
setActiveCard(card);
|
|
5690
6028
|
setWizardOpen(true);
|
|
5691
6029
|
}, []);
|
|
5692
|
-
const handleDisconnect =
|
|
6030
|
+
const handleDisconnect = useCallback8((card) => {
|
|
5693
6031
|
if (!card.credentialId) return;
|
|
5694
6032
|
updateCredential.mutate({
|
|
5695
6033
|
id: card.credentialId,
|
|
5696
6034
|
body: { status: "inactive" }
|
|
5697
6035
|
});
|
|
5698
6036
|
}, [updateCredential]);
|
|
5699
|
-
const handleDelete =
|
|
6037
|
+
const handleDelete = useCallback8((card) => {
|
|
5700
6038
|
if (!card.credentialId) return;
|
|
5701
6039
|
deleteCredential.mutate(card.credentialId);
|
|
5702
6040
|
}, [deleteCredential]);
|
|
5703
|
-
const handleWizardClose =
|
|
6041
|
+
const handleWizardClose = useCallback8((open) => {
|
|
5704
6042
|
if (!open) {
|
|
5705
6043
|
setActiveCard(null);
|
|
5706
6044
|
}
|
|
5707
6045
|
setWizardOpen(open);
|
|
5708
6046
|
}, []);
|
|
5709
|
-
const handleWizardComplete =
|
|
6047
|
+
const handleWizardComplete = useCallback8(() => {
|
|
5710
6048
|
queryClient.invalidateQueries({ queryKey: ["greatagents", "tool-credentials"] });
|
|
5711
6049
|
queryClient.invalidateQueries({ queryKey: ["greatagents", "tools"] });
|
|
5712
6050
|
queryClient.invalidateQueries({ queryKey: ["greatagents", "agent-tools"] });
|
|
@@ -5727,18 +6065,18 @@ function IntegrationsManagementPage({
|
|
|
5727
6065
|
const otherCards = cards.filter(
|
|
5728
6066
|
(c) => c.isAddNew || c.state === "coming_soon"
|
|
5729
6067
|
);
|
|
5730
|
-
return /* @__PURE__ */
|
|
5731
|
-
/* @__PURE__ */
|
|
5732
|
-
/* @__PURE__ */
|
|
5733
|
-
/* @__PURE__ */
|
|
6068
|
+
return /* @__PURE__ */ jsxs29("div", { className: "flex flex-col gap-4 p-4 md:p-6", children: [
|
|
6069
|
+
/* @__PURE__ */ jsx31("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsxs29("div", { children: [
|
|
6070
|
+
/* @__PURE__ */ jsx31("h1", { className: "text-xl font-semibold", children: title }),
|
|
6071
|
+
/* @__PURE__ */ jsx31("p", { className: "text-sm text-muted-foreground", children: subtitle })
|
|
5734
6072
|
] }) }),
|
|
5735
|
-
cardsLoading ? /* @__PURE__ */
|
|
5736
|
-
/* @__PURE__ */
|
|
5737
|
-
/* @__PURE__ */
|
|
5738
|
-
] }) : /* @__PURE__ */
|
|
5739
|
-
connectedCards.length > 0 && /* @__PURE__ */
|
|
5740
|
-
/* @__PURE__ */
|
|
5741
|
-
/* @__PURE__ */
|
|
6073
|
+
cardsLoading ? /* @__PURE__ */ jsx31("div", { className: "flex items-center justify-center py-16", children: /* @__PURE__ */ jsx31(Loader210, { className: "h-6 w-6 animate-spin text-muted-foreground" }) }) : cards.length === 0 ? /* @__PURE__ */ jsxs29("div", { className: "flex flex-col items-center justify-center gap-3 py-16 text-muted-foreground", children: [
|
|
6074
|
+
/* @__PURE__ */ jsx31(Plug5, { className: "h-10 w-10" }),
|
|
6075
|
+
/* @__PURE__ */ jsx31("p", { className: "text-sm", children: "Nenhuma integra\xE7\xE3o dispon\xEDvel" })
|
|
6076
|
+
] }) : /* @__PURE__ */ jsxs29("div", { className: "space-y-6", children: [
|
|
6077
|
+
connectedCards.length > 0 && /* @__PURE__ */ jsxs29("div", { children: [
|
|
6078
|
+
/* @__PURE__ */ jsx31("h3", { className: "mb-3 text-xs font-medium uppercase tracking-wider text-muted-foreground", children: "Contas conectadas" }),
|
|
6079
|
+
/* @__PURE__ */ jsx31("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3", children: connectedCards.map((card) => /* @__PURE__ */ jsx31(
|
|
5742
6080
|
IntegrationCard,
|
|
5743
6081
|
{
|
|
5744
6082
|
card,
|
|
@@ -5750,11 +6088,11 @@ function IntegrationsManagementPage({
|
|
|
5750
6088
|
`${card.definition.slug}-cred-${card.credentialId}`
|
|
5751
6089
|
)) })
|
|
5752
6090
|
] }),
|
|
5753
|
-
otherCards.length > 0 && /* @__PURE__ */
|
|
5754
|
-
connectedCards.length > 0 && /* @__PURE__ */
|
|
5755
|
-
/* @__PURE__ */
|
|
6091
|
+
otherCards.length > 0 && /* @__PURE__ */ jsxs29("div", { children: [
|
|
6092
|
+
connectedCards.length > 0 && /* @__PURE__ */ jsx31("h3", { className: "mb-3 text-xs font-medium uppercase tracking-wider text-muted-foreground", children: "Adicionar integra\xE7\xE3o" }),
|
|
6093
|
+
/* @__PURE__ */ jsx31("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3", children: otherCards.map((card) => {
|
|
5756
6094
|
const key = card.isAddNew ? `${card.definition.slug}-add-new` : card.definition.slug;
|
|
5757
|
-
return /* @__PURE__ */
|
|
6095
|
+
return /* @__PURE__ */ jsx31(
|
|
5758
6096
|
IntegrationCard,
|
|
5759
6097
|
{
|
|
5760
6098
|
card,
|
|
@@ -5765,7 +6103,7 @@ function IntegrationsManagementPage({
|
|
|
5765
6103
|
}) })
|
|
5766
6104
|
] })
|
|
5767
6105
|
] }),
|
|
5768
|
-
activeCard && wizardMeta && /* @__PURE__ */
|
|
6106
|
+
activeCard && wizardMeta && /* @__PURE__ */ jsx31(
|
|
5769
6107
|
IntegrationWizard,
|
|
5770
6108
|
{
|
|
5771
6109
|
open: wizardOpen,
|
|
@@ -5787,16 +6125,18 @@ export {
|
|
|
5787
6125
|
AgentCapabilitiesPage,
|
|
5788
6126
|
AgentConversationsPanel,
|
|
5789
6127
|
AgentConversationsTable,
|
|
6128
|
+
AgentDefinitionEditor,
|
|
5790
6129
|
AgentDetailPage,
|
|
5791
6130
|
AgentEditForm,
|
|
5792
6131
|
AgentFormDialog,
|
|
5793
6132
|
AgentObjectivesList,
|
|
5794
|
-
|
|
6133
|
+
AgentRevisionTab,
|
|
5795
6134
|
AgentTabs,
|
|
5796
6135
|
AgentToolsList,
|
|
5797
6136
|
AgentsPage,
|
|
5798
6137
|
AgentsTable,
|
|
5799
6138
|
CapabilitiesTab,
|
|
6139
|
+
ConversationFlowEditor,
|
|
5800
6140
|
ConversationView,
|
|
5801
6141
|
CredentialsPage,
|
|
5802
6142
|
INTEGRATIONS_REGISTRY,
|