@greatapps/greatagents-ui 0.3.21 → 0.3.23

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