@greatapps/greatagents-ui 0.3.6 → 0.3.8
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 +1173 -1140
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/agents/agent-tabs.tsx +1 -10
- package/src/components/agents/agent-tools-list.tsx +11 -6
- package/src/components/capabilities/capabilities-tab.tsx +1 -1
- package/src/components/capabilities/integration-wizard.tsx +53 -38
- package/src/components/capabilities/wizard-steps/credentials-step.tsx +5 -1
- package/src/components/tools/tool-credentials-form.tsx +18 -4
- package/src/components/tools/tools-table.tsx +3 -2
package/dist/index.js
CHANGED
|
@@ -1118,13 +1118,21 @@ function AgentEditForm({ config, agent, idAccount, open, onOpenChange }) {
|
|
|
1118
1118
|
return /* @__PURE__ */ jsx3("div", { className: "max-w-lg pt-4", children: formContent });
|
|
1119
1119
|
}
|
|
1120
1120
|
|
|
1121
|
-
// src/components/agents/agent-
|
|
1122
|
-
import { useState as
|
|
1121
|
+
// src/components/agents/agent-objectives-list.tsx
|
|
1122
|
+
import { useState as useState5 } from "react";
|
|
1123
1123
|
import {
|
|
1124
|
-
|
|
1125
|
-
Badge as Badge2,
|
|
1124
|
+
Input as Input4,
|
|
1126
1125
|
Button as Button4,
|
|
1126
|
+
Switch as Switch3,
|
|
1127
1127
|
Skeleton,
|
|
1128
|
+
Textarea,
|
|
1129
|
+
Label as Label3,
|
|
1130
|
+
Badge as Badge2,
|
|
1131
|
+
Dialog as Dialog3,
|
|
1132
|
+
DialogContent as DialogContent3,
|
|
1133
|
+
DialogHeader as DialogHeader3,
|
|
1134
|
+
DialogTitle as DialogTitle3,
|
|
1135
|
+
DialogFooter as DialogFooter3,
|
|
1128
1136
|
AlertDialog as AlertDialog2,
|
|
1129
1137
|
AlertDialogAction as AlertDialogAction2,
|
|
1130
1138
|
AlertDialogCancel as AlertDialogCancel2,
|
|
@@ -1132,340 +1140,7 @@ import {
|
|
|
1132
1140
|
AlertDialogDescription as AlertDialogDescription2,
|
|
1133
1141
|
AlertDialogFooter as AlertDialogFooter2,
|
|
1134
1142
|
AlertDialogHeader as AlertDialogHeader2,
|
|
1135
|
-
AlertDialogTitle as AlertDialogTitle2
|
|
1136
|
-
Popover,
|
|
1137
|
-
PopoverContent,
|
|
1138
|
-
PopoverTrigger,
|
|
1139
|
-
Input as Input4,
|
|
1140
|
-
Textarea,
|
|
1141
|
-
Dialog as Dialog3,
|
|
1142
|
-
DialogContent as DialogContent3,
|
|
1143
|
-
DialogHeader as DialogHeader3,
|
|
1144
|
-
DialogTitle as DialogTitle3,
|
|
1145
|
-
DialogFooter as DialogFooter3,
|
|
1146
|
-
Label as Label3,
|
|
1147
|
-
Select,
|
|
1148
|
-
SelectContent,
|
|
1149
|
-
SelectItem,
|
|
1150
|
-
SelectTrigger,
|
|
1151
|
-
SelectValue
|
|
1152
|
-
} from "@greatapps/greatauth-ui/ui";
|
|
1153
|
-
import {
|
|
1154
|
-
Trash2 as Trash22,
|
|
1155
|
-
Plus,
|
|
1156
|
-
Wrench,
|
|
1157
|
-
Settings2
|
|
1158
|
-
} from "lucide-react";
|
|
1159
|
-
import { toast as toast4 } from "sonner";
|
|
1160
|
-
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1161
|
-
function AgentToolsList({ agent, config }) {
|
|
1162
|
-
const { data: agentToolsData, isLoading } = useAgentTools(config, agent.id);
|
|
1163
|
-
const { data: allToolsData } = useTools(config);
|
|
1164
|
-
const addMutation = useAddAgentTool(config);
|
|
1165
|
-
const removeMutation = useRemoveAgentTool(config);
|
|
1166
|
-
const updateMutation = useUpdateAgentTool(config);
|
|
1167
|
-
const [removeTarget, setRemoveTarget] = useState4(null);
|
|
1168
|
-
const [addOpen, setAddOpen] = useState4(false);
|
|
1169
|
-
const [search, setSearch] = useState4("");
|
|
1170
|
-
const [configTarget, setConfigTarget] = useState4(null);
|
|
1171
|
-
const [configInstructions, setConfigInstructions] = useState4("");
|
|
1172
|
-
const [configCredentialId, setConfigCredentialId] = useState4("");
|
|
1173
|
-
const { data: credentialsData } = useToolCredentials(config);
|
|
1174
|
-
const allCredentials = credentialsData?.data || [];
|
|
1175
|
-
const agentTools = agentToolsData?.data || [];
|
|
1176
|
-
const allTools = allToolsData?.data || [];
|
|
1177
|
-
const assignedToolIds = new Set(agentTools.map((at) => at.id_tool));
|
|
1178
|
-
const availableTools = allTools.filter((t) => !assignedToolIds.has(t.id));
|
|
1179
|
-
const filteredAvailable = availableTools.filter(
|
|
1180
|
-
(t) => t.name.toLowerCase().includes(search.toLowerCase())
|
|
1181
|
-
);
|
|
1182
|
-
function getToolInfo(idTool) {
|
|
1183
|
-
return allTools.find((t) => t.id === idTool);
|
|
1184
|
-
}
|
|
1185
|
-
async function handleToggleEnabled(agentTool, checked) {
|
|
1186
|
-
try {
|
|
1187
|
-
await updateMutation.mutateAsync({
|
|
1188
|
-
idAgent: agent.id,
|
|
1189
|
-
id: agentTool.id,
|
|
1190
|
-
body: { enabled: checked }
|
|
1191
|
-
});
|
|
1192
|
-
toast4.success(checked ? "Ferramenta ativada" : "Ferramenta desativada");
|
|
1193
|
-
} catch (err) {
|
|
1194
|
-
toast4.error(
|
|
1195
|
-
err instanceof Error ? err.message : "Erro ao alterar estado da ferramenta"
|
|
1196
|
-
);
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
async function handleAdd(tool) {
|
|
1200
|
-
try {
|
|
1201
|
-
await addMutation.mutateAsync({
|
|
1202
|
-
idAgent: agent.id,
|
|
1203
|
-
body: { id_tool: tool.id }
|
|
1204
|
-
});
|
|
1205
|
-
toast4.success("Ferramenta adicionada");
|
|
1206
|
-
setAddOpen(false);
|
|
1207
|
-
setSearch("");
|
|
1208
|
-
} catch (err) {
|
|
1209
|
-
toast4.error(
|
|
1210
|
-
err instanceof Error ? err.message : "Erro ao adicionar ferramenta"
|
|
1211
|
-
);
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
async function handleRemove() {
|
|
1215
|
-
if (!removeTarget) return;
|
|
1216
|
-
try {
|
|
1217
|
-
await removeMutation.mutateAsync({
|
|
1218
|
-
idAgent: agent.id,
|
|
1219
|
-
id: removeTarget.id
|
|
1220
|
-
});
|
|
1221
|
-
toast4.success("Ferramenta removida");
|
|
1222
|
-
} catch (err) {
|
|
1223
|
-
toast4.error(
|
|
1224
|
-
err instanceof Error ? err.message : "Erro ao remover ferramenta"
|
|
1225
|
-
);
|
|
1226
|
-
} finally {
|
|
1227
|
-
setRemoveTarget(null);
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
function openConfig(agentTool) {
|
|
1231
|
-
setConfigTarget(agentTool);
|
|
1232
|
-
setConfigInstructions(agentTool.custom_instructions || "");
|
|
1233
|
-
setConfigCredentialId(agentTool.id_tool_credential ? String(agentTool.id_tool_credential) : "");
|
|
1234
|
-
}
|
|
1235
|
-
async function handleSaveConfig() {
|
|
1236
|
-
if (!configTarget) return;
|
|
1237
|
-
try {
|
|
1238
|
-
const newCredentialId = configCredentialId ? parseInt(configCredentialId, 10) : null;
|
|
1239
|
-
await updateMutation.mutateAsync({
|
|
1240
|
-
idAgent: agent.id,
|
|
1241
|
-
id: configTarget.id,
|
|
1242
|
-
body: {
|
|
1243
|
-
custom_instructions: configInstructions.trim() || null,
|
|
1244
|
-
id_tool_credential: newCredentialId
|
|
1245
|
-
}
|
|
1246
|
-
});
|
|
1247
|
-
toast4.success("Configura\xE7\xE3o atualizada");
|
|
1248
|
-
setConfigTarget(null);
|
|
1249
|
-
} catch (err) {
|
|
1250
|
-
toast4.error(
|
|
1251
|
-
err instanceof Error ? err.message : "Erro ao atualizar configura\xE7\xE3o"
|
|
1252
|
-
);
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
|
-
if (isLoading) {
|
|
1256
|
-
return /* @__PURE__ */ jsx4("div", { className: "space-y-3 p-4", children: Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ jsx4(Skeleton, { className: "h-14 w-full" }, i)) });
|
|
1257
|
-
}
|
|
1258
|
-
return /* @__PURE__ */ jsxs4("div", { className: "space-y-4 p-4", children: [
|
|
1259
|
-
/* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between", children: [
|
|
1260
|
-
/* @__PURE__ */ jsxs4("h3", { className: "text-sm font-medium text-muted-foreground", children: [
|
|
1261
|
-
agentTools.length,
|
|
1262
|
-
" ferramenta",
|
|
1263
|
-
agentTools.length !== 1 ? "s" : "",
|
|
1264
|
-
" associada",
|
|
1265
|
-
agentTools.length !== 1 ? "s" : ""
|
|
1266
|
-
] }),
|
|
1267
|
-
/* @__PURE__ */ jsxs4(Popover, { open: addOpen, onOpenChange: setAddOpen, children: [
|
|
1268
|
-
/* @__PURE__ */ jsx4(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs4(Button4, { size: "sm", disabled: availableTools.length === 0, children: [
|
|
1269
|
-
/* @__PURE__ */ jsx4(Plus, { className: "mr-2 h-4 w-4" }),
|
|
1270
|
-
"Adicionar Ferramenta"
|
|
1271
|
-
] }) }),
|
|
1272
|
-
/* @__PURE__ */ jsxs4(PopoverContent, { className: "w-72 p-0", align: "end", children: [
|
|
1273
|
-
/* @__PURE__ */ jsx4("div", { className: "p-2", children: /* @__PURE__ */ jsx4(
|
|
1274
|
-
Input4,
|
|
1275
|
-
{
|
|
1276
|
-
placeholder: "Buscar ferramenta\\u2026",
|
|
1277
|
-
"aria-label": "Buscar ferramenta",
|
|
1278
|
-
name: "search",
|
|
1279
|
-
value: search,
|
|
1280
|
-
onChange: (e) => setSearch(e.target.value),
|
|
1281
|
-
className: "h-8"
|
|
1282
|
-
}
|
|
1283
|
-
) }),
|
|
1284
|
-
/* @__PURE__ */ jsx4("div", { className: "max-h-48 overflow-y-auto", children: filteredAvailable.length === 0 ? /* @__PURE__ */ jsx4("p", { className: "p-3 text-center text-sm text-muted-foreground", children: "Nenhuma ferramenta dispon\xEDvel" }) : filteredAvailable.map((tool) => /* @__PURE__ */ jsxs4(
|
|
1285
|
-
"button",
|
|
1286
|
-
{
|
|
1287
|
-
type: "button",
|
|
1288
|
-
className: "flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-accent",
|
|
1289
|
-
onClick: () => handleAdd(tool),
|
|
1290
|
-
disabled: addMutation.isPending,
|
|
1291
|
-
children: [
|
|
1292
|
-
/* @__PURE__ */ jsx4(Wrench, { className: "h-4 w-4 text-muted-foreground" }),
|
|
1293
|
-
/* @__PURE__ */ jsx4("span", { className: "flex-1 font-medium", children: tool.name }),
|
|
1294
|
-
/* @__PURE__ */ jsx4(Badge2, { variant: "secondary", className: "text-xs", children: tool.type })
|
|
1295
|
-
]
|
|
1296
|
-
},
|
|
1297
|
-
tool.id
|
|
1298
|
-
)) })
|
|
1299
|
-
] })
|
|
1300
|
-
] })
|
|
1301
|
-
] }),
|
|
1302
|
-
agentTools.length === 0 ? /* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-center justify-center rounded-lg border border-dashed p-8 text-center", children: [
|
|
1303
|
-
/* @__PURE__ */ jsx4(Wrench, { className: "mb-2 h-8 w-8 text-muted-foreground" }),
|
|
1304
|
-
/* @__PURE__ */ jsx4("p", { className: "text-sm text-muted-foreground", children: "Nenhuma ferramenta associada. Clique em 'Adicionar Ferramenta' para come\xE7ar." })
|
|
1305
|
-
] }) : /* @__PURE__ */ jsx4("div", { className: "space-y-2", children: agentTools.map((agentTool) => {
|
|
1306
|
-
const tool = getToolInfo(agentTool.id_tool);
|
|
1307
|
-
return /* @__PURE__ */ jsxs4(
|
|
1308
|
-
"div",
|
|
1309
|
-
{
|
|
1310
|
-
className: "flex items-center gap-3 rounded-lg border bg-card p-3",
|
|
1311
|
-
children: [
|
|
1312
|
-
/* @__PURE__ */ jsxs4("div", { className: "flex flex-1 flex-col gap-1 min-w-0", children: [
|
|
1313
|
-
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2", children: [
|
|
1314
|
-
/* @__PURE__ */ jsx4("span", { className: "truncate font-medium", children: tool?.name || `Ferramenta #${agentTool.id_tool}` }),
|
|
1315
|
-
tool?.type && /* @__PURE__ */ jsx4(Badge2, { variant: "secondary", className: "shrink-0 text-xs", children: tool.type })
|
|
1316
|
-
] }),
|
|
1317
|
-
agentTool.custom_instructions && /* @__PURE__ */ jsx4("p", { className: "truncate text-xs text-muted-foreground", children: agentTool.custom_instructions })
|
|
1318
|
-
] }),
|
|
1319
|
-
/* @__PURE__ */ jsx4(
|
|
1320
|
-
Switch3,
|
|
1321
|
-
{
|
|
1322
|
-
"aria-label": "Ativar/Desativar",
|
|
1323
|
-
checked: agentTool.enabled,
|
|
1324
|
-
onCheckedChange: (checked) => handleToggleEnabled(agentTool, checked),
|
|
1325
|
-
disabled: updateMutation.isPending
|
|
1326
|
-
}
|
|
1327
|
-
),
|
|
1328
|
-
/* @__PURE__ */ jsx4(
|
|
1329
|
-
Button4,
|
|
1330
|
-
{
|
|
1331
|
-
variant: "ghost",
|
|
1332
|
-
size: "icon",
|
|
1333
|
-
"aria-label": "Configurar",
|
|
1334
|
-
className: "shrink-0 text-muted-foreground hover:text-foreground",
|
|
1335
|
-
onClick: () => openConfig(agentTool),
|
|
1336
|
-
title: "Configurar instru\xE7\xF5es",
|
|
1337
|
-
children: /* @__PURE__ */ jsx4(Settings2, { className: "h-4 w-4" })
|
|
1338
|
-
}
|
|
1339
|
-
),
|
|
1340
|
-
/* @__PURE__ */ jsx4(
|
|
1341
|
-
Button4,
|
|
1342
|
-
{
|
|
1343
|
-
variant: "ghost",
|
|
1344
|
-
size: "icon",
|
|
1345
|
-
"aria-label": "Remover",
|
|
1346
|
-
className: "shrink-0 text-muted-foreground hover:text-destructive",
|
|
1347
|
-
onClick: () => setRemoveTarget(agentTool),
|
|
1348
|
-
children: /* @__PURE__ */ jsx4(Trash22, { className: "h-4 w-4" })
|
|
1349
|
-
}
|
|
1350
|
-
)
|
|
1351
|
-
]
|
|
1352
|
-
},
|
|
1353
|
-
agentTool.id
|
|
1354
|
-
);
|
|
1355
|
-
}) }),
|
|
1356
|
-
/* @__PURE__ */ jsx4(
|
|
1357
|
-
Dialog3,
|
|
1358
|
-
{
|
|
1359
|
-
open: !!configTarget,
|
|
1360
|
-
onOpenChange: (open) => !open && setConfigTarget(null),
|
|
1361
|
-
children: /* @__PURE__ */ jsxs4(DialogContent3, { className: "sm:max-w-lg", children: [
|
|
1362
|
-
/* @__PURE__ */ jsx4(DialogHeader3, { children: /* @__PURE__ */ jsx4(DialogTitle3, { children: "Instru\xE7\xF5es da Ferramenta" }) }),
|
|
1363
|
-
/* @__PURE__ */ jsxs4("div", { className: "space-y-4", children: [
|
|
1364
|
-
configTarget && getToolInfo(configTarget.id_tool)?.type !== "none" && /* @__PURE__ */ jsxs4("div", { className: "space-y-2", children: [
|
|
1365
|
-
/* @__PURE__ */ jsx4(Label3, { htmlFor: "tool-credential", children: "Credencial" }),
|
|
1366
|
-
/* @__PURE__ */ jsxs4(
|
|
1367
|
-
Select,
|
|
1368
|
-
{
|
|
1369
|
-
value: configCredentialId || void 0,
|
|
1370
|
-
onValueChange: (val) => setConfigCredentialId(val === "__none__" ? "" : val),
|
|
1371
|
-
children: [
|
|
1372
|
-
/* @__PURE__ */ jsx4(SelectTrigger, { id: "tool-credential", children: /* @__PURE__ */ jsx4(SelectValue, { placeholder: "Selecione uma credencial (opcional)" }) }),
|
|
1373
|
-
/* @__PURE__ */ jsxs4(SelectContent, { children: [
|
|
1374
|
-
/* @__PURE__ */ jsx4(SelectItem, { value: "__none__", children: "Nenhuma (autom\xE1tico)" }),
|
|
1375
|
-
allCredentials.filter((c) => configTarget && c.id_tool === configTarget.id_tool && c.status === "active").map((c) => /* @__PURE__ */ jsx4(SelectItem, { value: String(c.id), children: c.label || `Credencial #${c.id}` }, c.id))
|
|
1376
|
-
] })
|
|
1377
|
-
]
|
|
1378
|
-
}
|
|
1379
|
-
),
|
|
1380
|
-
/* @__PURE__ */ jsx4("p", { className: "text-xs text-muted-foreground", children: "Vincule uma credencial espec\xEDfica a esta ferramenta neste agente." })
|
|
1381
|
-
] }),
|
|
1382
|
-
/* @__PURE__ */ jsxs4("div", { className: "space-y-2", children: [
|
|
1383
|
-
/* @__PURE__ */ jsx4(Label3, { htmlFor: "tool-instructions", children: "Instru\xE7\xF5es Personalizadas" }),
|
|
1384
|
-
/* @__PURE__ */ jsx4(
|
|
1385
|
-
Textarea,
|
|
1386
|
-
{
|
|
1387
|
-
id: "tool-instructions",
|
|
1388
|
-
name: "instructions",
|
|
1389
|
-
value: configInstructions,
|
|
1390
|
-
onChange: (e) => setConfigInstructions(e.target.value),
|
|
1391
|
-
placeholder: "Instru\\u00e7\\u00f5es sobre como e quando o agente deve usar esta ferramenta\\u2026",
|
|
1392
|
-
rows: 6
|
|
1393
|
-
}
|
|
1394
|
-
),
|
|
1395
|
-
/* @__PURE__ */ jsx4("p", { className: "text-xs text-muted-foreground", children: "Este texto \xE9 adicionado ao prompt do agente para orientar o uso da ferramenta." })
|
|
1396
|
-
] })
|
|
1397
|
-
] }),
|
|
1398
|
-
/* @__PURE__ */ jsxs4(DialogFooter3, { children: [
|
|
1399
|
-
/* @__PURE__ */ jsx4(
|
|
1400
|
-
Button4,
|
|
1401
|
-
{
|
|
1402
|
-
variant: "outline",
|
|
1403
|
-
onClick: () => setConfigTarget(null),
|
|
1404
|
-
children: "Cancelar"
|
|
1405
|
-
}
|
|
1406
|
-
),
|
|
1407
|
-
/* @__PURE__ */ jsx4(
|
|
1408
|
-
Button4,
|
|
1409
|
-
{
|
|
1410
|
-
onClick: handleSaveConfig,
|
|
1411
|
-
disabled: updateMutation.isPending,
|
|
1412
|
-
children: "Salvar"
|
|
1413
|
-
}
|
|
1414
|
-
)
|
|
1415
|
-
] })
|
|
1416
|
-
] })
|
|
1417
|
-
}
|
|
1418
|
-
),
|
|
1419
|
-
/* @__PURE__ */ jsx4(
|
|
1420
|
-
AlertDialog2,
|
|
1421
|
-
{
|
|
1422
|
-
open: !!removeTarget,
|
|
1423
|
-
onOpenChange: (open) => !open && setRemoveTarget(null),
|
|
1424
|
-
children: /* @__PURE__ */ jsxs4(AlertDialogContent2, { children: [
|
|
1425
|
-
/* @__PURE__ */ jsxs4(AlertDialogHeader2, { children: [
|
|
1426
|
-
/* @__PURE__ */ jsx4(AlertDialogTitle2, { children: "Remover ferramenta?" }),
|
|
1427
|
-
/* @__PURE__ */ jsx4(AlertDialogDescription2, { children: "A ferramenta ser\xE1 desassociada deste agente." })
|
|
1428
|
-
] }),
|
|
1429
|
-
/* @__PURE__ */ jsxs4(AlertDialogFooter2, { children: [
|
|
1430
|
-
/* @__PURE__ */ jsx4(AlertDialogCancel2, { children: "Cancelar" }),
|
|
1431
|
-
/* @__PURE__ */ jsx4(
|
|
1432
|
-
AlertDialogAction2,
|
|
1433
|
-
{
|
|
1434
|
-
onClick: handleRemove,
|
|
1435
|
-
disabled: removeMutation.isPending,
|
|
1436
|
-
children: "Remover"
|
|
1437
|
-
}
|
|
1438
|
-
)
|
|
1439
|
-
] })
|
|
1440
|
-
] })
|
|
1441
|
-
}
|
|
1442
|
-
)
|
|
1443
|
-
] });
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
|
-
// src/components/agents/agent-objectives-list.tsx
|
|
1447
|
-
import { useState as useState6 } from "react";
|
|
1448
|
-
import {
|
|
1449
|
-
Input as Input5,
|
|
1450
|
-
Button as Button5,
|
|
1451
|
-
Switch as Switch4,
|
|
1452
|
-
Skeleton as Skeleton2,
|
|
1453
|
-
Textarea as Textarea2,
|
|
1454
|
-
Label as Label4,
|
|
1455
|
-
Badge as Badge3,
|
|
1456
|
-
Dialog as Dialog4,
|
|
1457
|
-
DialogContent as DialogContent4,
|
|
1458
|
-
DialogHeader as DialogHeader4,
|
|
1459
|
-
DialogTitle as DialogTitle4,
|
|
1460
|
-
DialogFooter as DialogFooter4,
|
|
1461
|
-
AlertDialog as AlertDialog3,
|
|
1462
|
-
AlertDialogAction as AlertDialogAction3,
|
|
1463
|
-
AlertDialogCancel as AlertDialogCancel3,
|
|
1464
|
-
AlertDialogContent as AlertDialogContent3,
|
|
1465
|
-
AlertDialogDescription as AlertDialogDescription3,
|
|
1466
|
-
AlertDialogFooter as AlertDialogFooter3,
|
|
1467
|
-
AlertDialogHeader as AlertDialogHeader3,
|
|
1468
|
-
AlertDialogTitle as AlertDialogTitle3
|
|
1143
|
+
AlertDialogTitle as AlertDialogTitle2
|
|
1469
1144
|
} from "@greatapps/greatauth-ui/ui";
|
|
1470
1145
|
|
|
1471
1146
|
// src/components/ui/sortable.tsx
|
|
@@ -1538,7 +1213,7 @@ function useComposedRefs(...refs) {
|
|
|
1538
1213
|
}
|
|
1539
1214
|
|
|
1540
1215
|
// src/components/ui/sortable.tsx
|
|
1541
|
-
import { jsx as
|
|
1216
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
1542
1217
|
var orientationConfig = {
|
|
1543
1218
|
vertical: {
|
|
1544
1219
|
modifiers: [restrictToVerticalAxis, restrictToParentElement],
|
|
@@ -1723,11 +1398,11 @@ function Sortable(props) {
|
|
|
1723
1398
|
flatCursor
|
|
1724
1399
|
]
|
|
1725
1400
|
);
|
|
1726
|
-
return /* @__PURE__ */
|
|
1401
|
+
return /* @__PURE__ */ jsx4(
|
|
1727
1402
|
SortableRootContext.Provider,
|
|
1728
1403
|
{
|
|
1729
1404
|
value: contextValue,
|
|
1730
|
-
children: /* @__PURE__ */
|
|
1405
|
+
children: /* @__PURE__ */ jsx4(
|
|
1731
1406
|
DndContext,
|
|
1732
1407
|
{
|
|
1733
1408
|
collisionDetection: collisionDetection ?? config.collisionDetection,
|
|
@@ -1760,12 +1435,12 @@ function SortableContent(props) {
|
|
|
1760
1435
|
} = props;
|
|
1761
1436
|
const context = useSortableContext(CONTENT_NAME);
|
|
1762
1437
|
const ContentPrimitive = asChild ? SlotPrimitive.Slot : "div";
|
|
1763
|
-
return /* @__PURE__ */
|
|
1438
|
+
return /* @__PURE__ */ jsx4(SortableContentContext.Provider, { value: true, children: /* @__PURE__ */ jsx4(
|
|
1764
1439
|
SortableContext,
|
|
1765
1440
|
{
|
|
1766
1441
|
items: context.items,
|
|
1767
1442
|
strategy: strategyProp ?? context.strategy,
|
|
1768
|
-
children: withoutSlot ? children : /* @__PURE__ */
|
|
1443
|
+
children: withoutSlot ? children : /* @__PURE__ */ jsx4(
|
|
1769
1444
|
ContentPrimitive,
|
|
1770
1445
|
{
|
|
1771
1446
|
"data-slot": "sortable-content",
|
|
@@ -1841,7 +1516,7 @@ function SortableItem(props) {
|
|
|
1841
1516
|
[id, attributes, listeners, setActivatorNodeRef, isDragging, disabled]
|
|
1842
1517
|
);
|
|
1843
1518
|
const ItemPrimitive = asChild ? SlotPrimitive.Slot : "div";
|
|
1844
|
-
return /* @__PURE__ */
|
|
1519
|
+
return /* @__PURE__ */ jsx4(SortableItemContext.Provider, { value: itemContext, children: /* @__PURE__ */ jsx4(
|
|
1845
1520
|
ItemPrimitive,
|
|
1846
1521
|
{
|
|
1847
1522
|
id,
|
|
@@ -1878,7 +1553,7 @@ function SortableItemHandle(props) {
|
|
|
1878
1553
|
itemContext.setActivatorNodeRef(node);
|
|
1879
1554
|
});
|
|
1880
1555
|
const HandlePrimitive = asChild ? SlotPrimitive.Slot : "button";
|
|
1881
|
-
return /* @__PURE__ */
|
|
1556
|
+
return /* @__PURE__ */ jsx4(
|
|
1882
1557
|
HandlePrimitive,
|
|
1883
1558
|
{
|
|
1884
1559
|
type: "button",
|
|
@@ -1917,14 +1592,14 @@ function SortableOverlay(props) {
|
|
|
1917
1592
|
const container = containerProp ?? (mounted ? globalThis.document?.body : null);
|
|
1918
1593
|
if (!container) return null;
|
|
1919
1594
|
return ReactDOM.createPortal(
|
|
1920
|
-
/* @__PURE__ */
|
|
1595
|
+
/* @__PURE__ */ jsx4(
|
|
1921
1596
|
DragOverlay,
|
|
1922
1597
|
{
|
|
1923
1598
|
dropAnimation,
|
|
1924
1599
|
modifiers: context.modifiers,
|
|
1925
1600
|
className: cn(!context.flatCursor && "cursor-grabbing"),
|
|
1926
1601
|
...overlayProps,
|
|
1927
|
-
children: /* @__PURE__ */
|
|
1602
|
+
children: /* @__PURE__ */ jsx4(SortableOverlayContext.Provider, { value: true, children: context.activeId ? typeof children === "function" ? children({ value: context.activeId }) : children : null })
|
|
1928
1603
|
}
|
|
1929
1604
|
),
|
|
1930
1605
|
container
|
|
@@ -1932,9 +1607,9 @@ function SortableOverlay(props) {
|
|
|
1932
1607
|
}
|
|
1933
1608
|
|
|
1934
1609
|
// src/components/agents/agent-objectives-list.tsx
|
|
1935
|
-
import { Trash2 as
|
|
1936
|
-
import { toast as
|
|
1937
|
-
import { jsx as
|
|
1610
|
+
import { Trash2 as Trash22, Target, Pencil as Pencil2, Plus, GripVertical } from "lucide-react";
|
|
1611
|
+
import { toast as toast4 } from "sonner";
|
|
1612
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1938
1613
|
function slugify(text) {
|
|
1939
1614
|
return text.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
1940
1615
|
}
|
|
@@ -1944,11 +1619,11 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
1944
1619
|
const createMutation = useCreateObjective(config);
|
|
1945
1620
|
const updateMutation = useUpdateObjective(config);
|
|
1946
1621
|
const deleteMutation = useDeleteObjective(config);
|
|
1947
|
-
const [formOpen, setFormOpen] =
|
|
1948
|
-
const [editTarget, setEditTarget] =
|
|
1949
|
-
const [form, setForm] =
|
|
1950
|
-
const [slugManual, setSlugManual] =
|
|
1951
|
-
const [removeTarget, setRemoveTarget] =
|
|
1622
|
+
const [formOpen, setFormOpen] = useState5(false);
|
|
1623
|
+
const [editTarget, setEditTarget] = useState5(null);
|
|
1624
|
+
const [form, setForm] = useState5(EMPTY_FORM);
|
|
1625
|
+
const [slugManual, setSlugManual] = useState5(false);
|
|
1626
|
+
const [removeTarget, setRemoveTarget] = useState5(null);
|
|
1952
1627
|
const objectives = objectivesData?.data || [];
|
|
1953
1628
|
const sortedObjectives = [...objectives].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
1954
1629
|
async function handleReorder(newItems) {
|
|
@@ -1961,9 +1636,9 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
1961
1636
|
body: { order: item.order }
|
|
1962
1637
|
});
|
|
1963
1638
|
}
|
|
1964
|
-
|
|
1639
|
+
toast4.success("Ordem atualizada");
|
|
1965
1640
|
} catch {
|
|
1966
|
-
|
|
1641
|
+
toast4.error("Erro ao reordenar objetivos");
|
|
1967
1642
|
}
|
|
1968
1643
|
}
|
|
1969
1644
|
function openCreate() {
|
|
@@ -1997,7 +1672,7 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
1997
1672
|
prompt: form.prompt.trim() || null
|
|
1998
1673
|
}
|
|
1999
1674
|
});
|
|
2000
|
-
|
|
1675
|
+
toast4.success("Objetivo atualizado");
|
|
2001
1676
|
} else {
|
|
2002
1677
|
await createMutation.mutateAsync({
|
|
2003
1678
|
idAgent: agent.id,
|
|
@@ -2008,11 +1683,11 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
2008
1683
|
order: nextOrder
|
|
2009
1684
|
}
|
|
2010
1685
|
});
|
|
2011
|
-
|
|
1686
|
+
toast4.success("Objetivo criado");
|
|
2012
1687
|
}
|
|
2013
1688
|
setFormOpen(false);
|
|
2014
1689
|
} catch (err) {
|
|
2015
|
-
|
|
1690
|
+
toast4.error(
|
|
2016
1691
|
err instanceof Error ? err.message : editTarget ? "Erro ao atualizar objetivo" : "Erro ao criar objetivo"
|
|
2017
1692
|
);
|
|
2018
1693
|
}
|
|
@@ -2024,9 +1699,9 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
2024
1699
|
id: objective.id,
|
|
2025
1700
|
body: { active: checked }
|
|
2026
1701
|
});
|
|
2027
|
-
|
|
1702
|
+
toast4.success(checked ? "Objetivo ativado" : "Objetivo desativado");
|
|
2028
1703
|
} catch (err) {
|
|
2029
|
-
|
|
1704
|
+
toast4.error(
|
|
2030
1705
|
err instanceof Error ? err.message : "Erro ao alterar estado do objetivo"
|
|
2031
1706
|
);
|
|
2032
1707
|
}
|
|
@@ -2038,9 +1713,9 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
2038
1713
|
idAgent: agent.id,
|
|
2039
1714
|
id: removeTarget.id
|
|
2040
1715
|
});
|
|
2041
|
-
|
|
1716
|
+
toast4.success("Objetivo removido");
|
|
2042
1717
|
} catch (err) {
|
|
2043
|
-
|
|
1718
|
+
toast4.error(
|
|
2044
1719
|
err instanceof Error ? err.message : "Erro ao remover o objetivo"
|
|
2045
1720
|
);
|
|
2046
1721
|
} finally {
|
|
@@ -2048,51 +1723,51 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
2048
1723
|
}
|
|
2049
1724
|
}
|
|
2050
1725
|
if (isLoading) {
|
|
2051
|
-
return /* @__PURE__ */
|
|
1726
|
+
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)) });
|
|
2052
1727
|
}
|
|
2053
|
-
return /* @__PURE__ */
|
|
2054
|
-
/* @__PURE__ */
|
|
2055
|
-
/* @__PURE__ */
|
|
2056
|
-
/* @__PURE__ */
|
|
1728
|
+
return /* @__PURE__ */ jsxs4("div", { className: "space-y-4 p-4", children: [
|
|
1729
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between", children: [
|
|
1730
|
+
/* @__PURE__ */ jsxs4("div", { children: [
|
|
1731
|
+
/* @__PURE__ */ jsxs4("h3", { className: "text-sm font-medium text-muted-foreground", children: [
|
|
2057
1732
|
sortedObjectives.length,
|
|
2058
1733
|
" objetivo",
|
|
2059
1734
|
sortedObjectives.length !== 1 ? "s" : "",
|
|
2060
1735
|
" definido",
|
|
2061
1736
|
sortedObjectives.length !== 1 ? "s" : ""
|
|
2062
1737
|
] }),
|
|
2063
|
-
/* @__PURE__ */
|
|
1738
|
+
/* @__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." })
|
|
2064
1739
|
] }),
|
|
2065
|
-
/* @__PURE__ */
|
|
2066
|
-
/* @__PURE__ */
|
|
1740
|
+
/* @__PURE__ */ jsxs4(Button4, { onClick: openCreate, size: "sm", children: [
|
|
1741
|
+
/* @__PURE__ */ jsx5(Plus, { className: "mr-2 h-4 w-4" }),
|
|
2067
1742
|
"Novo Objetivo"
|
|
2068
1743
|
] })
|
|
2069
1744
|
] }),
|
|
2070
|
-
sortedObjectives.length === 0 ? /* @__PURE__ */
|
|
2071
|
-
/* @__PURE__ */
|
|
2072
|
-
/* @__PURE__ */
|
|
2073
|
-
] }) : /* @__PURE__ */
|
|
1745
|
+
sortedObjectives.length === 0 ? /* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-center justify-center rounded-lg border border-dashed p-8 text-center", children: [
|
|
1746
|
+
/* @__PURE__ */ jsx5(Target, { className: "mb-2 h-8 w-8 text-muted-foreground" }),
|
|
1747
|
+
/* @__PURE__ */ jsx5("p", { className: "text-sm text-muted-foreground", children: "Nenhum objetivo definido. Adicione objetivos para orientar o agente em diferentes contextos." })
|
|
1748
|
+
] }) : /* @__PURE__ */ jsxs4(
|
|
2074
1749
|
Sortable,
|
|
2075
1750
|
{
|
|
2076
1751
|
value: sortedObjectives,
|
|
2077
1752
|
onValueChange: handleReorder,
|
|
2078
1753
|
getItemValue: (item) => item.id,
|
|
2079
1754
|
children: [
|
|
2080
|
-
/* @__PURE__ */
|
|
1755
|
+
/* @__PURE__ */ jsx5(SortableContent, { className: "space-y-2", children: sortedObjectives.map((objective) => /* @__PURE__ */ jsxs4(
|
|
2081
1756
|
SortableItem,
|
|
2082
1757
|
{
|
|
2083
1758
|
value: objective.id,
|
|
2084
1759
|
className: "flex items-center gap-3 rounded-lg border bg-card p-3",
|
|
2085
1760
|
children: [
|
|
2086
|
-
/* @__PURE__ */
|
|
2087
|
-
/* @__PURE__ */
|
|
2088
|
-
/* @__PURE__ */
|
|
2089
|
-
/* @__PURE__ */
|
|
2090
|
-
objective.slug && /* @__PURE__ */
|
|
1761
|
+
/* @__PURE__ */ jsx5(SortableItemHandle, { className: "shrink-0 text-muted-foreground hover:text-foreground", children: /* @__PURE__ */ jsx5(GripVertical, { "aria-hidden": "true", className: "h-5 w-5" }) }),
|
|
1762
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-1 flex-col gap-1 min-w-0", children: [
|
|
1763
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2", children: [
|
|
1764
|
+
/* @__PURE__ */ jsx5("span", { className: "truncate font-medium", children: objective.title }),
|
|
1765
|
+
objective.slug && /* @__PURE__ */ jsx5(Badge2, { variant: "secondary", className: "shrink-0 text-xs font-mono", children: objective.slug })
|
|
2091
1766
|
] }),
|
|
2092
|
-
objective.prompt && /* @__PURE__ */
|
|
1767
|
+
objective.prompt && /* @__PURE__ */ jsx5("p", { className: "line-clamp-2 text-xs text-muted-foreground", children: objective.prompt })
|
|
2093
1768
|
] }),
|
|
2094
|
-
/* @__PURE__ */
|
|
2095
|
-
|
|
1769
|
+
/* @__PURE__ */ jsx5(
|
|
1770
|
+
Switch3,
|
|
2096
1771
|
{
|
|
2097
1772
|
"aria-label": "Ativar/Desativar",
|
|
2098
1773
|
checked: objective.active,
|
|
@@ -2100,49 +1775,49 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
2100
1775
|
disabled: updateMutation.isPending
|
|
2101
1776
|
}
|
|
2102
1777
|
),
|
|
2103
|
-
/* @__PURE__ */
|
|
2104
|
-
|
|
1778
|
+
/* @__PURE__ */ jsx5(
|
|
1779
|
+
Button4,
|
|
2105
1780
|
{
|
|
2106
1781
|
variant: "ghost",
|
|
2107
1782
|
size: "icon",
|
|
2108
1783
|
"aria-label": "Editar",
|
|
2109
1784
|
className: "shrink-0 text-muted-foreground hover:text-foreground",
|
|
2110
1785
|
onClick: () => openEdit(objective),
|
|
2111
|
-
children: /* @__PURE__ */
|
|
1786
|
+
children: /* @__PURE__ */ jsx5(Pencil2, { className: "h-4 w-4" })
|
|
2112
1787
|
}
|
|
2113
1788
|
),
|
|
2114
|
-
/* @__PURE__ */
|
|
2115
|
-
|
|
1789
|
+
/* @__PURE__ */ jsx5(
|
|
1790
|
+
Button4,
|
|
2116
1791
|
{
|
|
2117
1792
|
variant: "ghost",
|
|
2118
1793
|
size: "icon",
|
|
2119
1794
|
"aria-label": "Excluir",
|
|
2120
1795
|
className: "shrink-0 text-muted-foreground hover:text-destructive",
|
|
2121
1796
|
onClick: () => setRemoveTarget(objective),
|
|
2122
|
-
children: /* @__PURE__ */
|
|
1797
|
+
children: /* @__PURE__ */ jsx5(Trash22, { className: "h-4 w-4" })
|
|
2123
1798
|
}
|
|
2124
1799
|
)
|
|
2125
1800
|
]
|
|
2126
1801
|
},
|
|
2127
1802
|
objective.id
|
|
2128
1803
|
)) }),
|
|
2129
|
-
/* @__PURE__ */
|
|
1804
|
+
/* @__PURE__ */ jsx5(SortableOverlay, { children: ({ value }) => {
|
|
2130
1805
|
const obj = sortedObjectives.find((o) => o.id === value);
|
|
2131
|
-
return /* @__PURE__ */
|
|
2132
|
-
/* @__PURE__ */
|
|
2133
|
-
/* @__PURE__ */
|
|
1806
|
+
return /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-3 rounded-lg border bg-card p-3 shadow-lg", children: [
|
|
1807
|
+
/* @__PURE__ */ jsx5(GripVertical, { "aria-hidden": "true", className: "h-5 w-5 text-muted-foreground" }),
|
|
1808
|
+
/* @__PURE__ */ jsx5("span", { className: "font-medium", children: obj?.title })
|
|
2134
1809
|
] });
|
|
2135
1810
|
} })
|
|
2136
1811
|
]
|
|
2137
1812
|
}
|
|
2138
1813
|
),
|
|
2139
|
-
/* @__PURE__ */
|
|
2140
|
-
/* @__PURE__ */
|
|
2141
|
-
/* @__PURE__ */
|
|
2142
|
-
/* @__PURE__ */
|
|
2143
|
-
/* @__PURE__ */
|
|
2144
|
-
/* @__PURE__ */
|
|
2145
|
-
|
|
1814
|
+
/* @__PURE__ */ jsx5(Dialog3, { open: formOpen, onOpenChange: setFormOpen, children: /* @__PURE__ */ jsxs4(DialogContent3, { className: "sm:max-w-lg", children: [
|
|
1815
|
+
/* @__PURE__ */ jsx5(DialogHeader3, { children: /* @__PURE__ */ jsx5(DialogTitle3, { children: editTarget ? "Editar Objetivo" : "Novo Objetivo" }) }),
|
|
1816
|
+
/* @__PURE__ */ jsxs4("div", { className: "space-y-4", children: [
|
|
1817
|
+
/* @__PURE__ */ jsxs4("div", { className: "space-y-2", children: [
|
|
1818
|
+
/* @__PURE__ */ jsx5(Label3, { htmlFor: "objective-title", children: "T\xEDtulo *" }),
|
|
1819
|
+
/* @__PURE__ */ jsx5(
|
|
1820
|
+
Input4,
|
|
2146
1821
|
{
|
|
2147
1822
|
id: "objective-title",
|
|
2148
1823
|
name: "title",
|
|
@@ -2159,10 +1834,10 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
2159
1834
|
}
|
|
2160
1835
|
)
|
|
2161
1836
|
] }),
|
|
2162
|
-
/* @__PURE__ */
|
|
2163
|
-
/* @__PURE__ */
|
|
2164
|
-
/* @__PURE__ */
|
|
2165
|
-
|
|
1837
|
+
/* @__PURE__ */ jsxs4("div", { className: "space-y-2", children: [
|
|
1838
|
+
/* @__PURE__ */ jsx5(Label3, { htmlFor: "objective-slug", children: "Slug (identificador) *" }),
|
|
1839
|
+
/* @__PURE__ */ jsx5(
|
|
1840
|
+
Input4,
|
|
2166
1841
|
{
|
|
2167
1842
|
id: "objective-slug",
|
|
2168
1843
|
name: "slug",
|
|
@@ -2175,12 +1850,12 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
2175
1850
|
className: "font-mono"
|
|
2176
1851
|
}
|
|
2177
1852
|
),
|
|
2178
|
-
/* @__PURE__ */
|
|
1853
|
+
/* @__PURE__ */ jsx5("p", { className: "text-xs text-muted-foreground", children: "Gerado automaticamente. Usado pelo agente para identificar o objetivo." })
|
|
2179
1854
|
] }),
|
|
2180
|
-
/* @__PURE__ */
|
|
2181
|
-
/* @__PURE__ */
|
|
2182
|
-
/* @__PURE__ */
|
|
2183
|
-
|
|
1855
|
+
/* @__PURE__ */ jsxs4("div", { className: "space-y-2", children: [
|
|
1856
|
+
/* @__PURE__ */ jsx5(Label3, { htmlFor: "objective-prompt", children: "Instru\xE7\xF5es do Objetivo" }),
|
|
1857
|
+
/* @__PURE__ */ jsx5(
|
|
1858
|
+
Textarea,
|
|
2184
1859
|
{
|
|
2185
1860
|
id: "objective-prompt",
|
|
2186
1861
|
name: "prompt",
|
|
@@ -2190,20 +1865,20 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
2190
1865
|
rows: 8
|
|
2191
1866
|
}
|
|
2192
1867
|
),
|
|
2193
|
-
/* @__PURE__ */
|
|
1868
|
+
/* @__PURE__ */ jsx5("p", { className: "text-xs text-muted-foreground", children: "Estas instru\xE7\xF5es s\xE3o carregadas automaticamente quando o agente detecta que o utilizador precisa deste objetivo." })
|
|
2194
1869
|
] })
|
|
2195
1870
|
] }),
|
|
2196
|
-
/* @__PURE__ */
|
|
2197
|
-
/* @__PURE__ */
|
|
2198
|
-
|
|
1871
|
+
/* @__PURE__ */ jsxs4(DialogFooter3, { children: [
|
|
1872
|
+
/* @__PURE__ */ jsx5(
|
|
1873
|
+
Button4,
|
|
2199
1874
|
{
|
|
2200
1875
|
variant: "outline",
|
|
2201
1876
|
onClick: () => setFormOpen(false),
|
|
2202
1877
|
children: "Cancelar"
|
|
2203
1878
|
}
|
|
2204
1879
|
),
|
|
2205
|
-
/* @__PURE__ */
|
|
2206
|
-
|
|
1880
|
+
/* @__PURE__ */ jsx5(
|
|
1881
|
+
Button4,
|
|
2207
1882
|
{
|
|
2208
1883
|
onClick: handleSubmit,
|
|
2209
1884
|
disabled: !form.title.trim() || createMutation.isPending || updateMutation.isPending,
|
|
@@ -2212,20 +1887,20 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
2212
1887
|
)
|
|
2213
1888
|
] })
|
|
2214
1889
|
] }) }),
|
|
2215
|
-
/* @__PURE__ */
|
|
2216
|
-
|
|
1890
|
+
/* @__PURE__ */ jsx5(
|
|
1891
|
+
AlertDialog2,
|
|
2217
1892
|
{
|
|
2218
1893
|
open: !!removeTarget,
|
|
2219
1894
|
onOpenChange: (open) => !open && setRemoveTarget(null),
|
|
2220
|
-
children: /* @__PURE__ */
|
|
2221
|
-
/* @__PURE__ */
|
|
2222
|
-
/* @__PURE__ */
|
|
2223
|
-
/* @__PURE__ */
|
|
1895
|
+
children: /* @__PURE__ */ jsxs4(AlertDialogContent2, { children: [
|
|
1896
|
+
/* @__PURE__ */ jsxs4(AlertDialogHeader2, { children: [
|
|
1897
|
+
/* @__PURE__ */ jsx5(AlertDialogTitle2, { children: "Remover objetivo?" }),
|
|
1898
|
+
/* @__PURE__ */ jsx5(AlertDialogDescription2, { children: "O objetivo ser\xE1 removido permanentemente." })
|
|
2224
1899
|
] }),
|
|
2225
|
-
/* @__PURE__ */
|
|
2226
|
-
/* @__PURE__ */
|
|
2227
|
-
/* @__PURE__ */
|
|
2228
|
-
|
|
1900
|
+
/* @__PURE__ */ jsxs4(AlertDialogFooter2, { children: [
|
|
1901
|
+
/* @__PURE__ */ jsx5(AlertDialogCancel2, { children: "Cancelar" }),
|
|
1902
|
+
/* @__PURE__ */ jsx5(
|
|
1903
|
+
AlertDialogAction2,
|
|
2229
1904
|
{
|
|
2230
1905
|
onClick: handleRemove,
|
|
2231
1906
|
disabled: deleteMutation.isPending,
|
|
@@ -2240,11 +1915,11 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
2240
1915
|
}
|
|
2241
1916
|
|
|
2242
1917
|
// src/components/agents/agent-prompt-editor.tsx
|
|
2243
|
-
import { useState as
|
|
2244
|
-
import { Button as
|
|
1918
|
+
import { useState as useState6, useRef, useCallback as useCallback3, useEffect as useEffect3 } from "react";
|
|
1919
|
+
import { Button as Button5, Input as Input5, Skeleton as Skeleton2, Badge as Badge3 } from "@greatapps/greatauth-ui/ui";
|
|
2245
1920
|
import { FileText, Loader2 as Loader23, ChevronDown, ChevronUp, RotateCcw } from "lucide-react";
|
|
2246
|
-
import { toast as
|
|
2247
|
-
import { jsx as
|
|
1921
|
+
import { toast as toast5 } from "sonner";
|
|
1922
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2248
1923
|
function formatDate(dateStr) {
|
|
2249
1924
|
const date = new Date(dateStr);
|
|
2250
1925
|
return date.toLocaleDateString("pt-BR", {
|
|
@@ -2317,12 +1992,12 @@ function AgentPromptEditor({ config, agent }) {
|
|
|
2317
1992
|
);
|
|
2318
1993
|
const currentVersion = sortedVersions.find((v) => v.is_current) || sortedVersions[0] || null;
|
|
2319
1994
|
const currentPromptContent = currentVersion?.prompt_content ?? "";
|
|
2320
|
-
const [trackedAgentId, setTrackedAgentId] =
|
|
2321
|
-
const [promptText, setPromptText] =
|
|
2322
|
-
const [promptInitialized, setPromptInitialized] =
|
|
2323
|
-
const [changeNotes, setChangeNotes] =
|
|
2324
|
-
const [showPreview, setShowPreview] =
|
|
2325
|
-
const [compareVersionId, setCompareVersionId] =
|
|
1995
|
+
const [trackedAgentId, setTrackedAgentId] = useState6(agent.id);
|
|
1996
|
+
const [promptText, setPromptText] = useState6(currentPromptContent);
|
|
1997
|
+
const [promptInitialized, setPromptInitialized] = useState6(false);
|
|
1998
|
+
const [changeNotes, setChangeNotes] = useState6("");
|
|
1999
|
+
const [showPreview, setShowPreview] = useState6(false);
|
|
2000
|
+
const [compareVersionId, setCompareVersionId] = useState6(null);
|
|
2326
2001
|
const textareaRef = useRef(null);
|
|
2327
2002
|
if (!promptInitialized && currentPromptContent && !isLoading) {
|
|
2328
2003
|
setPromptText(currentPromptContent);
|
|
@@ -2369,15 +2044,15 @@ function AgentPromptEditor({ config, agent }) {
|
|
|
2369
2044
|
try {
|
|
2370
2045
|
await updateAgent.mutateAsync({ id: agent.id, body });
|
|
2371
2046
|
setChangeNotes("");
|
|
2372
|
-
|
|
2047
|
+
toast5.success("Prompt salvo com sucesso");
|
|
2373
2048
|
} catch {
|
|
2374
|
-
|
|
2049
|
+
toast5.error("Erro ao salvar prompt");
|
|
2375
2050
|
}
|
|
2376
2051
|
}
|
|
2377
2052
|
function handleRestore(version) {
|
|
2378
2053
|
setPromptText(version.prompt_content ?? "");
|
|
2379
2054
|
setChangeNotes(`Restaurado da v${version.version_number}`);
|
|
2380
|
-
|
|
2055
|
+
toast5.info("Prompt restaurado no editor. Clique em Salvar para confirmar.");
|
|
2381
2056
|
}
|
|
2382
2057
|
const charCount = promptText.length;
|
|
2383
2058
|
const tokenEstimate = Math.ceil(charCount / 4);
|
|
@@ -2386,12 +2061,12 @@ function AgentPromptEditor({ config, agent }) {
|
|
|
2386
2061
|
const allTools = toolsData?.data || [];
|
|
2387
2062
|
const previewText = buildPreview(promptText, objectives, agentTools, allTools);
|
|
2388
2063
|
if (isLoading) {
|
|
2389
|
-
return /* @__PURE__ */
|
|
2064
|
+
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)) });
|
|
2390
2065
|
}
|
|
2391
|
-
return /* @__PURE__ */
|
|
2392
|
-
/* @__PURE__ */
|
|
2393
|
-
/* @__PURE__ */
|
|
2394
|
-
/* @__PURE__ */
|
|
2066
|
+
return /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-4 p-4 lg:flex-row", children: [
|
|
2067
|
+
/* @__PURE__ */ jsxs5("div", { className: "min-w-0 flex-1 space-y-4", children: [
|
|
2068
|
+
/* @__PURE__ */ jsxs5("div", { className: "space-y-2", children: [
|
|
2069
|
+
/* @__PURE__ */ jsx6(
|
|
2395
2070
|
"textarea",
|
|
2396
2071
|
{
|
|
2397
2072
|
ref: textareaRef,
|
|
@@ -2406,22 +2081,22 @@ function AgentPromptEditor({ config, agent }) {
|
|
|
2406
2081
|
style: { minHeight: "300px" }
|
|
2407
2082
|
}
|
|
2408
2083
|
),
|
|
2409
|
-
/* @__PURE__ */
|
|
2410
|
-
/* @__PURE__ */
|
|
2084
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-3 text-xs text-muted-foreground", children: [
|
|
2085
|
+
/* @__PURE__ */ jsxs5("span", { className: "tabular-nums", children: [
|
|
2411
2086
|
charCount.toLocaleString("pt-BR"),
|
|
2412
2087
|
" caracteres"
|
|
2413
2088
|
] }),
|
|
2414
|
-
/* @__PURE__ */
|
|
2415
|
-
/* @__PURE__ */
|
|
2089
|
+
/* @__PURE__ */ jsx6("span", { children: "\xB7" }),
|
|
2090
|
+
/* @__PURE__ */ jsxs5("span", { className: "tabular-nums", children: [
|
|
2416
2091
|
"~",
|
|
2417
2092
|
tokenEstimate.toLocaleString("pt-BR"),
|
|
2418
2093
|
" tokens"
|
|
2419
2094
|
] })
|
|
2420
2095
|
] })
|
|
2421
2096
|
] }),
|
|
2422
|
-
/* @__PURE__ */
|
|
2423
|
-
/* @__PURE__ */
|
|
2424
|
-
|
|
2097
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-3", children: [
|
|
2098
|
+
/* @__PURE__ */ jsx6(
|
|
2099
|
+
Input5,
|
|
2425
2100
|
{
|
|
2426
2101
|
"aria-label": "Notas da altera\xE7\xE3o",
|
|
2427
2102
|
name: "changeNotes",
|
|
@@ -2438,34 +2113,34 @@ function AgentPromptEditor({ config, agent }) {
|
|
|
2438
2113
|
}
|
|
2439
2114
|
}
|
|
2440
2115
|
),
|
|
2441
|
-
/* @__PURE__ */
|
|
2442
|
-
|
|
2116
|
+
/* @__PURE__ */ jsxs5(
|
|
2117
|
+
Button5,
|
|
2443
2118
|
{
|
|
2444
2119
|
onClick: handleSave,
|
|
2445
2120
|
disabled: updateAgent.isPending || !promptText.trim(),
|
|
2446
2121
|
children: [
|
|
2447
|
-
updateAgent.isPending && /* @__PURE__ */
|
|
2122
|
+
updateAgent.isPending && /* @__PURE__ */ jsx6(Loader23, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
2448
2123
|
"Salvar"
|
|
2449
2124
|
]
|
|
2450
2125
|
}
|
|
2451
2126
|
)
|
|
2452
2127
|
] }),
|
|
2453
|
-
/* @__PURE__ */
|
|
2454
|
-
/* @__PURE__ */
|
|
2128
|
+
/* @__PURE__ */ jsxs5("div", { className: "rounded-lg border", children: [
|
|
2129
|
+
/* @__PURE__ */ jsxs5(
|
|
2455
2130
|
"button",
|
|
2456
2131
|
{
|
|
2457
2132
|
type: "button",
|
|
2458
2133
|
onClick: () => setShowPreview((prev) => !prev),
|
|
2459
2134
|
className: "flex w-full items-center justify-between px-4 py-3 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors",
|
|
2460
2135
|
children: [
|
|
2461
|
-
/* @__PURE__ */
|
|
2462
|
-
showPreview ? /* @__PURE__ */
|
|
2136
|
+
/* @__PURE__ */ jsx6("span", { children: "Preview do prompt final" }),
|
|
2137
|
+
showPreview ? /* @__PURE__ */ jsx6(ChevronUp, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx6(ChevronDown, { className: "h-4 w-4" })
|
|
2463
2138
|
]
|
|
2464
2139
|
}
|
|
2465
2140
|
),
|
|
2466
|
-
showPreview && /* @__PURE__ */
|
|
2141
|
+
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) => {
|
|
2467
2142
|
const isSection = line.startsWith("[SKILLS DISPON\xCDVEIS]") || line.startsWith("[TOOLS DISPON\xCDVEIS]");
|
|
2468
|
-
return /* @__PURE__ */
|
|
2143
|
+
return /* @__PURE__ */ jsxs5(
|
|
2469
2144
|
"span",
|
|
2470
2145
|
{
|
|
2471
2146
|
className: isSection ? "font-semibold text-muted-foreground" : "",
|
|
@@ -2478,17 +2153,17 @@ function AgentPromptEditor({ config, agent }) {
|
|
|
2478
2153
|
);
|
|
2479
2154
|
}) }) })
|
|
2480
2155
|
] }),
|
|
2481
|
-
diffLines && compareVersion && currentVersion && /* @__PURE__ */
|
|
2482
|
-
/* @__PURE__ */
|
|
2483
|
-
/* @__PURE__ */
|
|
2156
|
+
diffLines && compareVersion && currentVersion && /* @__PURE__ */ jsxs5("div", { children: [
|
|
2157
|
+
/* @__PURE__ */ jsxs5("div", { className: "mb-2 flex items-center justify-between", children: [
|
|
2158
|
+
/* @__PURE__ */ jsxs5("h3", { className: "text-sm font-medium text-muted-foreground", children: [
|
|
2484
2159
|
"Diferen\xE7as: v",
|
|
2485
2160
|
compareVersion.version_number,
|
|
2486
2161
|
" \u2192 v",
|
|
2487
2162
|
currentVersion.version_number,
|
|
2488
2163
|
" (actual)"
|
|
2489
2164
|
] }),
|
|
2490
|
-
/* @__PURE__ */
|
|
2491
|
-
|
|
2165
|
+
/* @__PURE__ */ jsx6(
|
|
2166
|
+
Button5,
|
|
2492
2167
|
{
|
|
2493
2168
|
variant: "ghost",
|
|
2494
2169
|
size: "sm",
|
|
@@ -2498,12 +2173,12 @@ function AgentPromptEditor({ config, agent }) {
|
|
|
2498
2173
|
}
|
|
2499
2174
|
)
|
|
2500
2175
|
] }),
|
|
2501
|
-
/* @__PURE__ */
|
|
2176
|
+
/* @__PURE__ */ jsx6("div", { className: "max-h-64 overflow-auto rounded-lg border font-mono text-sm", children: diffLines.map((line, i) => /* @__PURE__ */ jsxs5(
|
|
2502
2177
|
"div",
|
|
2503
2178
|
{
|
|
2504
2179
|
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" : ""}`,
|
|
2505
2180
|
children: [
|
|
2506
|
-
/* @__PURE__ */
|
|
2181
|
+
/* @__PURE__ */ jsx6("span", { className: "mr-2 inline-block w-4 select-none text-muted-foreground", children: line.type === "added" ? "+" : line.type === "removed" ? "-" : " " }),
|
|
2507
2182
|
line.line || " "
|
|
2508
2183
|
]
|
|
2509
2184
|
},
|
|
@@ -2511,57 +2186,57 @@ function AgentPromptEditor({ config, agent }) {
|
|
|
2511
2186
|
)) })
|
|
2512
2187
|
] })
|
|
2513
2188
|
] }),
|
|
2514
|
-
/* @__PURE__ */
|
|
2515
|
-
/* @__PURE__ */
|
|
2516
|
-
sortedVersions.length === 0 ? /* @__PURE__ */
|
|
2517
|
-
/* @__PURE__ */
|
|
2518
|
-
/* @__PURE__ */
|
|
2519
|
-
] }) : /* @__PURE__ */
|
|
2189
|
+
/* @__PURE__ */ jsxs5("div", { className: "w-full space-y-2 lg:w-80 lg:shrink-0", children: [
|
|
2190
|
+
/* @__PURE__ */ jsx6("h3", { className: "text-sm font-medium text-muted-foreground", children: "Hist\xF3rico de Vers\xF5es" }),
|
|
2191
|
+
sortedVersions.length === 0 ? /* @__PURE__ */ jsxs5("div", { className: "flex flex-col items-center justify-center rounded-lg border border-dashed p-8 text-center", children: [
|
|
2192
|
+
/* @__PURE__ */ jsx6(FileText, { className: "mb-2 h-8 w-8 text-muted-foreground" }),
|
|
2193
|
+
/* @__PURE__ */ jsx6("p", { className: "text-sm text-muted-foreground", children: "Nenhuma vers\xE3o encontrada. Salve o prompt para criar a primeira vers\xE3o." })
|
|
2194
|
+
] }) : /* @__PURE__ */ jsx6("div", { className: "space-y-1", children: sortedVersions.map((version, idx) => {
|
|
2520
2195
|
const isCurrent = idx === 0;
|
|
2521
2196
|
const isComparing = version.id === compareVersionId;
|
|
2522
|
-
return /* @__PURE__ */
|
|
2197
|
+
return /* @__PURE__ */ jsxs5(
|
|
2523
2198
|
"div",
|
|
2524
2199
|
{
|
|
2525
2200
|
className: `rounded-lg border p-3 transition-colors ${isCurrent ? "border-primary bg-primary/5" : isComparing ? "border-muted-foreground/30 bg-muted/50" : ""}`,
|
|
2526
2201
|
children: [
|
|
2527
|
-
/* @__PURE__ */
|
|
2528
|
-
/* @__PURE__ */
|
|
2202
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between gap-2", children: [
|
|
2203
|
+
/* @__PURE__ */ jsxs5("span", { className: "text-sm font-medium", children: [
|
|
2529
2204
|
"v",
|
|
2530
2205
|
version.version_number
|
|
2531
2206
|
] }),
|
|
2532
|
-
isCurrent && /* @__PURE__ */
|
|
2207
|
+
isCurrent && /* @__PURE__ */ jsx6(Badge3, { variant: "default", className: "text-[10px] px-1.5 py-0", children: "Actual" })
|
|
2533
2208
|
] }),
|
|
2534
|
-
/* @__PURE__ */
|
|
2535
|
-
/* @__PURE__ */
|
|
2536
|
-
/* @__PURE__ */
|
|
2209
|
+
/* @__PURE__ */ jsx6("div", { className: "mt-1 text-xs text-muted-foreground", children: formatDate(version.datetime_add) }),
|
|
2210
|
+
/* @__PURE__ */ jsxs5("div", { className: "mt-1 flex items-center gap-2 text-xs text-muted-foreground", children: [
|
|
2211
|
+
/* @__PURE__ */ jsxs5("span", { children: [
|
|
2537
2212
|
(version.prompt_content ?? "").length,
|
|
2538
2213
|
" chars"
|
|
2539
2214
|
] }),
|
|
2540
|
-
/* @__PURE__ */
|
|
2541
|
-
/* @__PURE__ */
|
|
2215
|
+
/* @__PURE__ */ jsx6("span", { children: "\xB7" }),
|
|
2216
|
+
/* @__PURE__ */ jsx6("span", { className: "truncate font-mono", children: (version.prompt_hash ?? "").slice(0, 8) })
|
|
2542
2217
|
] }),
|
|
2543
|
-
version.change_notes && /* @__PURE__ */
|
|
2544
|
-
!isCurrent && /* @__PURE__ */
|
|
2545
|
-
/* @__PURE__ */
|
|
2218
|
+
version.change_notes && /* @__PURE__ */ jsx6("div", { className: "mt-1.5 text-xs italic text-muted-foreground", children: version.change_notes }),
|
|
2219
|
+
!isCurrent && /* @__PURE__ */ jsxs5("div", { className: "mt-2 flex items-center gap-3", children: [
|
|
2220
|
+
/* @__PURE__ */ jsxs5(
|
|
2546
2221
|
"button",
|
|
2547
2222
|
{
|
|
2548
2223
|
type: "button",
|
|
2549
2224
|
onClick: () => setCompareVersionId(isComparing ? null : version.id),
|
|
2550
2225
|
className: "flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",
|
|
2551
2226
|
children: [
|
|
2552
|
-
/* @__PURE__ */
|
|
2227
|
+
/* @__PURE__ */ jsx6(FileText, { "aria-hidden": "true", className: "h-3 w-3" }),
|
|
2553
2228
|
isComparing ? "Ocultar diff" : "Comparar"
|
|
2554
2229
|
]
|
|
2555
2230
|
}
|
|
2556
2231
|
),
|
|
2557
|
-
/* @__PURE__ */
|
|
2232
|
+
/* @__PURE__ */ jsxs5(
|
|
2558
2233
|
"button",
|
|
2559
2234
|
{
|
|
2560
2235
|
type: "button",
|
|
2561
2236
|
onClick: () => handleRestore(version),
|
|
2562
2237
|
className: "flex items-center gap-1 text-xs text-primary hover:underline",
|
|
2563
2238
|
children: [
|
|
2564
|
-
/* @__PURE__ */
|
|
2239
|
+
/* @__PURE__ */ jsx6(RotateCcw, { "aria-hidden": "true", className: "h-3 w-3" }),
|
|
2565
2240
|
"Restaurar"
|
|
2566
2241
|
]
|
|
2567
2242
|
}
|
|
@@ -2577,7 +2252,7 @@ function AgentPromptEditor({ config, agent }) {
|
|
|
2577
2252
|
}
|
|
2578
2253
|
|
|
2579
2254
|
// src/components/conversations/agent-conversations-table.tsx
|
|
2580
|
-
import { useState as
|
|
2255
|
+
import { useState as useState7 } from "react";
|
|
2581
2256
|
import {
|
|
2582
2257
|
Table,
|
|
2583
2258
|
TableBody,
|
|
@@ -2585,15 +2260,15 @@ import {
|
|
|
2585
2260
|
TableHead,
|
|
2586
2261
|
TableHeader,
|
|
2587
2262
|
TableRow,
|
|
2588
|
-
Skeleton as
|
|
2589
|
-
Badge as
|
|
2263
|
+
Skeleton as Skeleton4,
|
|
2264
|
+
Badge as Badge4
|
|
2590
2265
|
} from "@greatapps/greatauth-ui/ui";
|
|
2591
2266
|
import { MessageCircle, ExternalLink } from "lucide-react";
|
|
2592
2267
|
|
|
2593
2268
|
// src/components/conversations/conversation-view.tsx
|
|
2594
|
-
import { Skeleton as
|
|
2269
|
+
import { Skeleton as Skeleton3, Button as Button6 } from "@greatapps/greatauth-ui/ui";
|
|
2595
2270
|
import { X, MessageSquare } from "lucide-react";
|
|
2596
|
-
import { jsx as
|
|
2271
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2597
2272
|
function formatDateTime(dateStr) {
|
|
2598
2273
|
if (!dateStr) return "\u2014";
|
|
2599
2274
|
return new Date(dateStr).toLocaleString("pt-BR");
|
|
@@ -2607,68 +2282,68 @@ function ConversationView({
|
|
|
2607
2282
|
}) {
|
|
2608
2283
|
const { data: conversation, isLoading } = useConversation(config, conversationId);
|
|
2609
2284
|
if (isLoading) {
|
|
2610
|
-
return /* @__PURE__ */
|
|
2611
|
-
/* @__PURE__ */
|
|
2612
|
-
/* @__PURE__ */
|
|
2285
|
+
return /* @__PURE__ */ jsxs6("div", { className: "rounded-lg border bg-card p-4 space-y-3", children: [
|
|
2286
|
+
/* @__PURE__ */ jsx7(Skeleton3, { className: "h-6 w-48" }),
|
|
2287
|
+
/* @__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)) })
|
|
2613
2288
|
] });
|
|
2614
2289
|
}
|
|
2615
2290
|
if (!conversation) {
|
|
2616
|
-
return /* @__PURE__ */
|
|
2617
|
-
/* @__PURE__ */
|
|
2618
|
-
/* @__PURE__ */
|
|
2291
|
+
return /* @__PURE__ */ jsx7("div", { className: "rounded-lg border bg-card p-4", children: /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between", children: [
|
|
2292
|
+
/* @__PURE__ */ jsx7("p", { className: "text-sm text-muted-foreground", children: "Conversa n\xE3o encontrada." }),
|
|
2293
|
+
/* @__PURE__ */ jsx7(Button6, { variant: "ghost", size: "icon", "aria-label": "Fechar", onClick: onClose, children: /* @__PURE__ */ jsx7(X, { className: "h-4 w-4" }) })
|
|
2619
2294
|
] }) });
|
|
2620
2295
|
}
|
|
2621
|
-
return /* @__PURE__ */
|
|
2622
|
-
/* @__PURE__ */
|
|
2623
|
-
/* @__PURE__ */
|
|
2296
|
+
return /* @__PURE__ */ jsxs6("div", { className: "rounded-lg border bg-card p-4 space-y-4", children: [
|
|
2297
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between", children: [
|
|
2298
|
+
/* @__PURE__ */ jsxs6("h3", { className: "font-semibold", children: [
|
|
2624
2299
|
"Detalhes da conversa #",
|
|
2625
2300
|
conversation.id
|
|
2626
2301
|
] }),
|
|
2627
|
-
/* @__PURE__ */
|
|
2302
|
+
/* @__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" }) }) })
|
|
2628
2303
|
] }),
|
|
2629
|
-
conversation.id_external ? renderChatLink ? renderChatLink(conversation.id_external) : /* @__PURE__ */
|
|
2630
|
-
/* @__PURE__ */
|
|
2304
|
+
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: [
|
|
2305
|
+
/* @__PURE__ */ jsx7(MessageSquare, { className: "mr-2 h-4 w-4" }),
|
|
2631
2306
|
"Ver no Chat"
|
|
2632
2307
|
] }) }) : null,
|
|
2633
|
-
/* @__PURE__ */
|
|
2634
|
-
/* @__PURE__ */
|
|
2635
|
-
/* @__PURE__ */
|
|
2636
|
-
/* @__PURE__ */
|
|
2308
|
+
/* @__PURE__ */ jsxs6("div", { className: "grid grid-cols-2 gap-x-6 gap-y-3 text-sm", children: [
|
|
2309
|
+
/* @__PURE__ */ jsxs6("div", { children: [
|
|
2310
|
+
/* @__PURE__ */ jsx7("span", { className: "text-muted-foreground", children: "Thread ID" }),
|
|
2311
|
+
/* @__PURE__ */ jsx7("p", { className: "font-mono text-xs mt-0.5", children: conversation.openai_thread_id || "\u2014" })
|
|
2637
2312
|
] }),
|
|
2638
|
-
/* @__PURE__ */
|
|
2639
|
-
/* @__PURE__ */
|
|
2640
|
-
/* @__PURE__ */
|
|
2313
|
+
/* @__PURE__ */ jsxs6("div", { children: [
|
|
2314
|
+
/* @__PURE__ */ jsx7("span", { className: "text-muted-foreground", children: "Contato" }),
|
|
2315
|
+
/* @__PURE__ */ jsx7("p", { className: "mt-0.5", children: contactsMap?.get(conversation.id_contact) ?? conversation.id_contact })
|
|
2641
2316
|
] }),
|
|
2642
|
-
/* @__PURE__ */
|
|
2643
|
-
/* @__PURE__ */
|
|
2644
|
-
/* @__PURE__ */
|
|
2317
|
+
/* @__PURE__ */ jsxs6("div", { children: [
|
|
2318
|
+
/* @__PURE__ */ jsx7("span", { className: "text-muted-foreground", children: "Agente" }),
|
|
2319
|
+
/* @__PURE__ */ jsx7("p", { className: "mt-0.5", children: conversation.id_agent ?? "\u2014" })
|
|
2645
2320
|
] }),
|
|
2646
|
-
/* @__PURE__ */
|
|
2647
|
-
/* @__PURE__ */
|
|
2648
|
-
/* @__PURE__ */
|
|
2321
|
+
/* @__PURE__ */ jsxs6("div", { children: [
|
|
2322
|
+
/* @__PURE__ */ jsx7("span", { className: "text-muted-foreground", children: "Mensagens" }),
|
|
2323
|
+
/* @__PURE__ */ jsx7("p", { className: "mt-0.5", children: conversation.message_count ?? "\u2014" })
|
|
2649
2324
|
] }),
|
|
2650
|
-
/* @__PURE__ */
|
|
2651
|
-
/* @__PURE__ */
|
|
2652
|
-
/* @__PURE__ */
|
|
2325
|
+
/* @__PURE__ */ jsxs6("div", { children: [
|
|
2326
|
+
/* @__PURE__ */ jsx7("span", { className: "text-muted-foreground", children: "Tokens" }),
|
|
2327
|
+
/* @__PURE__ */ jsx7("p", { className: "mt-0.5", children: conversation.usage_tokens ?? "\u2014" })
|
|
2653
2328
|
] }),
|
|
2654
|
-
/* @__PURE__ */
|
|
2655
|
-
/* @__PURE__ */
|
|
2656
|
-
/* @__PURE__ */
|
|
2329
|
+
/* @__PURE__ */ jsxs6("div", { children: [
|
|
2330
|
+
/* @__PURE__ */ jsx7("span", { className: "text-muted-foreground", children: "Rota\xE7\xF5es de Thread" }),
|
|
2331
|
+
/* @__PURE__ */ jsx7("p", { className: "mt-0.5", children: conversation.rotation_count ?? "\u2014" })
|
|
2657
2332
|
] }),
|
|
2658
|
-
/* @__PURE__ */
|
|
2659
|
-
/* @__PURE__ */
|
|
2660
|
-
/* @__PURE__ */
|
|
2333
|
+
/* @__PURE__ */ jsxs6("div", { children: [
|
|
2334
|
+
/* @__PURE__ */ jsx7("span", { className: "text-muted-foreground", children: "Criado em" }),
|
|
2335
|
+
/* @__PURE__ */ jsx7("p", { className: "mt-0.5", children: formatDateTime(conversation.datetime_add) })
|
|
2661
2336
|
] }),
|
|
2662
|
-
/* @__PURE__ */
|
|
2663
|
-
/* @__PURE__ */
|
|
2664
|
-
/* @__PURE__ */
|
|
2337
|
+
/* @__PURE__ */ jsxs6("div", { children: [
|
|
2338
|
+
/* @__PURE__ */ jsx7("span", { className: "text-muted-foreground", children: "Atualizado em" }),
|
|
2339
|
+
/* @__PURE__ */ jsx7("p", { className: "mt-0.5", children: formatDateTime(conversation.datetime_alt) })
|
|
2665
2340
|
] })
|
|
2666
2341
|
] })
|
|
2667
2342
|
] });
|
|
2668
2343
|
}
|
|
2669
2344
|
|
|
2670
2345
|
// src/components/conversations/agent-conversations-table.tsx
|
|
2671
|
-
import { jsx as
|
|
2346
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2672
2347
|
function formatRelativeDate(dateStr) {
|
|
2673
2348
|
if (!dateStr) return "\u2014";
|
|
2674
2349
|
const date = new Date(dateStr);
|
|
@@ -2691,29 +2366,29 @@ function AgentConversationsTable({
|
|
|
2691
2366
|
config,
|
|
2692
2367
|
renderChatLink
|
|
2693
2368
|
}) {
|
|
2694
|
-
const [selectedId, setSelectedId] =
|
|
2369
|
+
const [selectedId, setSelectedId] = useState7(null);
|
|
2695
2370
|
if (isLoading) {
|
|
2696
|
-
return /* @__PURE__ */
|
|
2371
|
+
return /* @__PURE__ */ jsx8("div", { className: "space-y-3", children: Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ jsx8(Skeleton4, { className: "h-12 w-full" }, i)) });
|
|
2697
2372
|
}
|
|
2698
2373
|
if (conversations.length === 0) {
|
|
2699
|
-
return /* @__PURE__ */
|
|
2700
|
-
/* @__PURE__ */
|
|
2701
|
-
/* @__PURE__ */
|
|
2374
|
+
return /* @__PURE__ */ jsxs7("div", { className: "flex flex-col items-center justify-center rounded-lg border border-dashed p-8 text-center", children: [
|
|
2375
|
+
/* @__PURE__ */ jsx8(MessageCircle, { className: "mb-2 h-8 w-8 text-muted-foreground" }),
|
|
2376
|
+
/* @__PURE__ */ jsx8("p", { className: "text-sm text-muted-foreground", children: "Nenhuma conversa encontrada." })
|
|
2702
2377
|
] });
|
|
2703
2378
|
}
|
|
2704
|
-
return /* @__PURE__ */
|
|
2705
|
-
/* @__PURE__ */
|
|
2706
|
-
/* @__PURE__ */
|
|
2707
|
-
/* @__PURE__ */
|
|
2708
|
-
/* @__PURE__ */
|
|
2709
|
-
/* @__PURE__ */
|
|
2710
|
-
/* @__PURE__ */
|
|
2711
|
-
/* @__PURE__ */
|
|
2712
|
-
/* @__PURE__ */
|
|
2713
|
-
/* @__PURE__ */
|
|
2714
|
-
/* @__PURE__ */
|
|
2379
|
+
return /* @__PURE__ */ jsxs7("div", { className: "space-y-4", children: [
|
|
2380
|
+
/* @__PURE__ */ jsxs7(Table, { children: [
|
|
2381
|
+
/* @__PURE__ */ jsx8(TableHeader, { children: /* @__PURE__ */ jsxs7(TableRow, { children: [
|
|
2382
|
+
/* @__PURE__ */ jsx8(TableHead, { children: "ID" }),
|
|
2383
|
+
/* @__PURE__ */ jsx8(TableHead, { children: "Contato" }),
|
|
2384
|
+
/* @__PURE__ */ jsx8(TableHead, { children: "Objetivo" }),
|
|
2385
|
+
/* @__PURE__ */ jsx8(TableHead, { className: "text-right", children: "Mensagens" }),
|
|
2386
|
+
/* @__PURE__ */ jsx8(TableHead, { className: "text-right", children: "Tokens" }),
|
|
2387
|
+
/* @__PURE__ */ jsx8(TableHead, { children: "Criado em" }),
|
|
2388
|
+
/* @__PURE__ */ jsx8(TableHead, { children: "Atualizado em" }),
|
|
2389
|
+
/* @__PURE__ */ jsx8(TableHead, { className: "w-10" })
|
|
2715
2390
|
] }) }),
|
|
2716
|
-
/* @__PURE__ */
|
|
2391
|
+
/* @__PURE__ */ jsx8(TableBody, { children: conversations.map((conversation) => /* @__PURE__ */ jsxs7(
|
|
2717
2392
|
TableRow,
|
|
2718
2393
|
{
|
|
2719
2394
|
className: "cursor-pointer",
|
|
@@ -2732,14 +2407,14 @@ function AgentConversationsTable({
|
|
|
2732
2407
|
},
|
|
2733
2408
|
"data-state": selectedId === conversation.id ? "selected" : void 0,
|
|
2734
2409
|
children: [
|
|
2735
|
-
/* @__PURE__ */
|
|
2736
|
-
/* @__PURE__ */
|
|
2737
|
-
/* @__PURE__ */
|
|
2738
|
-
/* @__PURE__ */
|
|
2739
|
-
/* @__PURE__ */
|
|
2740
|
-
/* @__PURE__ */
|
|
2741
|
-
/* @__PURE__ */
|
|
2742
|
-
/* @__PURE__ */
|
|
2410
|
+
/* @__PURE__ */ jsx8(TableCell, { className: "font-mono text-xs", children: conversation.id }),
|
|
2411
|
+
/* @__PURE__ */ jsx8(TableCell, { children: contactsMap?.get(conversation.id_contact) ?? conversation.id_contact }),
|
|
2412
|
+
/* @__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" }) }),
|
|
2413
|
+
/* @__PURE__ */ jsx8(TableCell, { className: "text-right tabular-nums", children: conversation.message_count ?? "\u2014" }),
|
|
2414
|
+
/* @__PURE__ */ jsx8(TableCell, { className: "text-right tabular-nums", children: conversation.usage_tokens ?? "\u2014" }),
|
|
2415
|
+
/* @__PURE__ */ jsx8(TableCell, { children: new Date(conversation.datetime_add).toLocaleDateString("pt-BR") }),
|
|
2416
|
+
/* @__PURE__ */ jsx8(TableCell, { children: formatRelativeDate(conversation.datetime_alt) }),
|
|
2417
|
+
/* @__PURE__ */ jsx8(TableCell, { children: conversation.id_external ? renderChatLink ? /* @__PURE__ */ jsx8("span", { onClick: (e) => e.stopPropagation(), children: renderChatLink(conversation.id_external) }) : /* @__PURE__ */ jsx8(
|
|
2743
2418
|
"a",
|
|
2744
2419
|
{
|
|
2745
2420
|
href: `/gchat/inbox/${conversation.id_external}`,
|
|
@@ -2747,7 +2422,7 @@ function AgentConversationsTable({
|
|
|
2747
2422
|
"aria-label": "Ver no Chat",
|
|
2748
2423
|
onClick: (e) => e.stopPropagation(),
|
|
2749
2424
|
className: "inline-flex items-center justify-center rounded-md p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",
|
|
2750
|
-
children: /* @__PURE__ */
|
|
2425
|
+
children: /* @__PURE__ */ jsx8(ExternalLink, { className: "h-4 w-4" })
|
|
2751
2426
|
}
|
|
2752
2427
|
) : null })
|
|
2753
2428
|
]
|
|
@@ -2755,7 +2430,7 @@ function AgentConversationsTable({
|
|
|
2755
2430
|
conversation.id
|
|
2756
2431
|
)) })
|
|
2757
2432
|
] }),
|
|
2758
|
-
selectedId && /* @__PURE__ */
|
|
2433
|
+
selectedId && /* @__PURE__ */ jsx8(
|
|
2759
2434
|
ConversationView,
|
|
2760
2435
|
{
|
|
2761
2436
|
conversationId: selectedId,
|
|
@@ -2769,7 +2444,7 @@ function AgentConversationsTable({
|
|
|
2769
2444
|
}
|
|
2770
2445
|
|
|
2771
2446
|
// src/components/conversations/agent-conversations-panel.tsx
|
|
2772
|
-
import { jsx as
|
|
2447
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
2773
2448
|
function AgentConversationsPanel({
|
|
2774
2449
|
agent,
|
|
2775
2450
|
config,
|
|
@@ -2788,7 +2463,7 @@ function AgentConversationsPanel({
|
|
|
2788
2463
|
const objectivesMap = new Map(
|
|
2789
2464
|
(objectivesData?.data || []).map((o) => [o.id, o.title])
|
|
2790
2465
|
);
|
|
2791
|
-
return /* @__PURE__ */
|
|
2466
|
+
return /* @__PURE__ */ jsx9("div", { className: "p-4", children: /* @__PURE__ */ jsx9(
|
|
2792
2467
|
AgentConversationsTable,
|
|
2793
2468
|
{
|
|
2794
2469
|
conversations,
|
|
@@ -2802,27 +2477,27 @@ function AgentConversationsPanel({
|
|
|
2802
2477
|
}
|
|
2803
2478
|
|
|
2804
2479
|
// src/pages/agent-capabilities-page.tsx
|
|
2805
|
-
import { useState as
|
|
2480
|
+
import { useState as useState14, useCallback as useCallback6 } from "react";
|
|
2806
2481
|
import {
|
|
2807
2482
|
Tabs,
|
|
2808
2483
|
TabsList,
|
|
2809
2484
|
TabsTrigger,
|
|
2810
2485
|
TabsContent
|
|
2811
2486
|
} from "@greatapps/greatauth-ui/ui";
|
|
2812
|
-
import { Blocks, Plug as Plug3, Settings as
|
|
2487
|
+
import { Blocks, Plug as Plug3, Settings as Settings3 } from "lucide-react";
|
|
2813
2488
|
|
|
2814
2489
|
// src/components/capabilities/capabilities-tab.tsx
|
|
2815
|
-
import { useState as
|
|
2490
|
+
import { useState as useState8, useCallback as useCallback4, useRef as useRef2, useEffect as useEffect4, useMemo as useMemo5 } from "react";
|
|
2816
2491
|
import {
|
|
2817
2492
|
Accordion,
|
|
2818
2493
|
AccordionItem,
|
|
2819
2494
|
AccordionTrigger,
|
|
2820
2495
|
AccordionContent,
|
|
2821
|
-
Switch as
|
|
2496
|
+
Switch as Switch4,
|
|
2822
2497
|
Checkbox,
|
|
2823
|
-
Badge as
|
|
2824
|
-
Button as
|
|
2825
|
-
Skeleton as
|
|
2498
|
+
Badge as Badge5,
|
|
2499
|
+
Button as Button7,
|
|
2500
|
+
Skeleton as Skeleton5
|
|
2826
2501
|
} from "@greatapps/greatauth-ui/ui";
|
|
2827
2502
|
import {
|
|
2828
2503
|
Calendar,
|
|
@@ -2832,8 +2507,8 @@ import {
|
|
|
2832
2507
|
Package,
|
|
2833
2508
|
ChevronDown as ChevronDown2
|
|
2834
2509
|
} from "lucide-react";
|
|
2835
|
-
import { toast as
|
|
2836
|
-
import { jsx as
|
|
2510
|
+
import { toast as toast6 } from "sonner";
|
|
2511
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2837
2512
|
var OPERATION_LABELS = {
|
|
2838
2513
|
list: "Listar",
|
|
2839
2514
|
view: "Visualizar",
|
|
@@ -2888,9 +2563,9 @@ function CapabilitiesTab({ config, agentId }) {
|
|
|
2888
2563
|
const { data: registry, isLoading: isLoadingRegistry } = useCapabilities(config);
|
|
2889
2564
|
const { data: agentCaps, isLoading: isLoadingAgent } = useAgentCapabilities(config, agentId);
|
|
2890
2565
|
const updateMutation = useUpdateAgentCapabilities(config);
|
|
2891
|
-
const [localState, setLocalState] =
|
|
2892
|
-
const [serverState, setServerState] =
|
|
2893
|
-
const [initialized, setInitialized] =
|
|
2566
|
+
const [localState, setLocalState] = useState8(/* @__PURE__ */ new Map());
|
|
2567
|
+
const [serverState, setServerState] = useState8(/* @__PURE__ */ new Map());
|
|
2568
|
+
const [initialized, setInitialized] = useState8(false);
|
|
2894
2569
|
const debounceRef = useRef2(null);
|
|
2895
2570
|
useEffect4(() => {
|
|
2896
2571
|
if (agentCaps && !initialized) {
|
|
@@ -2917,11 +2592,11 @@ function CapabilitiesTab({ config, agentId }) {
|
|
|
2917
2592
|
{
|
|
2918
2593
|
onSuccess: () => {
|
|
2919
2594
|
setServerState(cloneState(nextState));
|
|
2920
|
-
|
|
2595
|
+
toast6.success("Capacidades salvas");
|
|
2921
2596
|
},
|
|
2922
2597
|
onError: () => {
|
|
2923
2598
|
setLocalState(cloneState(serverState));
|
|
2924
|
-
|
|
2599
|
+
toast6.error("Erro ao salvar capacidades");
|
|
2925
2600
|
}
|
|
2926
2601
|
}
|
|
2927
2602
|
);
|
|
@@ -3000,11 +2675,11 @@ function CapabilitiesTab({ config, agentId }) {
|
|
|
3000
2675
|
{
|
|
3001
2676
|
onSuccess: () => {
|
|
3002
2677
|
setServerState(cloneState(localState));
|
|
3003
|
-
|
|
2678
|
+
toast6.success("Capacidades salvas");
|
|
3004
2679
|
},
|
|
3005
2680
|
onError: () => {
|
|
3006
2681
|
setLocalState(cloneState(serverState));
|
|
3007
|
-
|
|
2682
|
+
toast6.error("Erro ao salvar capacidades");
|
|
3008
2683
|
}
|
|
3009
2684
|
}
|
|
3010
2685
|
);
|
|
@@ -3013,51 +2688,51 @@ function CapabilitiesTab({ config, agentId }) {
|
|
|
3013
2688
|
return cat.modules.filter((m) => (localState.get(m.slug)?.size ?? 0) > 0).length;
|
|
3014
2689
|
}
|
|
3015
2690
|
if (isLoadingRegistry || isLoadingAgent) {
|
|
3016
|
-
return /* @__PURE__ */
|
|
2691
|
+
return /* @__PURE__ */ jsx10("div", { className: "space-y-3", children: [1, 2, 3, 4].map((i) => /* @__PURE__ */ jsx10(Skeleton5, { className: "h-14 w-full" }, i)) });
|
|
3017
2692
|
}
|
|
3018
2693
|
if (!registry || !registry.categories.length) {
|
|
3019
|
-
return /* @__PURE__ */
|
|
3020
|
-
/* @__PURE__ */
|
|
3021
|
-
/* @__PURE__ */
|
|
3022
|
-
/* @__PURE__ */
|
|
2694
|
+
return /* @__PURE__ */ jsxs8("div", { className: "flex flex-col items-center justify-center py-12 text-center", children: [
|
|
2695
|
+
/* @__PURE__ */ jsx10(Package, { className: "h-12 w-12 text-muted-foreground mb-3" }),
|
|
2696
|
+
/* @__PURE__ */ jsx10("h3", { className: "text-base font-medium", children: "Nenhuma capacidade dispon\xEDvel" }),
|
|
2697
|
+
/* @__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." })
|
|
3023
2698
|
] });
|
|
3024
2699
|
}
|
|
3025
|
-
return /* @__PURE__ */
|
|
3026
|
-
/* @__PURE__ */
|
|
3027
|
-
/* @__PURE__ */
|
|
3028
|
-
/* @__PURE__ */
|
|
3029
|
-
/* @__PURE__ */
|
|
2700
|
+
return /* @__PURE__ */ jsxs8("div", { className: "space-y-4", children: [
|
|
2701
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between", children: [
|
|
2702
|
+
/* @__PURE__ */ jsxs8("div", { children: [
|
|
2703
|
+
/* @__PURE__ */ jsx10("h3", { className: "text-sm font-medium", children: "Capacidades do agente" }),
|
|
2704
|
+
/* @__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." })
|
|
3030
2705
|
] }),
|
|
3031
|
-
/* @__PURE__ */
|
|
3032
|
-
/* @__PURE__ */
|
|
3033
|
-
/* @__PURE__ */
|
|
2706
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-2", children: [
|
|
2707
|
+
/* @__PURE__ */ jsx10(Button7, { variant: "outline", size: "sm", onClick: enableAll, children: "Ativar tudo" }),
|
|
2708
|
+
/* @__PURE__ */ jsx10(Button7, { variant: "outline", size: "sm", onClick: disableAll, children: "Desativar tudo" })
|
|
3034
2709
|
] })
|
|
3035
2710
|
] }),
|
|
3036
|
-
/* @__PURE__ */
|
|
2711
|
+
/* @__PURE__ */ jsx10(Accordion, { type: "multiple", className: "space-y-2", children: registry.categories.map((cat) => {
|
|
3037
2712
|
const Icon = getCategoryIcon(cat.slug);
|
|
3038
2713
|
const activeCount = countActiveModules(cat);
|
|
3039
2714
|
const totalModules = cat.modules.length;
|
|
3040
|
-
return /* @__PURE__ */
|
|
2715
|
+
return /* @__PURE__ */ jsxs8(
|
|
3041
2716
|
AccordionItem,
|
|
3042
2717
|
{
|
|
3043
2718
|
value: cat.slug,
|
|
3044
2719
|
className: "border rounded-lg px-4",
|
|
3045
2720
|
children: [
|
|
3046
|
-
/* @__PURE__ */
|
|
3047
|
-
/* @__PURE__ */
|
|
3048
|
-
/* @__PURE__ */
|
|
3049
|
-
/* @__PURE__ */
|
|
2721
|
+
/* @__PURE__ */ jsx10(AccordionTrigger, { className: "hover:no-underline py-3", children: /* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-3 flex-1", children: [
|
|
2722
|
+
/* @__PURE__ */ jsx10(Icon, { className: "h-4 w-4 text-muted-foreground" }),
|
|
2723
|
+
/* @__PURE__ */ jsx10("span", { className: "font-medium text-sm", children: cat.label }),
|
|
2724
|
+
/* @__PURE__ */ jsxs8(Badge5, { variant: "secondary", className: "text-xs", children: [
|
|
3050
2725
|
activeCount,
|
|
3051
2726
|
" de ",
|
|
3052
2727
|
totalModules,
|
|
3053
2728
|
" m\xF3dulos ativos"
|
|
3054
2729
|
] })
|
|
3055
2730
|
] }) }),
|
|
3056
|
-
/* @__PURE__ */
|
|
2731
|
+
/* @__PURE__ */ jsx10(AccordionContent, { className: "pb-3 !h-auto", children: /* @__PURE__ */ jsx10("div", { className: "space-y-1", children: cat.modules.map((mod) => {
|
|
3057
2732
|
const enabledOps = localState.get(mod.slug);
|
|
3058
2733
|
const isModuleOn = (enabledOps?.size ?? 0) > 0;
|
|
3059
2734
|
const allOpsEnabled = enabledOps?.size === mod.operations.length;
|
|
3060
|
-
return /* @__PURE__ */
|
|
2735
|
+
return /* @__PURE__ */ jsx10(
|
|
3061
2736
|
ModuleRow,
|
|
3062
2737
|
{
|
|
3063
2738
|
module: mod,
|
|
@@ -3075,12 +2750,12 @@ function CapabilitiesTab({ config, agentId }) {
|
|
|
3075
2750
|
cat.slug
|
|
3076
2751
|
);
|
|
3077
2752
|
}) }),
|
|
3078
|
-
hasChanges && /* @__PURE__ */
|
|
3079
|
-
/* @__PURE__ */
|
|
3080
|
-
/* @__PURE__ */
|
|
3081
|
-
/* @__PURE__ */
|
|
3082
|
-
/* @__PURE__ */
|
|
3083
|
-
|
|
2753
|
+
hasChanges && /* @__PURE__ */ jsxs8("div", { className: "sticky bottom-0 bg-background border-t py-3 px-4 -mx-4 flex items-center justify-between", children: [
|
|
2754
|
+
/* @__PURE__ */ jsx10("span", { className: "text-sm text-muted-foreground", children: "Voc\xEA tem altera\xE7\xF5es n\xE3o salvas." }),
|
|
2755
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-2", children: [
|
|
2756
|
+
/* @__PURE__ */ jsx10(Button7, { variant: "outline", size: "sm", onClick: discard, children: "Descartar" }),
|
|
2757
|
+
/* @__PURE__ */ jsx10(
|
|
2758
|
+
Button7,
|
|
3084
2759
|
{
|
|
3085
2760
|
size: "sm",
|
|
3086
2761
|
onClick: saveNow,
|
|
@@ -3099,10 +2774,10 @@ function ModuleRow({
|
|
|
3099
2774
|
onToggleModule,
|
|
3100
2775
|
onToggleOperation
|
|
3101
2776
|
}) {
|
|
3102
|
-
const [expanded, setExpanded] =
|
|
3103
|
-
return /* @__PURE__ */
|
|
3104
|
-
/* @__PURE__ */
|
|
3105
|
-
/* @__PURE__ */
|
|
2777
|
+
const [expanded, setExpanded] = useState8(false);
|
|
2778
|
+
return /* @__PURE__ */ jsxs8("div", { className: "rounded-md border px-3 py-2", children: [
|
|
2779
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between", children: [
|
|
2780
|
+
/* @__PURE__ */ jsxs8(
|
|
3106
2781
|
"button",
|
|
3107
2782
|
{
|
|
3108
2783
|
type: "button",
|
|
@@ -3111,18 +2786,18 @@ function ModuleRow({
|
|
|
3111
2786
|
"aria-expanded": expanded,
|
|
3112
2787
|
"aria-label": `Expandir ${mod.label}`,
|
|
3113
2788
|
children: [
|
|
3114
|
-
/* @__PURE__ */
|
|
2789
|
+
/* @__PURE__ */ jsx10(
|
|
3115
2790
|
ChevronDown2,
|
|
3116
2791
|
{
|
|
3117
2792
|
className: `h-3.5 w-3.5 text-muted-foreground transition-transform ${expanded ? "rotate-0" : "-rotate-90"}`
|
|
3118
2793
|
}
|
|
3119
2794
|
),
|
|
3120
|
-
/* @__PURE__ */
|
|
3121
|
-
mod.description && /* @__PURE__ */
|
|
2795
|
+
/* @__PURE__ */ jsx10("span", { className: "text-sm font-medium", children: mod.label }),
|
|
2796
|
+
mod.description && /* @__PURE__ */ jsxs8("span", { className: "text-xs text-muted-foreground hidden sm:inline", children: [
|
|
3122
2797
|
"\u2014 ",
|
|
3123
2798
|
mod.description
|
|
3124
2799
|
] }),
|
|
3125
|
-
isOn && /* @__PURE__ */
|
|
2800
|
+
isOn && /* @__PURE__ */ jsxs8(Badge5, { variant: "secondary", className: "text-xs ml-1", children: [
|
|
3126
2801
|
enabledOps.size,
|
|
3127
2802
|
"/",
|
|
3128
2803
|
mod.operations.length
|
|
@@ -3130,8 +2805,8 @@ function ModuleRow({
|
|
|
3130
2805
|
]
|
|
3131
2806
|
}
|
|
3132
2807
|
),
|
|
3133
|
-
/* @__PURE__ */
|
|
3134
|
-
|
|
2808
|
+
/* @__PURE__ */ jsx10(
|
|
2809
|
+
Switch4,
|
|
3135
2810
|
{
|
|
3136
2811
|
checked: isOn,
|
|
3137
2812
|
onCheckedChange: onToggleModule,
|
|
@@ -3139,14 +2814,14 @@ function ModuleRow({
|
|
|
3139
2814
|
}
|
|
3140
2815
|
)
|
|
3141
2816
|
] }),
|
|
3142
|
-
expanded && /* @__PURE__ */
|
|
2817
|
+
expanded && /* @__PURE__ */ jsx10("div", { className: "mt-2 ml-6 flex flex-wrap gap-x-5 gap-y-1.5 pb-1", children: mod.operations.map((op) => {
|
|
3143
2818
|
const checked = enabledOps.has(op);
|
|
3144
|
-
return /* @__PURE__ */
|
|
2819
|
+
return /* @__PURE__ */ jsxs8(
|
|
3145
2820
|
"label",
|
|
3146
2821
|
{
|
|
3147
2822
|
className: "flex items-center gap-1.5 text-sm cursor-pointer",
|
|
3148
2823
|
children: [
|
|
3149
|
-
/* @__PURE__ */
|
|
2824
|
+
/* @__PURE__ */ jsx10(
|
|
3150
2825
|
Checkbox,
|
|
3151
2826
|
{
|
|
3152
2827
|
checked,
|
|
@@ -3154,7 +2829,7 @@ function ModuleRow({
|
|
|
3154
2829
|
"aria-label": `${getOperationLabel(op)} em ${mod.label}`
|
|
3155
2830
|
}
|
|
3156
2831
|
),
|
|
3157
|
-
/* @__PURE__ */
|
|
2832
|
+
/* @__PURE__ */ jsx10("span", { className: checked ? "" : "text-muted-foreground", children: getOperationLabel(op) })
|
|
3158
2833
|
]
|
|
3159
2834
|
},
|
|
3160
2835
|
op
|
|
@@ -3164,20 +2839,20 @@ function ModuleRow({
|
|
|
3164
2839
|
}
|
|
3165
2840
|
|
|
3166
2841
|
// src/components/capabilities/integration-card.tsx
|
|
3167
|
-
import { Badge as
|
|
2842
|
+
import { Badge as Badge6, Button as Button8, Tooltip as Tooltip2, TooltipContent as TooltipContent2, TooltipTrigger as TooltipTrigger2 } from "@greatapps/greatauth-ui/ui";
|
|
3168
2843
|
import {
|
|
3169
2844
|
CalendarSync,
|
|
3170
2845
|
Plug,
|
|
3171
|
-
Settings as
|
|
2846
|
+
Settings as Settings2,
|
|
3172
2847
|
RefreshCw,
|
|
3173
2848
|
Users as Users2,
|
|
3174
2849
|
Clock
|
|
3175
2850
|
} from "lucide-react";
|
|
3176
|
-
import { jsx as
|
|
2851
|
+
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
3177
2852
|
var ICON_MAP = {
|
|
3178
2853
|
CalendarSync,
|
|
3179
2854
|
Plug,
|
|
3180
|
-
Settings:
|
|
2855
|
+
Settings: Settings2,
|
|
3181
2856
|
RefreshCw,
|
|
3182
2857
|
Users: Users2,
|
|
3183
2858
|
Clock
|
|
@@ -3221,7 +2896,7 @@ function IntegrationCard({ card, onConnect }) {
|
|
|
3221
2896
|
const badge = STATE_BADGES[state];
|
|
3222
2897
|
const actionLabel = getActionLabel(state);
|
|
3223
2898
|
const isComingSoon = state === "coming_soon";
|
|
3224
|
-
return /* @__PURE__ */
|
|
2899
|
+
return /* @__PURE__ */ jsxs9(
|
|
3225
2900
|
"div",
|
|
3226
2901
|
{
|
|
3227
2902
|
className: cn(
|
|
@@ -3240,24 +2915,24 @@ function IntegrationCard({ card, onConnect }) {
|
|
|
3240
2915
|
}
|
|
3241
2916
|
},
|
|
3242
2917
|
children: [
|
|
3243
|
-
/* @__PURE__ */
|
|
3244
|
-
/* @__PURE__ */
|
|
3245
|
-
/* @__PURE__ */
|
|
2918
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-start justify-between gap-2", children: [
|
|
2919
|
+
/* @__PURE__ */ jsx11("div", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary", children: /* @__PURE__ */ jsx11(Icon, { className: "h-5 w-5" }) }),
|
|
2920
|
+
/* @__PURE__ */ jsx11(Badge6, { variant: "outline", className: cn("text-xs", badge.className), children: badge.label })
|
|
3246
2921
|
] }),
|
|
3247
|
-
/* @__PURE__ */
|
|
3248
|
-
/* @__PURE__ */
|
|
3249
|
-
/* @__PURE__ */
|
|
2922
|
+
/* @__PURE__ */ jsxs9("div", { className: "space-y-1", children: [
|
|
2923
|
+
/* @__PURE__ */ jsx11("h3", { className: "text-sm font-semibold leading-tight", children: definition.name }),
|
|
2924
|
+
/* @__PURE__ */ jsx11("p", { className: "text-xs text-muted-foreground leading-relaxed", children: definition.description })
|
|
3250
2925
|
] }),
|
|
3251
|
-
/* @__PURE__ */
|
|
3252
|
-
sharedByAgentsCount > 0 ? /* @__PURE__ */
|
|
3253
|
-
/* @__PURE__ */
|
|
3254
|
-
/* @__PURE__ */
|
|
2926
|
+
/* @__PURE__ */ jsxs9("div", { className: "mt-auto flex items-center justify-between gap-2 pt-1", children: [
|
|
2927
|
+
sharedByAgentsCount > 0 ? /* @__PURE__ */ jsxs9(Tooltip2, { children: [
|
|
2928
|
+
/* @__PURE__ */ jsx11(TooltipTrigger2, { asChild: true, children: /* @__PURE__ */ jsxs9("span", { className: "inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400", children: [
|
|
2929
|
+
/* @__PURE__ */ jsx11(Users2, { className: "h-3.5 w-3.5" }),
|
|
3255
2930
|
"Compartilhada"
|
|
3256
2931
|
] }) }),
|
|
3257
|
-
/* @__PURE__ */
|
|
3258
|
-
] }) : /* @__PURE__ */
|
|
3259
|
-
!isComingSoon && /* @__PURE__ */
|
|
3260
|
-
|
|
2932
|
+
/* @__PURE__ */ jsx11(TooltipContent2, { children: "Esta credencial est\xE1 dispon\xEDvel para todos os agentes da conta" })
|
|
2933
|
+
] }) : /* @__PURE__ */ jsx11("span", {}),
|
|
2934
|
+
!isComingSoon && /* @__PURE__ */ jsx11(
|
|
2935
|
+
Button8,
|
|
3261
2936
|
{
|
|
3262
2937
|
variant: state === "expired" ? "destructive" : "outline",
|
|
3263
2938
|
size: "sm",
|
|
@@ -3277,7 +2952,7 @@ function IntegrationCard({ card, onConnect }) {
|
|
|
3277
2952
|
|
|
3278
2953
|
// src/components/capabilities/integrations-tab.tsx
|
|
3279
2954
|
import { Plug as Plug2, Loader2 as Loader24 } from "lucide-react";
|
|
3280
|
-
import { jsx as
|
|
2955
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
3281
2956
|
function IntegrationsTab({
|
|
3282
2957
|
config,
|
|
3283
2958
|
agentId,
|
|
@@ -3285,15 +2960,15 @@ function IntegrationsTab({
|
|
|
3285
2960
|
}) {
|
|
3286
2961
|
const { cards, isLoading } = useIntegrationState(config, agentId);
|
|
3287
2962
|
if (isLoading) {
|
|
3288
|
-
return /* @__PURE__ */
|
|
2963
|
+
return /* @__PURE__ */ jsx12("div", { className: "flex items-center justify-center py-16", children: /* @__PURE__ */ jsx12(Loader24, { className: "h-6 w-6 animate-spin text-muted-foreground" }) });
|
|
3289
2964
|
}
|
|
3290
2965
|
if (cards.length === 0) {
|
|
3291
|
-
return /* @__PURE__ */
|
|
3292
|
-
/* @__PURE__ */
|
|
3293
|
-
/* @__PURE__ */
|
|
2966
|
+
return /* @__PURE__ */ jsxs10("div", { className: "flex flex-col items-center justify-center gap-3 py-16 text-muted-foreground", children: [
|
|
2967
|
+
/* @__PURE__ */ jsx12(Plug2, { className: "h-10 w-10" }),
|
|
2968
|
+
/* @__PURE__ */ jsx12("p", { className: "text-sm", children: "Nenhuma integra\xE7\xE3o dispon\xEDvel" })
|
|
3294
2969
|
] });
|
|
3295
2970
|
}
|
|
3296
|
-
return /* @__PURE__ */
|
|
2971
|
+
return /* @__PURE__ */ jsx12("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3", children: cards.map((card) => /* @__PURE__ */ jsx12(
|
|
3297
2972
|
IntegrationCard,
|
|
3298
2973
|
{
|
|
3299
2974
|
card,
|
|
@@ -3304,43 +2979,43 @@ function IntegrationsTab({
|
|
|
3304
2979
|
}
|
|
3305
2980
|
|
|
3306
2981
|
// src/components/capabilities/integration-wizard.tsx
|
|
3307
|
-
import { useCallback as useCallback5, useEffect as useEffect5, useRef as useRef3, useState as
|
|
2982
|
+
import { useCallback as useCallback5, useEffect as useEffect5, useRef as useRef3, useState as useState9 } from "react";
|
|
3308
2983
|
import {
|
|
3309
|
-
Dialog as
|
|
3310
|
-
DialogContent as
|
|
3311
|
-
DialogFooter as
|
|
3312
|
-
DialogHeader as
|
|
3313
|
-
DialogTitle as
|
|
3314
|
-
Button as
|
|
2984
|
+
Dialog as Dialog4,
|
|
2985
|
+
DialogContent as DialogContent4,
|
|
2986
|
+
DialogFooter as DialogFooter4,
|
|
2987
|
+
DialogHeader as DialogHeader4,
|
|
2988
|
+
DialogTitle as DialogTitle4,
|
|
2989
|
+
Button as Button10
|
|
3315
2990
|
} from "@greatapps/greatauth-ui/ui";
|
|
3316
2991
|
import { Loader2 as Loader27, ChevronLeft, ChevronRight, Check as Check2 } from "lucide-react";
|
|
3317
|
-
import { toast as
|
|
2992
|
+
import { toast as toast7 } from "sonner";
|
|
3318
2993
|
|
|
3319
2994
|
// src/components/capabilities/wizard-steps/info-step.tsx
|
|
3320
2995
|
import { Check, Info } from "lucide-react";
|
|
3321
|
-
import { jsx as
|
|
2996
|
+
import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3322
2997
|
function InfoStep({ integration, meta }) {
|
|
3323
|
-
return /* @__PURE__ */
|
|
3324
|
-
/* @__PURE__ */
|
|
3325
|
-
meta.icon && /* @__PURE__ */
|
|
3326
|
-
/* @__PURE__ */
|
|
3327
|
-
/* @__PURE__ */
|
|
3328
|
-
/* @__PURE__ */
|
|
2998
|
+
return /* @__PURE__ */ jsxs11("div", { className: "space-y-6", children: [
|
|
2999
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-start gap-4", children: [
|
|
3000
|
+
meta.icon && /* @__PURE__ */ jsx13("div", { className: "flex h-12 w-12 shrink-0 items-center justify-center rounded-lg bg-muted", children: meta.icon }),
|
|
3001
|
+
/* @__PURE__ */ jsxs11("div", { className: "space-y-1", children: [
|
|
3002
|
+
/* @__PURE__ */ jsx13("h3", { className: "text-lg font-semibold", children: integration.name }),
|
|
3003
|
+
/* @__PURE__ */ jsx13("p", { className: "text-sm text-muted-foreground", children: integration.description })
|
|
3329
3004
|
] })
|
|
3330
3005
|
] }),
|
|
3331
|
-
meta.capabilities.length > 0 && /* @__PURE__ */
|
|
3332
|
-
/* @__PURE__ */
|
|
3333
|
-
/* @__PURE__ */
|
|
3334
|
-
/* @__PURE__ */
|
|
3006
|
+
meta.capabilities.length > 0 && /* @__PURE__ */ jsxs11("div", { className: "space-y-3", children: [
|
|
3007
|
+
/* @__PURE__ */ jsx13("h4", { className: "text-sm font-medium", children: "O que esta integra\xE7\xE3o permite:" }),
|
|
3008
|
+
/* @__PURE__ */ jsx13("ul", { className: "space-y-2", children: meta.capabilities.map((cap, i) => /* @__PURE__ */ jsxs11("li", { className: "flex items-start gap-2 text-sm", children: [
|
|
3009
|
+
/* @__PURE__ */ jsx13(
|
|
3335
3010
|
Check,
|
|
3336
3011
|
{
|
|
3337
3012
|
"aria-hidden": "true",
|
|
3338
3013
|
className: "mt-0.5 h-4 w-4 shrink-0 text-green-600"
|
|
3339
3014
|
}
|
|
3340
3015
|
),
|
|
3341
|
-
/* @__PURE__ */
|
|
3342
|
-
/* @__PURE__ */
|
|
3343
|
-
cap.description && /* @__PURE__ */
|
|
3016
|
+
/* @__PURE__ */ jsxs11("div", { children: [
|
|
3017
|
+
/* @__PURE__ */ jsx13("span", { className: "font-medium", children: cap.label }),
|
|
3018
|
+
cap.description && /* @__PURE__ */ jsxs11("span", { className: "text-muted-foreground", children: [
|
|
3344
3019
|
" ",
|
|
3345
3020
|
"\u2014 ",
|
|
3346
3021
|
cap.description
|
|
@@ -3348,21 +3023,21 @@ function InfoStep({ integration, meta }) {
|
|
|
3348
3023
|
] })
|
|
3349
3024
|
] }, i)) })
|
|
3350
3025
|
] }),
|
|
3351
|
-
meta.requirements.length > 0 && /* @__PURE__ */
|
|
3352
|
-
/* @__PURE__ */
|
|
3353
|
-
/* @__PURE__ */
|
|
3026
|
+
meta.requirements.length > 0 && /* @__PURE__ */ jsxs11("div", { className: "space-y-3", children: [
|
|
3027
|
+
/* @__PURE__ */ jsx13("h4", { className: "text-sm font-medium", children: "Requisitos:" }),
|
|
3028
|
+
/* @__PURE__ */ jsx13("ul", { className: "space-y-2", children: meta.requirements.map((req, i) => /* @__PURE__ */ jsxs11(
|
|
3354
3029
|
"li",
|
|
3355
3030
|
{
|
|
3356
3031
|
className: "flex items-start gap-2 text-sm text-muted-foreground",
|
|
3357
3032
|
children: [
|
|
3358
|
-
/* @__PURE__ */
|
|
3033
|
+
/* @__PURE__ */ jsx13(
|
|
3359
3034
|
Info,
|
|
3360
3035
|
{
|
|
3361
3036
|
"aria-hidden": "true",
|
|
3362
3037
|
className: "mt-0.5 h-4 w-4 shrink-0 text-blue-500"
|
|
3363
3038
|
}
|
|
3364
3039
|
),
|
|
3365
|
-
/* @__PURE__ */
|
|
3040
|
+
/* @__PURE__ */ jsx13("span", { children: req })
|
|
3366
3041
|
]
|
|
3367
3042
|
},
|
|
3368
3043
|
i
|
|
@@ -3373,8 +3048,8 @@ function InfoStep({ integration, meta }) {
|
|
|
3373
3048
|
|
|
3374
3049
|
// src/components/capabilities/wizard-steps/credentials-step.tsx
|
|
3375
3050
|
import { CheckCircle2, Loader2 as Loader25, AlertCircle, Shield } from "lucide-react";
|
|
3376
|
-
import { Button as
|
|
3377
|
-
import { jsx as
|
|
3051
|
+
import { Button as Button9, Input as Input6, Label as Label4 } from "@greatapps/greatauth-ui/ui";
|
|
3052
|
+
import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3378
3053
|
function CredentialsStep({
|
|
3379
3054
|
integration,
|
|
3380
3055
|
meta,
|
|
@@ -3386,7 +3061,7 @@ function CredentialsStep({
|
|
|
3386
3061
|
isReconnect = false
|
|
3387
3062
|
}) {
|
|
3388
3063
|
if (integration.authType === "oauth2") {
|
|
3389
|
-
return /* @__PURE__ */
|
|
3064
|
+
return /* @__PURE__ */ jsx14(
|
|
3390
3065
|
OAuthCredentials,
|
|
3391
3066
|
{
|
|
3392
3067
|
integration,
|
|
@@ -3398,7 +3073,7 @@ function CredentialsStep({
|
|
|
3398
3073
|
}
|
|
3399
3074
|
);
|
|
3400
3075
|
}
|
|
3401
|
-
return /* @__PURE__ */
|
|
3076
|
+
return /* @__PURE__ */ jsx14(ApiKeyCredentials, { apiKey, onApiKeyChange });
|
|
3402
3077
|
}
|
|
3403
3078
|
function OAuthCredentials({
|
|
3404
3079
|
integration,
|
|
@@ -3409,66 +3084,74 @@ function OAuthCredentials({
|
|
|
3409
3084
|
isReconnect
|
|
3410
3085
|
}) {
|
|
3411
3086
|
const providerLabel = meta.providerLabel || integration.name;
|
|
3412
|
-
return /* @__PURE__ */
|
|
3413
|
-
/* @__PURE__ */
|
|
3414
|
-
/* @__PURE__ */
|
|
3415
|
-
/* @__PURE__ */
|
|
3087
|
+
return /* @__PURE__ */ jsxs12("div", { className: "space-y-6", children: [
|
|
3088
|
+
/* @__PURE__ */ jsxs12("div", { className: "space-y-2", children: [
|
|
3089
|
+
/* @__PURE__ */ jsx14("h3", { className: "text-lg font-semibold", children: "Autentica\xE7\xE3o" }),
|
|
3090
|
+
/* @__PURE__ */ jsx14("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.` })
|
|
3416
3091
|
] }),
|
|
3417
|
-
/* @__PURE__ */
|
|
3418
|
-
oauthStatus === "idle" && /* @__PURE__ */
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3092
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex flex-col items-center gap-4 rounded-lg border p-6", children: [
|
|
3093
|
+
oauthStatus === "idle" && /* @__PURE__ */ jsxs12(
|
|
3094
|
+
Button9,
|
|
3095
|
+
{
|
|
3096
|
+
onClick: onStartOAuth,
|
|
3097
|
+
size: "lg",
|
|
3098
|
+
className: "gap-2",
|
|
3099
|
+
children: [
|
|
3100
|
+
meta.icon,
|
|
3101
|
+
isReconnect ? `Reconectar com ${providerLabel}` : `Conectar com ${providerLabel}`
|
|
3102
|
+
]
|
|
3103
|
+
}
|
|
3104
|
+
),
|
|
3105
|
+
oauthStatus === "waiting" && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col items-center gap-3 text-center", children: [
|
|
3106
|
+
/* @__PURE__ */ jsx14(
|
|
3424
3107
|
Loader25,
|
|
3425
3108
|
{
|
|
3426
3109
|
"aria-hidden": "true",
|
|
3427
3110
|
className: "h-8 w-8 animate-spin text-muted-foreground"
|
|
3428
3111
|
}
|
|
3429
3112
|
),
|
|
3430
|
-
/* @__PURE__ */
|
|
3431
|
-
/* @__PURE__ */
|
|
3432
|
-
/* @__PURE__ */
|
|
3113
|
+
/* @__PURE__ */ jsxs12("div", { children: [
|
|
3114
|
+
/* @__PURE__ */ jsx14("p", { className: "text-sm font-medium", children: "Aguardando autoriza\xE7\xE3o..." }),
|
|
3115
|
+
/* @__PURE__ */ jsx14("p", { className: "text-xs text-muted-foreground", children: "Complete o login na janela que foi aberta." })
|
|
3433
3116
|
] })
|
|
3434
3117
|
] }),
|
|
3435
|
-
oauthStatus === "success" && oauthResult && /* @__PURE__ */
|
|
3436
|
-
/* @__PURE__ */
|
|
3118
|
+
oauthStatus === "success" && oauthResult && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col items-center gap-3 text-center", children: [
|
|
3119
|
+
/* @__PURE__ */ jsx14(
|
|
3437
3120
|
CheckCircle2,
|
|
3438
3121
|
{
|
|
3439
3122
|
"aria-hidden": "true",
|
|
3440
3123
|
className: "h-8 w-8 text-green-600"
|
|
3441
3124
|
}
|
|
3442
3125
|
),
|
|
3443
|
-
/* @__PURE__ */
|
|
3444
|
-
/* @__PURE__ */
|
|
3445
|
-
oauthResult.email && /* @__PURE__ */
|
|
3126
|
+
/* @__PURE__ */ jsxs12("div", { children: [
|
|
3127
|
+
/* @__PURE__ */ jsx14("p", { className: "text-sm font-medium text-green-700", children: "Conectado com sucesso!" }),
|
|
3128
|
+
oauthResult.email && /* @__PURE__ */ jsx14("p", { className: "text-xs text-muted-foreground", children: oauthResult.email })
|
|
3446
3129
|
] })
|
|
3447
3130
|
] }),
|
|
3448
|
-
oauthStatus === "error" && /* @__PURE__ */
|
|
3449
|
-
/* @__PURE__ */
|
|
3131
|
+
oauthStatus === "error" && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col items-center gap-3 text-center", children: [
|
|
3132
|
+
/* @__PURE__ */ jsx14(
|
|
3450
3133
|
AlertCircle,
|
|
3451
3134
|
{
|
|
3452
3135
|
"aria-hidden": "true",
|
|
3453
3136
|
className: "h-8 w-8 text-destructive"
|
|
3454
3137
|
}
|
|
3455
3138
|
),
|
|
3456
|
-
/* @__PURE__ */
|
|
3457
|
-
/* @__PURE__ */
|
|
3458
|
-
oauthResult?.error && /* @__PURE__ */
|
|
3139
|
+
/* @__PURE__ */ jsxs12("div", { children: [
|
|
3140
|
+
/* @__PURE__ */ jsx14("p", { className: "text-sm font-medium text-destructive", children: "Falha na conex\xE3o" }),
|
|
3141
|
+
oauthResult?.error && /* @__PURE__ */ jsx14("p", { className: "text-xs text-muted-foreground", children: oauthResult.error })
|
|
3459
3142
|
] }),
|
|
3460
|
-
/* @__PURE__ */
|
|
3143
|
+
/* @__PURE__ */ jsx14(Button9, { variant: "outline", onClick: onStartOAuth, size: "sm", children: "Tentar novamente" })
|
|
3461
3144
|
] })
|
|
3462
3145
|
] }),
|
|
3463
|
-
/* @__PURE__ */
|
|
3464
|
-
/* @__PURE__ */
|
|
3146
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-start gap-2 rounded-md bg-muted/50 p-3", children: [
|
|
3147
|
+
/* @__PURE__ */ jsx14(
|
|
3465
3148
|
Shield,
|
|
3466
3149
|
{
|
|
3467
3150
|
"aria-hidden": "true",
|
|
3468
3151
|
className: "mt-0.5 h-4 w-4 shrink-0 text-green-600"
|
|
3469
3152
|
}
|
|
3470
3153
|
),
|
|
3471
|
-
/* @__PURE__ */
|
|
3154
|
+
/* @__PURE__ */ jsxs12("p", { className: "text-xs text-muted-foreground", children: [
|
|
3472
3155
|
"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 ",
|
|
3473
3156
|
providerLabel,
|
|
3474
3157
|
"."
|
|
@@ -3480,15 +3163,15 @@ function ApiKeyCredentials({
|
|
|
3480
3163
|
apiKey,
|
|
3481
3164
|
onApiKeyChange
|
|
3482
3165
|
}) {
|
|
3483
|
-
return /* @__PURE__ */
|
|
3484
|
-
/* @__PURE__ */
|
|
3485
|
-
/* @__PURE__ */
|
|
3486
|
-
/* @__PURE__ */
|
|
3166
|
+
return /* @__PURE__ */ jsxs12("div", { className: "space-y-6", children: [
|
|
3167
|
+
/* @__PURE__ */ jsxs12("div", { className: "space-y-2", children: [
|
|
3168
|
+
/* @__PURE__ */ jsx14("h3", { className: "text-lg font-semibold", children: "Autentica\xE7\xE3o" }),
|
|
3169
|
+
/* @__PURE__ */ jsx14("p", { className: "text-sm text-muted-foreground", children: "Insira a chave de API para conectar a integra\xE7\xE3o." })
|
|
3487
3170
|
] }),
|
|
3488
|
-
/* @__PURE__ */
|
|
3489
|
-
/* @__PURE__ */
|
|
3490
|
-
/* @__PURE__ */
|
|
3491
|
-
|
|
3171
|
+
/* @__PURE__ */ jsxs12("div", { className: "space-y-2", children: [
|
|
3172
|
+
/* @__PURE__ */ jsx14(Label4, { htmlFor: "integration-api-key", children: "Chave de API" }),
|
|
3173
|
+
/* @__PURE__ */ jsx14(
|
|
3174
|
+
Input6,
|
|
3492
3175
|
{
|
|
3493
3176
|
id: "integration-api-key",
|
|
3494
3177
|
type: "password",
|
|
@@ -3499,15 +3182,15 @@ function ApiKeyCredentials({
|
|
|
3499
3182
|
}
|
|
3500
3183
|
)
|
|
3501
3184
|
] }),
|
|
3502
|
-
/* @__PURE__ */
|
|
3503
|
-
/* @__PURE__ */
|
|
3185
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-start gap-2 rounded-md bg-muted/50 p-3", children: [
|
|
3186
|
+
/* @__PURE__ */ jsx14(
|
|
3504
3187
|
Shield,
|
|
3505
3188
|
{
|
|
3506
3189
|
"aria-hidden": "true",
|
|
3507
3190
|
className: "mt-0.5 h-4 w-4 shrink-0 text-green-600"
|
|
3508
3191
|
}
|
|
3509
3192
|
),
|
|
3510
|
-
/* @__PURE__ */
|
|
3193
|
+
/* @__PURE__ */ jsx14("p", { className: "text-xs text-muted-foreground", children: "Sua chave de API \xE9 armazenada de forma segura e encriptada. Nunca \xE9 exposta no frontend." })
|
|
3511
3194
|
] })
|
|
3512
3195
|
] });
|
|
3513
3196
|
}
|
|
@@ -3515,14 +3198,14 @@ function ApiKeyCredentials({
|
|
|
3515
3198
|
// src/components/capabilities/wizard-steps/config-step.tsx
|
|
3516
3199
|
import { Loader2 as Loader26 } from "lucide-react";
|
|
3517
3200
|
import {
|
|
3518
|
-
Label as
|
|
3519
|
-
Select
|
|
3520
|
-
SelectContent
|
|
3521
|
-
SelectItem
|
|
3522
|
-
SelectTrigger
|
|
3523
|
-
SelectValue
|
|
3201
|
+
Label as Label5,
|
|
3202
|
+
Select,
|
|
3203
|
+
SelectContent,
|
|
3204
|
+
SelectItem,
|
|
3205
|
+
SelectTrigger,
|
|
3206
|
+
SelectValue
|
|
3524
3207
|
} from "@greatapps/greatauth-ui/ui";
|
|
3525
|
-
import { jsx as
|
|
3208
|
+
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3526
3209
|
function ConfigStep({
|
|
3527
3210
|
integration,
|
|
3528
3211
|
options,
|
|
@@ -3534,27 +3217,27 @@ function ConfigStep({
|
|
|
3534
3217
|
}) {
|
|
3535
3218
|
const label = selectLabel || getDefaultLabel(integration.slug);
|
|
3536
3219
|
const placeholder = selectPlaceholder || getDefaultPlaceholder(integration.slug);
|
|
3537
|
-
return /* @__PURE__ */
|
|
3538
|
-
/* @__PURE__ */
|
|
3539
|
-
/* @__PURE__ */
|
|
3540
|
-
/* @__PURE__ */
|
|
3220
|
+
return /* @__PURE__ */ jsxs13("div", { className: "space-y-6", children: [
|
|
3221
|
+
/* @__PURE__ */ jsxs13("div", { className: "space-y-2", children: [
|
|
3222
|
+
/* @__PURE__ */ jsx15("h3", { className: "text-lg font-semibold", children: "Configura\xE7\xE3o" }),
|
|
3223
|
+
/* @__PURE__ */ jsx15("p", { className: "text-sm text-muted-foreground", children: "Configure as op\xE7\xF5es espec\xEDficas da integra\xE7\xE3o." })
|
|
3541
3224
|
] }),
|
|
3542
|
-
isLoading ? /* @__PURE__ */
|
|
3543
|
-
/* @__PURE__ */
|
|
3225
|
+
isLoading ? /* @__PURE__ */ jsxs13("div", { className: "flex flex-col items-center gap-3 py-8", children: [
|
|
3226
|
+
/* @__PURE__ */ jsx15(
|
|
3544
3227
|
Loader26,
|
|
3545
3228
|
{
|
|
3546
3229
|
"aria-hidden": "true",
|
|
3547
3230
|
className: "h-6 w-6 animate-spin text-muted-foreground"
|
|
3548
3231
|
}
|
|
3549
3232
|
),
|
|
3550
|
-
/* @__PURE__ */
|
|
3551
|
-
] }) : options.length === 0 ? /* @__PURE__ */
|
|
3552
|
-
/* @__PURE__ */
|
|
3553
|
-
/* @__PURE__ */
|
|
3554
|
-
/* @__PURE__ */
|
|
3555
|
-
/* @__PURE__ */
|
|
3556
|
-
/* @__PURE__ */
|
|
3557
|
-
opt.description && /* @__PURE__ */
|
|
3233
|
+
/* @__PURE__ */ jsx15("p", { className: "text-sm text-muted-foreground", children: "Carregando op\xE7\xF5es..." })
|
|
3234
|
+
] }) : options.length === 0 ? /* @__PURE__ */ jsx15("div", { className: "rounded-lg border border-dashed p-6 text-center", children: /* @__PURE__ */ jsx15("p", { className: "text-sm text-muted-foreground", children: "Nenhuma op\xE7\xE3o dispon\xEDvel. A configura\xE7\xE3o padr\xE3o ser\xE1 usada." }) }) : /* @__PURE__ */ jsxs13("div", { className: "space-y-2", children: [
|
|
3235
|
+
/* @__PURE__ */ jsx15(Label5, { htmlFor: "integration-config-select", children: label }),
|
|
3236
|
+
/* @__PURE__ */ jsxs13(Select, { value: selectedValue, onValueChange, children: [
|
|
3237
|
+
/* @__PURE__ */ jsx15(SelectTrigger, { id: "integration-config-select", children: /* @__PURE__ */ jsx15(SelectValue, { placeholder }) }),
|
|
3238
|
+
/* @__PURE__ */ jsx15(SelectContent, { children: options.map((opt) => /* @__PURE__ */ jsxs13(SelectItem, { value: opt.id, children: [
|
|
3239
|
+
/* @__PURE__ */ jsx15("span", { children: opt.label }),
|
|
3240
|
+
opt.description && /* @__PURE__ */ jsxs13("span", { className: "ml-2 text-xs text-muted-foreground", children: [
|
|
3558
3241
|
"(",
|
|
3559
3242
|
opt.description,
|
|
3560
3243
|
")"
|
|
@@ -3583,8 +3266,8 @@ function getDefaultPlaceholder(slug) {
|
|
|
3583
3266
|
|
|
3584
3267
|
// src/components/capabilities/wizard-steps/confirm-step.tsx
|
|
3585
3268
|
import { CheckCircle2 as CheckCircle22 } from "lucide-react";
|
|
3586
|
-
import { Label as
|
|
3587
|
-
import { jsx as
|
|
3269
|
+
import { Label as Label6 } from "@greatapps/greatauth-ui/ui";
|
|
3270
|
+
import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3588
3271
|
function ConfirmStep({
|
|
3589
3272
|
integration,
|
|
3590
3273
|
oauthResult,
|
|
@@ -3592,22 +3275,22 @@ function ConfirmStep({
|
|
|
3592
3275
|
enableOnComplete,
|
|
3593
3276
|
onEnableChange
|
|
3594
3277
|
}) {
|
|
3595
|
-
return /* @__PURE__ */
|
|
3596
|
-
/* @__PURE__ */
|
|
3597
|
-
/* @__PURE__ */
|
|
3598
|
-
/* @__PURE__ */
|
|
3278
|
+
return /* @__PURE__ */ jsxs14("div", { className: "space-y-6", children: [
|
|
3279
|
+
/* @__PURE__ */ jsxs14("div", { className: "space-y-2", children: [
|
|
3280
|
+
/* @__PURE__ */ jsx16("h3", { className: "text-lg font-semibold", children: "Confirma\xE7\xE3o" }),
|
|
3281
|
+
/* @__PURE__ */ jsx16("p", { className: "text-sm text-muted-foreground", children: "Revise as configura\xE7\xF5es antes de concluir." })
|
|
3599
3282
|
] }),
|
|
3600
|
-
/* @__PURE__ */
|
|
3601
|
-
/* @__PURE__ */
|
|
3602
|
-
oauthResult?.email && /* @__PURE__ */
|
|
3603
|
-
selectedConfigOption && /* @__PURE__ */
|
|
3283
|
+
/* @__PURE__ */ jsxs14("div", { className: "space-y-3 rounded-lg border p-4", children: [
|
|
3284
|
+
/* @__PURE__ */ jsx16(SummaryRow, { label: "Integra\xE7\xE3o", value: integration.name }),
|
|
3285
|
+
oauthResult?.email && /* @__PURE__ */ jsx16(SummaryRow, { label: "Conta conectada", value: oauthResult.email }),
|
|
3286
|
+
selectedConfigOption && /* @__PURE__ */ jsx16(
|
|
3604
3287
|
SummaryRow,
|
|
3605
3288
|
{
|
|
3606
3289
|
label: getConfigLabel(integration.slug),
|
|
3607
3290
|
value: selectedConfigOption.label
|
|
3608
3291
|
}
|
|
3609
3292
|
),
|
|
3610
|
-
/* @__PURE__ */
|
|
3293
|
+
/* @__PURE__ */ jsx16(
|
|
3611
3294
|
SummaryRow,
|
|
3612
3295
|
{
|
|
3613
3296
|
label: "Tipo de autentica\xE7\xE3o",
|
|
@@ -3615,12 +3298,12 @@ function ConfirmStep({
|
|
|
3615
3298
|
}
|
|
3616
3299
|
)
|
|
3617
3300
|
] }),
|
|
3618
|
-
/* @__PURE__ */
|
|
3619
|
-
/* @__PURE__ */
|
|
3620
|
-
/* @__PURE__ */
|
|
3621
|
-
/* @__PURE__ */
|
|
3301
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center justify-between rounded-lg border p-4", children: [
|
|
3302
|
+
/* @__PURE__ */ jsxs14("div", { className: "space-y-0.5", children: [
|
|
3303
|
+
/* @__PURE__ */ jsx16(Label6, { htmlFor: "enable-on-complete", className: "text-sm font-medium", children: "Ativar imediatamente" }),
|
|
3304
|
+
/* @__PURE__ */ jsx16("p", { className: "text-xs text-muted-foreground", children: "A integra\xE7\xE3o ficar\xE1 ativa assim que concluir o assistente." })
|
|
3622
3305
|
] }),
|
|
3623
|
-
/* @__PURE__ */
|
|
3306
|
+
/* @__PURE__ */ jsx16(
|
|
3624
3307
|
"button",
|
|
3625
3308
|
{
|
|
3626
3309
|
id: "enable-on-complete",
|
|
@@ -3634,7 +3317,7 @@ function ConfirmStep({
|
|
|
3634
3317
|
focus-visible:ring-ring focus-visible:ring-offset-2
|
|
3635
3318
|
${enableOnComplete ? "bg-primary" : "bg-muted"}
|
|
3636
3319
|
`,
|
|
3637
|
-
children: /* @__PURE__ */
|
|
3320
|
+
children: /* @__PURE__ */ jsx16(
|
|
3638
3321
|
"span",
|
|
3639
3322
|
{
|
|
3640
3323
|
"aria-hidden": "true",
|
|
@@ -3648,22 +3331,22 @@ function ConfirmStep({
|
|
|
3648
3331
|
}
|
|
3649
3332
|
)
|
|
3650
3333
|
] }),
|
|
3651
|
-
/* @__PURE__ */
|
|
3652
|
-
/* @__PURE__ */
|
|
3334
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2 rounded-md bg-green-50 p-3 dark:bg-green-950/20", children: [
|
|
3335
|
+
/* @__PURE__ */ jsx16(
|
|
3653
3336
|
CheckCircle22,
|
|
3654
3337
|
{
|
|
3655
3338
|
"aria-hidden": "true",
|
|
3656
3339
|
className: "h-4 w-4 shrink-0 text-green-600"
|
|
3657
3340
|
}
|
|
3658
3341
|
),
|
|
3659
|
-
/* @__PURE__ */
|
|
3342
|
+
/* @__PURE__ */ jsx16("p", { className: "text-xs text-green-700 dark:text-green-400", children: 'Tudo pronto! Clique em "Concluir" para finalizar a configura\xE7\xE3o.' })
|
|
3660
3343
|
] })
|
|
3661
3344
|
] });
|
|
3662
3345
|
}
|
|
3663
3346
|
function SummaryRow({ label, value }) {
|
|
3664
|
-
return /* @__PURE__ */
|
|
3665
|
-
/* @__PURE__ */
|
|
3666
|
-
/* @__PURE__ */
|
|
3347
|
+
return /* @__PURE__ */ jsxs14("div", { className: "flex items-center justify-between text-sm", children: [
|
|
3348
|
+
/* @__PURE__ */ jsx16("span", { className: "text-muted-foreground", children: label }),
|
|
3349
|
+
/* @__PURE__ */ jsx16("span", { className: "font-medium", children: value })
|
|
3667
3350
|
] });
|
|
3668
3351
|
}
|
|
3669
3352
|
function getConfigLabel(slug) {
|
|
@@ -3676,7 +3359,7 @@ function getConfigLabel(slug) {
|
|
|
3676
3359
|
}
|
|
3677
3360
|
|
|
3678
3361
|
// src/components/capabilities/integration-wizard.tsx
|
|
3679
|
-
import { jsx as
|
|
3362
|
+
import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3680
3363
|
var STEPS = ["info", "credentials", "config", "confirm"];
|
|
3681
3364
|
var STEP_LABELS = {
|
|
3682
3365
|
info: "Informa\xE7\xE3o",
|
|
@@ -3698,18 +3381,18 @@ function IntegrationWizard({
|
|
|
3698
3381
|
existingConfigValue
|
|
3699
3382
|
}) {
|
|
3700
3383
|
const isReconnect = !!existingCredentialId;
|
|
3701
|
-
const [currentStep, setCurrentStep] =
|
|
3384
|
+
const [currentStep, setCurrentStep] = useState9("info");
|
|
3702
3385
|
const currentIndex = STEPS.indexOf(currentStep);
|
|
3703
|
-
const [oauthStatus, setOauthStatus] =
|
|
3704
|
-
const [oauthResult, setOauthResult] =
|
|
3386
|
+
const [oauthStatus, setOauthStatus] = useState9("idle");
|
|
3387
|
+
const [oauthResult, setOauthResult] = useState9(null);
|
|
3705
3388
|
const popupRef = useRef3(null);
|
|
3706
3389
|
const popupPollRef = useRef3(null);
|
|
3707
|
-
const [apiKey, setApiKey] =
|
|
3708
|
-
const [configOptions, setConfigOptions] =
|
|
3709
|
-
const [configLoading, setConfigLoading] =
|
|
3710
|
-
const [selectedConfigValue, setSelectedConfigValue] =
|
|
3711
|
-
const [enableOnComplete, setEnableOnComplete] =
|
|
3712
|
-
const [isSubmitting, setIsSubmitting] =
|
|
3390
|
+
const [apiKey, setApiKey] = useState9("");
|
|
3391
|
+
const [configOptions, setConfigOptions] = useState9([]);
|
|
3392
|
+
const [configLoading, setConfigLoading] = useState9(false);
|
|
3393
|
+
const [selectedConfigValue, setSelectedConfigValue] = useState9("");
|
|
3394
|
+
const [enableOnComplete, setEnableOnComplete] = useState9(true);
|
|
3395
|
+
const [isSubmitting, setIsSubmitting] = useState9(false);
|
|
3713
3396
|
useEffect5(() => {
|
|
3714
3397
|
return () => {
|
|
3715
3398
|
if (popupPollRef.current) {
|
|
@@ -3783,38 +3466,54 @@ function IntegrationWizard({
|
|
|
3783
3466
|
window.addEventListener("message", handleOAuthMessage);
|
|
3784
3467
|
return () => window.removeEventListener("message", handleOAuthMessage);
|
|
3785
3468
|
}, [open, handleOAuthMessage]);
|
|
3786
|
-
function startOAuth() {
|
|
3787
|
-
const { language = "pt-br", idWl = 1, accountId } = config;
|
|
3788
|
-
const redirectUri = `${window.location.origin}/oauth/callback`;
|
|
3789
|
-
const url = new URL(
|
|
3790
|
-
`${gagentsApiUrl}/v1/${language}/${idWl}/accounts/${accountId}/oauth/authorize/${integration.slug}`
|
|
3791
|
-
);
|
|
3792
|
-
url.searchParams.set("redirect_uri", redirectUri);
|
|
3469
|
+
async function startOAuth() {
|
|
3470
|
+
const { language = "pt-br", idWl = 1, accountId, token } = config;
|
|
3793
3471
|
setOauthStatus("waiting");
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3472
|
+
try {
|
|
3473
|
+
const response = await fetch(
|
|
3474
|
+
`${gagentsApiUrl}/v1/${language}/${idWl}/accounts/${accountId}/oauth/authorize/${integration.slug}`,
|
|
3475
|
+
{ headers: { Authorization: `Bearer ${token}` } }
|
|
3476
|
+
);
|
|
3477
|
+
const result = await response.json();
|
|
3478
|
+
if (result.status !== 1 || !result.data?.auth_url) {
|
|
3479
|
+
setOauthStatus("error");
|
|
3480
|
+
setOauthResult({
|
|
3481
|
+
success: false,
|
|
3482
|
+
error: result.message || "Erro ao obter URL de autoriza\xE7\xE3o"
|
|
3483
|
+
});
|
|
3484
|
+
return;
|
|
3803
3485
|
}
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
);
|
|
3813
|
-
setOauthResult(
|
|
3814
|
-
(prev) => prev === null ? { success: false, error: "Janela fechada antes de concluir" } : prev
|
|
3815
|
-
);
|
|
3486
|
+
const popup = window.open(
|
|
3487
|
+
result.data.auth_url,
|
|
3488
|
+
"oauth-popup",
|
|
3489
|
+
"width=500,height=600,scrollbars=yes,resizable=yes"
|
|
3490
|
+
);
|
|
3491
|
+
popupRef.current = popup;
|
|
3492
|
+
if (popup) {
|
|
3493
|
+
if (popupPollRef.current) {
|
|
3494
|
+
clearInterval(popupPollRef.current);
|
|
3816
3495
|
}
|
|
3817
|
-
|
|
3496
|
+
popupPollRef.current = setInterval(() => {
|
|
3497
|
+
if (popup.closed) {
|
|
3498
|
+
if (popupPollRef.current) {
|
|
3499
|
+
clearInterval(popupPollRef.current);
|
|
3500
|
+
popupPollRef.current = null;
|
|
3501
|
+
}
|
|
3502
|
+
setOauthStatus(
|
|
3503
|
+
(prev) => prev === "waiting" ? "error" : prev
|
|
3504
|
+
);
|
|
3505
|
+
setOauthResult(
|
|
3506
|
+
(prev) => prev === null ? { success: false, error: "Janela fechada antes de concluir" } : prev
|
|
3507
|
+
);
|
|
3508
|
+
}
|
|
3509
|
+
}, 500);
|
|
3510
|
+
}
|
|
3511
|
+
} catch (err) {
|
|
3512
|
+
setOauthStatus("error");
|
|
3513
|
+
setOauthResult({
|
|
3514
|
+
success: false,
|
|
3515
|
+
error: "Erro de rede ao obter URL de autoriza\xE7\xE3o"
|
|
3516
|
+
});
|
|
3818
3517
|
}
|
|
3819
3518
|
}
|
|
3820
3519
|
function canAdvance() {
|
|
@@ -3860,11 +3559,11 @@ function IntegrationWizard({
|
|
|
3860
3559
|
try {
|
|
3861
3560
|
onComplete();
|
|
3862
3561
|
onOpenChange(false);
|
|
3863
|
-
|
|
3562
|
+
toast7.success(
|
|
3864
3563
|
`${integration.name} ${isReconnect ? "reconectado" : "configurado"} com sucesso!`
|
|
3865
3564
|
);
|
|
3866
3565
|
} catch {
|
|
3867
|
-
|
|
3566
|
+
toast7.error("Erro ao finalizar configura\xE7\xE3o");
|
|
3868
3567
|
} finally {
|
|
3869
3568
|
setIsSubmitting(false);
|
|
3870
3569
|
}
|
|
@@ -3872,18 +3571,18 @@ function IntegrationWizard({
|
|
|
3872
3571
|
const selectedConfigOption = configOptions.find((o) => o.id === selectedConfigValue) || null;
|
|
3873
3572
|
const isLastStep = currentStep === "confirm";
|
|
3874
3573
|
const effectiveSteps = meta.hasConfigStep ? STEPS : STEPS.filter((s) => s !== "config");
|
|
3875
|
-
return /* @__PURE__ */
|
|
3876
|
-
/* @__PURE__ */
|
|
3877
|
-
/* @__PURE__ */
|
|
3878
|
-
/* @__PURE__ */
|
|
3879
|
-
currentStep === "info" && /* @__PURE__ */
|
|
3574
|
+
return /* @__PURE__ */ jsx17(Dialog4, { open, onOpenChange, children: /* @__PURE__ */ jsxs15(DialogContent4, { className: "sm:max-w-lg", children: [
|
|
3575
|
+
/* @__PURE__ */ jsx17(DialogHeader4, { children: /* @__PURE__ */ jsx17(DialogTitle4, { children: integration.name }) }),
|
|
3576
|
+
/* @__PURE__ */ jsx17(StepIndicator, { steps: effectiveSteps, currentStep }),
|
|
3577
|
+
/* @__PURE__ */ jsxs15("div", { className: "min-h-[280px] py-2", children: [
|
|
3578
|
+
currentStep === "info" && /* @__PURE__ */ jsx17(
|
|
3880
3579
|
InfoStep,
|
|
3881
3580
|
{
|
|
3882
3581
|
integration,
|
|
3883
3582
|
meta
|
|
3884
3583
|
}
|
|
3885
3584
|
),
|
|
3886
|
-
currentStep === "credentials" && /* @__PURE__ */
|
|
3585
|
+
currentStep === "credentials" && /* @__PURE__ */ jsx17(
|
|
3887
3586
|
CredentialsStep,
|
|
3888
3587
|
{
|
|
3889
3588
|
integration,
|
|
@@ -3896,7 +3595,7 @@ function IntegrationWizard({
|
|
|
3896
3595
|
isReconnect
|
|
3897
3596
|
}
|
|
3898
3597
|
),
|
|
3899
|
-
currentStep === "config" && /* @__PURE__ */
|
|
3598
|
+
currentStep === "config" && /* @__PURE__ */ jsx17(
|
|
3900
3599
|
ConfigStep,
|
|
3901
3600
|
{
|
|
3902
3601
|
integration,
|
|
@@ -3906,7 +3605,7 @@ function IntegrationWizard({
|
|
|
3906
3605
|
onValueChange: setSelectedConfigValue
|
|
3907
3606
|
}
|
|
3908
3607
|
),
|
|
3909
|
-
currentStep === "confirm" && /* @__PURE__ */
|
|
3608
|
+
currentStep === "confirm" && /* @__PURE__ */ jsx17(
|
|
3910
3609
|
ConfirmStep,
|
|
3911
3610
|
{
|
|
3912
3611
|
integration,
|
|
@@ -3917,48 +3616,48 @@ function IntegrationWizard({
|
|
|
3917
3616
|
}
|
|
3918
3617
|
)
|
|
3919
3618
|
] }),
|
|
3920
|
-
/* @__PURE__ */
|
|
3921
|
-
/* @__PURE__ */
|
|
3922
|
-
|
|
3619
|
+
/* @__PURE__ */ jsxs15(DialogFooter4, { className: "flex-row justify-between sm:justify-between", children: [
|
|
3620
|
+
/* @__PURE__ */ jsx17("div", { children: currentStep === "info" ? /* @__PURE__ */ jsx17(
|
|
3621
|
+
Button10,
|
|
3923
3622
|
{
|
|
3924
3623
|
type: "button",
|
|
3925
3624
|
variant: "outline",
|
|
3926
3625
|
onClick: () => onOpenChange(false),
|
|
3927
3626
|
children: "Cancelar"
|
|
3928
3627
|
}
|
|
3929
|
-
) : /* @__PURE__ */
|
|
3930
|
-
|
|
3628
|
+
) : /* @__PURE__ */ jsxs15(
|
|
3629
|
+
Button10,
|
|
3931
3630
|
{
|
|
3932
3631
|
type: "button",
|
|
3933
3632
|
variant: "outline",
|
|
3934
3633
|
onClick: goPrev,
|
|
3935
3634
|
className: "gap-1",
|
|
3936
3635
|
children: [
|
|
3937
|
-
/* @__PURE__ */
|
|
3636
|
+
/* @__PURE__ */ jsx17(ChevronLeft, { "aria-hidden": "true", className: "h-4 w-4" }),
|
|
3938
3637
|
"Voltar"
|
|
3939
3638
|
]
|
|
3940
3639
|
}
|
|
3941
3640
|
) }),
|
|
3942
|
-
/* @__PURE__ */
|
|
3943
|
-
|
|
3641
|
+
/* @__PURE__ */ jsx17("div", { children: isLastStep ? /* @__PURE__ */ jsxs15(
|
|
3642
|
+
Button10,
|
|
3944
3643
|
{
|
|
3945
3644
|
type: "button",
|
|
3946
3645
|
onClick: handleComplete,
|
|
3947
3646
|
disabled: isSubmitting,
|
|
3948
3647
|
className: "gap-1",
|
|
3949
3648
|
children: [
|
|
3950
|
-
isSubmitting ? /* @__PURE__ */
|
|
3649
|
+
isSubmitting ? /* @__PURE__ */ jsx17(
|
|
3951
3650
|
Loader27,
|
|
3952
3651
|
{
|
|
3953
3652
|
"aria-hidden": "true",
|
|
3954
3653
|
className: "h-4 w-4 animate-spin"
|
|
3955
3654
|
}
|
|
3956
|
-
) : /* @__PURE__ */
|
|
3655
|
+
) : /* @__PURE__ */ jsx17(Check2, { "aria-hidden": "true", className: "h-4 w-4" }),
|
|
3957
3656
|
"Concluir"
|
|
3958
3657
|
]
|
|
3959
3658
|
}
|
|
3960
|
-
) : /* @__PURE__ */
|
|
3961
|
-
|
|
3659
|
+
) : /* @__PURE__ */ jsxs15(
|
|
3660
|
+
Button10,
|
|
3962
3661
|
{
|
|
3963
3662
|
type: "button",
|
|
3964
3663
|
onClick: goNext,
|
|
@@ -3966,7 +3665,7 @@ function IntegrationWizard({
|
|
|
3966
3665
|
className: "gap-1",
|
|
3967
3666
|
children: [
|
|
3968
3667
|
"Continuar",
|
|
3969
|
-
/* @__PURE__ */
|
|
3668
|
+
/* @__PURE__ */ jsx17(ChevronRight, { "aria-hidden": "true", className: "h-4 w-4" })
|
|
3970
3669
|
]
|
|
3971
3670
|
}
|
|
3972
3671
|
) })
|
|
@@ -3978,7 +3677,7 @@ function StepIndicator({
|
|
|
3978
3677
|
currentStep
|
|
3979
3678
|
}) {
|
|
3980
3679
|
const currentIndex = steps.indexOf(currentStep);
|
|
3981
|
-
return /* @__PURE__ */
|
|
3680
|
+
return /* @__PURE__ */ jsx17(
|
|
3982
3681
|
"div",
|
|
3983
3682
|
{
|
|
3984
3683
|
className: "flex items-center justify-center gap-1 py-2",
|
|
@@ -3987,8 +3686,8 @@ function StepIndicator({
|
|
|
3987
3686
|
children: steps.map((step, i) => {
|
|
3988
3687
|
const isCompleted = i < currentIndex;
|
|
3989
3688
|
const isCurrent = step === currentStep;
|
|
3990
|
-
return /* @__PURE__ */
|
|
3991
|
-
/* @__PURE__ */
|
|
3689
|
+
return /* @__PURE__ */ jsxs15("div", { className: "flex items-center", role: "listitem", children: [
|
|
3690
|
+
/* @__PURE__ */ jsx17(
|
|
3992
3691
|
"div",
|
|
3993
3692
|
{
|
|
3994
3693
|
className: `
|
|
@@ -3998,10 +3697,10 @@ function StepIndicator({
|
|
|
3998
3697
|
`,
|
|
3999
3698
|
"aria-current": isCurrent ? "step" : void 0,
|
|
4000
3699
|
"aria-label": `${STEP_LABELS[step]}${isCompleted ? " (conclu\xEDdo)" : isCurrent ? " (atual)" : ""}`,
|
|
4001
|
-
children: isCompleted ? /* @__PURE__ */
|
|
3700
|
+
children: isCompleted ? /* @__PURE__ */ jsx17(Check2, { "aria-hidden": "true", className: "h-3.5 w-3.5" }) : i + 1
|
|
4002
3701
|
}
|
|
4003
3702
|
),
|
|
4004
|
-
/* @__PURE__ */
|
|
3703
|
+
/* @__PURE__ */ jsx17(
|
|
4005
3704
|
"span",
|
|
4006
3705
|
{
|
|
4007
3706
|
className: `
|
|
@@ -4011,7 +3710,7 @@ function StepIndicator({
|
|
|
4011
3710
|
children: STEP_LABELS[step]
|
|
4012
3711
|
}
|
|
4013
3712
|
),
|
|
4014
|
-
i < steps.length - 1 && /* @__PURE__ */
|
|
3713
|
+
i < steps.length - 1 && /* @__PURE__ */ jsx17(
|
|
4015
3714
|
"div",
|
|
4016
3715
|
{
|
|
4017
3716
|
className: `
|
|
@@ -4027,63 +3726,63 @@ function StepIndicator({
|
|
|
4027
3726
|
}
|
|
4028
3727
|
|
|
4029
3728
|
// src/components/capabilities/advanced-tab.tsx
|
|
4030
|
-
import { useState as
|
|
3729
|
+
import { useState as useState13 } from "react";
|
|
4031
3730
|
|
|
4032
3731
|
// src/components/tools/tools-table.tsx
|
|
4033
|
-
import { useMemo as useMemo6, useState as
|
|
3732
|
+
import { useMemo as useMemo6, useState as useState10 } from "react";
|
|
4034
3733
|
import { DataTable as DataTable2 } from "@greatapps/greatauth-ui";
|
|
4035
3734
|
import {
|
|
4036
|
-
Input as
|
|
4037
|
-
Badge as
|
|
3735
|
+
Input as Input7,
|
|
3736
|
+
Badge as Badge7,
|
|
4038
3737
|
Tooltip as Tooltip3,
|
|
4039
3738
|
TooltipTrigger as TooltipTrigger3,
|
|
4040
3739
|
TooltipContent as TooltipContent3,
|
|
4041
|
-
AlertDialog as
|
|
4042
|
-
AlertDialogAction as
|
|
4043
|
-
AlertDialogCancel as
|
|
4044
|
-
AlertDialogContent as
|
|
4045
|
-
AlertDialogDescription as
|
|
4046
|
-
AlertDialogFooter as
|
|
4047
|
-
AlertDialogHeader as
|
|
4048
|
-
AlertDialogTitle as
|
|
4049
|
-
Button as
|
|
3740
|
+
AlertDialog as AlertDialog3,
|
|
3741
|
+
AlertDialogAction as AlertDialogAction3,
|
|
3742
|
+
AlertDialogCancel as AlertDialogCancel3,
|
|
3743
|
+
AlertDialogContent as AlertDialogContent3,
|
|
3744
|
+
AlertDialogDescription as AlertDialogDescription3,
|
|
3745
|
+
AlertDialogFooter as AlertDialogFooter3,
|
|
3746
|
+
AlertDialogHeader as AlertDialogHeader3,
|
|
3747
|
+
AlertDialogTitle as AlertDialogTitle3,
|
|
3748
|
+
Button as Button11
|
|
4050
3749
|
} from "@greatapps/greatauth-ui/ui";
|
|
4051
|
-
import { Pencil as Pencil3, Trash2 as
|
|
3750
|
+
import { Pencil as Pencil3, Trash2 as Trash23, Search as Search2 } from "lucide-react";
|
|
4052
3751
|
import { format as format2 } from "date-fns";
|
|
4053
3752
|
import { ptBR as ptBR2 } from "date-fns/locale";
|
|
4054
|
-
import { toast as
|
|
4055
|
-
import { Fragment as Fragment2, jsx as
|
|
3753
|
+
import { toast as toast8 } from "sonner";
|
|
3754
|
+
import { Fragment as Fragment2, jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
4056
3755
|
function useColumns2(onEdit, onDelete) {
|
|
4057
3756
|
return [
|
|
4058
3757
|
{
|
|
4059
3758
|
accessorKey: "name",
|
|
4060
3759
|
header: "Nome",
|
|
4061
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
3760
|
+
cell: ({ row }) => /* @__PURE__ */ jsx18("span", { className: "font-medium", children: row.original.name }),
|
|
4062
3761
|
sortingFn: (rowA, rowB) => rowA.original.name.toLowerCase().localeCompare(rowB.original.name.toLowerCase())
|
|
4063
3762
|
},
|
|
4064
3763
|
{
|
|
4065
3764
|
accessorKey: "slug",
|
|
4066
3765
|
header: "Slug",
|
|
4067
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
3766
|
+
cell: ({ row }) => /* @__PURE__ */ jsx18("span", { className: "text-muted-foreground text-sm font-mono", children: row.original.slug || "\u2014" })
|
|
4068
3767
|
},
|
|
4069
3768
|
{
|
|
4070
3769
|
accessorKey: "type",
|
|
4071
3770
|
header: "Tipo",
|
|
4072
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
3771
|
+
cell: ({ row }) => /* @__PURE__ */ jsx18(Badge7, { variant: "secondary", children: row.original.type })
|
|
4073
3772
|
},
|
|
4074
3773
|
{
|
|
4075
3774
|
accessorKey: "description",
|
|
4076
3775
|
header: "Descri\xE7\xE3o",
|
|
4077
3776
|
cell: ({ row }) => {
|
|
4078
3777
|
const desc = row.original.description;
|
|
4079
|
-
if (!desc) return /* @__PURE__ */
|
|
4080
|
-
return /* @__PURE__ */
|
|
3778
|
+
if (!desc) return /* @__PURE__ */ jsx18("span", { className: "text-muted-foreground text-sm", children: "\u2014" });
|
|
3779
|
+
return /* @__PURE__ */ jsx18("span", { className: "text-muted-foreground text-sm", children: desc.length > 50 ? `${desc.slice(0, 50)}\u2026` : desc });
|
|
4081
3780
|
}
|
|
4082
3781
|
},
|
|
4083
3782
|
{
|
|
4084
3783
|
accessorKey: "datetime_add",
|
|
4085
3784
|
header: "Criado em",
|
|
4086
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
3785
|
+
cell: ({ row }) => /* @__PURE__ */ jsx18("span", { className: "text-muted-foreground text-sm", children: format2(new Date(row.original.datetime_add), "dd/MM/yyyy", {
|
|
4087
3786
|
locale: ptBR2
|
|
4088
3787
|
}) })
|
|
4089
3788
|
},
|
|
@@ -4091,42 +3790,42 @@ function useColumns2(onEdit, onDelete) {
|
|
|
4091
3790
|
id: "actions",
|
|
4092
3791
|
size: 80,
|
|
4093
3792
|
enableSorting: false,
|
|
4094
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
4095
|
-
/* @__PURE__ */
|
|
4096
|
-
/* @__PURE__ */
|
|
4097
|
-
|
|
3793
|
+
cell: ({ row }) => /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-1", children: [
|
|
3794
|
+
/* @__PURE__ */ jsxs16(Tooltip3, { children: [
|
|
3795
|
+
/* @__PURE__ */ jsx18(TooltipTrigger3, { asChild: true, children: /* @__PURE__ */ jsx18(
|
|
3796
|
+
Button11,
|
|
4098
3797
|
{
|
|
4099
3798
|
variant: "ghost",
|
|
4100
3799
|
size: "icon",
|
|
4101
3800
|
className: "h-8 w-8",
|
|
4102
3801
|
"aria-label": "Editar",
|
|
4103
3802
|
onClick: () => onEdit(row.original),
|
|
4104
|
-
children: /* @__PURE__ */
|
|
3803
|
+
children: /* @__PURE__ */ jsx18(Pencil3, { className: "h-4 w-4" })
|
|
4105
3804
|
}
|
|
4106
3805
|
) }),
|
|
4107
|
-
/* @__PURE__ */
|
|
3806
|
+
/* @__PURE__ */ jsx18(TooltipContent3, { children: "Editar" })
|
|
4108
3807
|
] }),
|
|
4109
|
-
/* @__PURE__ */
|
|
4110
|
-
/* @__PURE__ */
|
|
4111
|
-
|
|
3808
|
+
/* @__PURE__ */ jsxs16(Tooltip3, { children: [
|
|
3809
|
+
/* @__PURE__ */ jsx18(TooltipTrigger3, { asChild: true, children: /* @__PURE__ */ jsx18(
|
|
3810
|
+
Button11,
|
|
4112
3811
|
{
|
|
4113
3812
|
variant: "ghost",
|
|
4114
3813
|
size: "icon",
|
|
4115
3814
|
className: "h-8 w-8 text-destructive hover:text-destructive",
|
|
4116
3815
|
"aria-label": "Excluir",
|
|
4117
3816
|
onClick: () => onDelete(row.original.id),
|
|
4118
|
-
children: /* @__PURE__ */
|
|
3817
|
+
children: /* @__PURE__ */ jsx18(Trash23, { className: "h-4 w-4" })
|
|
4119
3818
|
}
|
|
4120
3819
|
) }),
|
|
4121
|
-
/* @__PURE__ */
|
|
3820
|
+
/* @__PURE__ */ jsx18(TooltipContent3, { children: "Excluir" })
|
|
4122
3821
|
] })
|
|
4123
3822
|
] })
|
|
4124
3823
|
}
|
|
4125
3824
|
];
|
|
4126
3825
|
}
|
|
4127
3826
|
function ToolsTable({ onEdit, config }) {
|
|
4128
|
-
const [search, setSearch] =
|
|
4129
|
-
const [page, setPage] =
|
|
3827
|
+
const [search, setSearch] = useState10("");
|
|
3828
|
+
const [page, setPage] = useState10(1);
|
|
4130
3829
|
const queryParams = useMemo6(() => {
|
|
4131
3830
|
const params = {
|
|
4132
3831
|
limit: "15",
|
|
@@ -4139,9 +3838,10 @@ function ToolsTable({ onEdit, config }) {
|
|
|
4139
3838
|
}, [search, page]);
|
|
4140
3839
|
const { data, isLoading } = useTools(config, queryParams);
|
|
4141
3840
|
const deleteTool = useDeleteTool(config);
|
|
4142
|
-
const [deleteId, setDeleteId] =
|
|
4143
|
-
const
|
|
4144
|
-
const
|
|
3841
|
+
const [deleteId, setDeleteId] = useState10(null);
|
|
3842
|
+
const rawTools = data?.data || [];
|
|
3843
|
+
const tools = rawTools.filter((t) => !t.slug?.startsWith("gclinic_"));
|
|
3844
|
+
const total = tools.length;
|
|
4145
3845
|
const columns = useColumns2(
|
|
4146
3846
|
(tool) => onEdit(tool),
|
|
4147
3847
|
(id) => setDeleteId(id)
|
|
@@ -4150,21 +3850,21 @@ function ToolsTable({ onEdit, config }) {
|
|
|
4150
3850
|
if (!deleteId) return;
|
|
4151
3851
|
deleteTool.mutate(deleteId, {
|
|
4152
3852
|
onSuccess: () => {
|
|
4153
|
-
|
|
3853
|
+
toast8.success("Ferramenta exclu\xEDda");
|
|
4154
3854
|
setDeleteId(null);
|
|
4155
3855
|
},
|
|
4156
|
-
onError: () =>
|
|
3856
|
+
onError: () => toast8.error("Erro ao excluir ferramenta")
|
|
4157
3857
|
});
|
|
4158
3858
|
}
|
|
4159
3859
|
function handleSearchChange(value) {
|
|
4160
3860
|
setSearch(value);
|
|
4161
3861
|
setPage(1);
|
|
4162
3862
|
}
|
|
4163
|
-
return /* @__PURE__ */
|
|
4164
|
-
/* @__PURE__ */
|
|
4165
|
-
/* @__PURE__ */
|
|
4166
|
-
/* @__PURE__ */
|
|
4167
|
-
|
|
3863
|
+
return /* @__PURE__ */ jsxs16(Fragment2, { children: [
|
|
3864
|
+
/* @__PURE__ */ jsx18("div", { className: "flex items-center gap-3", children: /* @__PURE__ */ jsxs16("div", { className: "relative flex-1 max-w-md", children: [
|
|
3865
|
+
/* @__PURE__ */ jsx18(Search2, { "aria-hidden": "true", className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
|
|
3866
|
+
/* @__PURE__ */ jsx18(
|
|
3867
|
+
Input7,
|
|
4168
3868
|
{
|
|
4169
3869
|
placeholder: "Buscar ferramentas\\u2026",
|
|
4170
3870
|
"aria-label": "Buscar ferramentas",
|
|
@@ -4176,7 +3876,7 @@ function ToolsTable({ onEdit, config }) {
|
|
|
4176
3876
|
}
|
|
4177
3877
|
)
|
|
4178
3878
|
] }) }),
|
|
4179
|
-
/* @__PURE__ */
|
|
3879
|
+
/* @__PURE__ */ jsx18(
|
|
4180
3880
|
DataTable2,
|
|
4181
3881
|
{
|
|
4182
3882
|
columns,
|
|
@@ -4189,20 +3889,20 @@ function ToolsTable({ onEdit, config }) {
|
|
|
4189
3889
|
pageSize: 15
|
|
4190
3890
|
}
|
|
4191
3891
|
),
|
|
4192
|
-
/* @__PURE__ */
|
|
4193
|
-
|
|
3892
|
+
/* @__PURE__ */ jsx18(
|
|
3893
|
+
AlertDialog3,
|
|
4194
3894
|
{
|
|
4195
3895
|
open: !!deleteId,
|
|
4196
3896
|
onOpenChange: (open) => !open && setDeleteId(null),
|
|
4197
|
-
children: /* @__PURE__ */
|
|
4198
|
-
/* @__PURE__ */
|
|
4199
|
-
/* @__PURE__ */
|
|
4200
|
-
/* @__PURE__ */
|
|
3897
|
+
children: /* @__PURE__ */ jsxs16(AlertDialogContent3, { children: [
|
|
3898
|
+
/* @__PURE__ */ jsxs16(AlertDialogHeader3, { children: [
|
|
3899
|
+
/* @__PURE__ */ jsx18(AlertDialogTitle3, { children: "Excluir ferramenta?" }),
|
|
3900
|
+
/* @__PURE__ */ jsx18(AlertDialogDescription3, { children: "Esta a\xE7\xE3o n\xE3o pode ser desfeita. A ferramenta ser\xE1 removida permanentemente." })
|
|
4201
3901
|
] }),
|
|
4202
|
-
/* @__PURE__ */
|
|
4203
|
-
/* @__PURE__ */
|
|
4204
|
-
/* @__PURE__ */
|
|
4205
|
-
|
|
3902
|
+
/* @__PURE__ */ jsxs16(AlertDialogFooter3, { children: [
|
|
3903
|
+
/* @__PURE__ */ jsx18(AlertDialogCancel3, { variant: "outline", size: "default", children: "Cancelar" }),
|
|
3904
|
+
/* @__PURE__ */ jsx18(
|
|
3905
|
+
AlertDialogAction3,
|
|
4206
3906
|
{
|
|
4207
3907
|
variant: "default",
|
|
4208
3908
|
size: "default",
|
|
@@ -4219,39 +3919,39 @@ function ToolsTable({ onEdit, config }) {
|
|
|
4219
3919
|
}
|
|
4220
3920
|
|
|
4221
3921
|
// src/components/tools/tool-credentials-form.tsx
|
|
4222
|
-
import { useMemo as useMemo7, useState as
|
|
3922
|
+
import { useMemo as useMemo7, useState as useState11 } from "react";
|
|
4223
3923
|
import { DataTable as DataTable3 } from "@greatapps/greatauth-ui";
|
|
4224
3924
|
import {
|
|
4225
|
-
Input as
|
|
4226
|
-
Button as
|
|
4227
|
-
Badge as
|
|
3925
|
+
Input as Input8,
|
|
3926
|
+
Button as Button12,
|
|
3927
|
+
Badge as Badge8,
|
|
4228
3928
|
Tooltip as Tooltip4,
|
|
4229
3929
|
TooltipTrigger as TooltipTrigger4,
|
|
4230
3930
|
TooltipContent as TooltipContent4,
|
|
4231
|
-
Dialog as
|
|
4232
|
-
DialogContent as
|
|
4233
|
-
DialogHeader as
|
|
4234
|
-
DialogTitle as
|
|
4235
|
-
DialogFooter as
|
|
4236
|
-
AlertDialog as
|
|
4237
|
-
AlertDialogAction as
|
|
4238
|
-
AlertDialogCancel as
|
|
4239
|
-
AlertDialogContent as
|
|
4240
|
-
AlertDialogDescription as
|
|
4241
|
-
AlertDialogFooter as
|
|
4242
|
-
AlertDialogHeader as
|
|
4243
|
-
AlertDialogTitle as
|
|
4244
|
-
Select as
|
|
4245
|
-
SelectContent as
|
|
4246
|
-
SelectItem as
|
|
4247
|
-
SelectTrigger as
|
|
4248
|
-
SelectValue as
|
|
3931
|
+
Dialog as Dialog5,
|
|
3932
|
+
DialogContent as DialogContent5,
|
|
3933
|
+
DialogHeader as DialogHeader5,
|
|
3934
|
+
DialogTitle as DialogTitle5,
|
|
3935
|
+
DialogFooter as DialogFooter5,
|
|
3936
|
+
AlertDialog as AlertDialog4,
|
|
3937
|
+
AlertDialogAction as AlertDialogAction4,
|
|
3938
|
+
AlertDialogCancel as AlertDialogCancel4,
|
|
3939
|
+
AlertDialogContent as AlertDialogContent4,
|
|
3940
|
+
AlertDialogDescription as AlertDialogDescription4,
|
|
3941
|
+
AlertDialogFooter as AlertDialogFooter4,
|
|
3942
|
+
AlertDialogHeader as AlertDialogHeader4,
|
|
3943
|
+
AlertDialogTitle as AlertDialogTitle4,
|
|
3944
|
+
Select as Select2,
|
|
3945
|
+
SelectContent as SelectContent2,
|
|
3946
|
+
SelectItem as SelectItem2,
|
|
3947
|
+
SelectTrigger as SelectTrigger2,
|
|
3948
|
+
SelectValue as SelectValue2
|
|
4249
3949
|
} from "@greatapps/greatauth-ui/ui";
|
|
4250
|
-
import { Trash2 as
|
|
3950
|
+
import { Trash2 as Trash24, Pencil as Pencil4, Link, Search as Search3 } from "lucide-react";
|
|
4251
3951
|
import { format as format3 } from "date-fns";
|
|
4252
3952
|
import { ptBR as ptBR3 } from "date-fns/locale";
|
|
4253
|
-
import { toast as
|
|
4254
|
-
import { jsx as
|
|
3953
|
+
import { toast as toast9 } from "sonner";
|
|
3954
|
+
import { jsx as jsx19, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
4255
3955
|
function formatDate2(dateStr) {
|
|
4256
3956
|
if (!dateStr) return "Sem expira\xE7\xE3o";
|
|
4257
3957
|
return format3(new Date(dateStr), "dd/MM/yyyy", { locale: ptBR3 });
|
|
@@ -4271,18 +3971,18 @@ function useColumns3(tools, onEdit, onConnect, onRemove) {
|
|
|
4271
3971
|
{
|
|
4272
3972
|
accessorKey: "label",
|
|
4273
3973
|
header: "Label",
|
|
4274
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
3974
|
+
cell: ({ row }) => /* @__PURE__ */ jsx19("span", { className: "font-medium", children: row.original.label || "\u2014" })
|
|
4275
3975
|
},
|
|
4276
3976
|
{
|
|
4277
3977
|
accessorKey: "id_tool",
|
|
4278
3978
|
header: "Ferramenta",
|
|
4279
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
3979
|
+
cell: ({ row }) => /* @__PURE__ */ jsx19("span", { className: "text-sm", children: getToolName(row.original.id_tool) })
|
|
4280
3980
|
},
|
|
4281
3981
|
{
|
|
4282
3982
|
accessorKey: "status",
|
|
4283
3983
|
header: "Status",
|
|
4284
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
4285
|
-
|
|
3984
|
+
cell: ({ row }) => /* @__PURE__ */ jsx19(
|
|
3985
|
+
Badge8,
|
|
4286
3986
|
{
|
|
4287
3987
|
variant: row.original.status === "active" ? "default" : "destructive",
|
|
4288
3988
|
children: row.original.status === "active" ? "Ativo" : "Expirado"
|
|
@@ -4292,60 +3992,60 @@ function useColumns3(tools, onEdit, onConnect, onRemove) {
|
|
|
4292
3992
|
{
|
|
4293
3993
|
accessorKey: "expires_at",
|
|
4294
3994
|
header: "Expira em",
|
|
4295
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
3995
|
+
cell: ({ row }) => /* @__PURE__ */ jsx19("span", { className: "text-muted-foreground text-sm", children: formatDate2(row.original.expires_at) })
|
|
4296
3996
|
},
|
|
4297
3997
|
{
|
|
4298
3998
|
accessorKey: "datetime_add",
|
|
4299
3999
|
header: "Criado em",
|
|
4300
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
4000
|
+
cell: ({ row }) => /* @__PURE__ */ jsx19("span", { className: "text-muted-foreground text-sm", children: formatDate2(row.original.datetime_add) })
|
|
4301
4001
|
},
|
|
4302
4002
|
{
|
|
4303
4003
|
id: "actions",
|
|
4304
4004
|
header: "A\xE7\xF5es",
|
|
4305
4005
|
size: 100,
|
|
4306
4006
|
enableSorting: false,
|
|
4307
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
4308
|
-
getToolType(row.original.id_tool) === "oauth2" && /* @__PURE__ */
|
|
4309
|
-
/* @__PURE__ */
|
|
4310
|
-
|
|
4007
|
+
cell: ({ row }) => /* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-1", children: [
|
|
4008
|
+
getToolType(row.original.id_tool) === "oauth2" && /* @__PURE__ */ jsxs17(Tooltip4, { children: [
|
|
4009
|
+
/* @__PURE__ */ jsx19(TooltipTrigger4, { asChild: true, children: /* @__PURE__ */ jsx19(
|
|
4010
|
+
Button12,
|
|
4311
4011
|
{
|
|
4312
4012
|
variant: "ghost",
|
|
4313
4013
|
size: "icon",
|
|
4314
4014
|
className: "h-8 w-8",
|
|
4315
4015
|
"aria-label": "Vincular",
|
|
4316
4016
|
disabled: true,
|
|
4317
|
-
children: /* @__PURE__ */
|
|
4017
|
+
children: /* @__PURE__ */ jsx19(Link, { className: "h-4 w-4" })
|
|
4318
4018
|
}
|
|
4319
4019
|
) }),
|
|
4320
|
-
/* @__PURE__ */
|
|
4020
|
+
/* @__PURE__ */ jsx19(TooltipContent4, { children: "Em breve" })
|
|
4321
4021
|
] }),
|
|
4322
|
-
/* @__PURE__ */
|
|
4323
|
-
/* @__PURE__ */
|
|
4324
|
-
|
|
4022
|
+
/* @__PURE__ */ jsxs17(Tooltip4, { children: [
|
|
4023
|
+
/* @__PURE__ */ jsx19(TooltipTrigger4, { asChild: true, children: /* @__PURE__ */ jsx19(
|
|
4024
|
+
Button12,
|
|
4325
4025
|
{
|
|
4326
4026
|
variant: "ghost",
|
|
4327
4027
|
size: "icon",
|
|
4328
4028
|
className: "h-8 w-8",
|
|
4329
4029
|
"aria-label": "Editar",
|
|
4330
4030
|
onClick: () => onEdit(row.original),
|
|
4331
|
-
children: /* @__PURE__ */
|
|
4031
|
+
children: /* @__PURE__ */ jsx19(Pencil4, { className: "h-4 w-4" })
|
|
4332
4032
|
}
|
|
4333
4033
|
) }),
|
|
4334
|
-
/* @__PURE__ */
|
|
4034
|
+
/* @__PURE__ */ jsx19(TooltipContent4, { children: "Editar" })
|
|
4335
4035
|
] }),
|
|
4336
|
-
/* @__PURE__ */
|
|
4337
|
-
/* @__PURE__ */
|
|
4338
|
-
|
|
4036
|
+
/* @__PURE__ */ jsxs17(Tooltip4, { children: [
|
|
4037
|
+
/* @__PURE__ */ jsx19(TooltipTrigger4, { asChild: true, children: /* @__PURE__ */ jsx19(
|
|
4038
|
+
Button12,
|
|
4339
4039
|
{
|
|
4340
4040
|
variant: "ghost",
|
|
4341
4041
|
size: "icon",
|
|
4342
4042
|
className: "h-8 w-8 text-destructive hover:text-destructive",
|
|
4343
4043
|
"aria-label": "Excluir",
|
|
4344
4044
|
onClick: () => onRemove(row.original),
|
|
4345
|
-
children: /* @__PURE__ */
|
|
4045
|
+
children: /* @__PURE__ */ jsx19(Trash24, { className: "h-4 w-4" })
|
|
4346
4046
|
}
|
|
4347
4047
|
) }),
|
|
4348
|
-
/* @__PURE__ */
|
|
4048
|
+
/* @__PURE__ */ jsx19(TooltipContent4, { children: "Remover" })
|
|
4349
4049
|
] })
|
|
4350
4050
|
] })
|
|
4351
4051
|
}
|
|
@@ -4363,34 +4063,43 @@ function ToolCredentialsForm({
|
|
|
4363
4063
|
const updateMutation = useUpdateToolCredential(config);
|
|
4364
4064
|
const deleteMutation = useDeleteToolCredential(config);
|
|
4365
4065
|
const { data: toolsData } = useTools(config);
|
|
4366
|
-
const tools = toolsData?.data || [];
|
|
4367
|
-
const [search, setSearch] =
|
|
4368
|
-
const [internalCreateOpen, setInternalCreateOpen] =
|
|
4066
|
+
const tools = (toolsData?.data || []).filter((t) => !t.slug?.startsWith("gclinic_"));
|
|
4067
|
+
const [search, setSearch] = useState11("");
|
|
4068
|
+
const [internalCreateOpen, setInternalCreateOpen] = useState11(false);
|
|
4369
4069
|
const showCreateDialog = externalCreateOpen ?? internalCreateOpen;
|
|
4370
4070
|
const setShowCreateDialog = onCreateOpenChange ?? setInternalCreateOpen;
|
|
4371
|
-
const [createForm, setCreateForm] =
|
|
4071
|
+
const [createForm, setCreateForm] = useState11({
|
|
4372
4072
|
id_tool: "",
|
|
4373
4073
|
label: "",
|
|
4374
4074
|
credentials_encrypted: "",
|
|
4375
4075
|
expires_at: ""
|
|
4376
4076
|
});
|
|
4377
|
-
const [editTarget, setEditTarget] =
|
|
4378
|
-
const [editForm, setEditForm] =
|
|
4077
|
+
const [editTarget, setEditTarget] = useState11(null);
|
|
4078
|
+
const [editForm, setEditForm] = useState11({
|
|
4379
4079
|
id_tool: "",
|
|
4380
4080
|
label: "",
|
|
4381
4081
|
credentials_encrypted: "",
|
|
4382
4082
|
expires_at: "",
|
|
4383
4083
|
status: ""
|
|
4384
4084
|
});
|
|
4385
|
-
const [removeTarget, setRemoveTarget] =
|
|
4085
|
+
const [removeTarget, setRemoveTarget] = useState11(null);
|
|
4086
|
+
const internalToolIds = useMemo7(() => {
|
|
4087
|
+
const allRawTools = toolsData?.data || [];
|
|
4088
|
+
return new Set(
|
|
4089
|
+
allRawTools.filter((t) => t.slug?.startsWith("gclinic_")).map((t) => t.id)
|
|
4090
|
+
);
|
|
4091
|
+
}, [toolsData]);
|
|
4386
4092
|
const filteredCredentials = useMemo7(() => {
|
|
4387
|
-
|
|
4093
|
+
const visible = credentials.filter(
|
|
4094
|
+
(cred) => !cred.id_tool || !internalToolIds.has(cred.id_tool)
|
|
4095
|
+
);
|
|
4096
|
+
if (!search) return visible;
|
|
4388
4097
|
const term = search.toLowerCase();
|
|
4389
|
-
return
|
|
4098
|
+
return visible.filter((cred) => {
|
|
4390
4099
|
const toolName = tools.find((t) => t.id === cred.id_tool)?.name || "";
|
|
4391
4100
|
return (cred.label || "").toLowerCase().includes(term) || toolName.toLowerCase().includes(term);
|
|
4392
4101
|
});
|
|
4393
|
-
}, [credentials, search, tools]);
|
|
4102
|
+
}, [credentials, search, tools, internalToolIds]);
|
|
4394
4103
|
const columns = useColumns3(
|
|
4395
4104
|
tools,
|
|
4396
4105
|
(cred) => startEdit(cred),
|
|
@@ -4408,14 +4117,14 @@ function ToolCredentialsForm({
|
|
|
4408
4117
|
...createForm.expires_at ? { expires_at: createForm.expires_at } : {}
|
|
4409
4118
|
});
|
|
4410
4119
|
if (result.status === 1) {
|
|
4411
|
-
|
|
4120
|
+
toast9.success("Credencial criada");
|
|
4412
4121
|
setShowCreateDialog(false);
|
|
4413
4122
|
setCreateForm({ id_tool: "", label: "", credentials_encrypted: "", expires_at: "" });
|
|
4414
4123
|
} else {
|
|
4415
|
-
|
|
4124
|
+
toast9.error(result.message || "Erro ao criar credencial");
|
|
4416
4125
|
}
|
|
4417
4126
|
} catch {
|
|
4418
|
-
|
|
4127
|
+
toast9.error("Erro ao criar credencial");
|
|
4419
4128
|
}
|
|
4420
4129
|
}
|
|
4421
4130
|
function startEdit(cred) {
|
|
@@ -4457,13 +4166,13 @@ function ToolCredentialsForm({
|
|
|
4457
4166
|
body
|
|
4458
4167
|
});
|
|
4459
4168
|
if (result.status === 1) {
|
|
4460
|
-
|
|
4169
|
+
toast9.success("Credencial atualizada");
|
|
4461
4170
|
setEditTarget(null);
|
|
4462
4171
|
} else {
|
|
4463
|
-
|
|
4172
|
+
toast9.error(result.message || "Erro ao atualizar credencial");
|
|
4464
4173
|
}
|
|
4465
4174
|
} catch {
|
|
4466
|
-
|
|
4175
|
+
toast9.error("Erro ao atualizar credencial");
|
|
4467
4176
|
}
|
|
4468
4177
|
}
|
|
4469
4178
|
async function handleRemove() {
|
|
@@ -4471,12 +4180,12 @@ function ToolCredentialsForm({
|
|
|
4471
4180
|
try {
|
|
4472
4181
|
const result = await deleteMutation.mutateAsync(removeTarget.id);
|
|
4473
4182
|
if (result.status === 1) {
|
|
4474
|
-
|
|
4183
|
+
toast9.success("Credencial removida");
|
|
4475
4184
|
} else {
|
|
4476
|
-
|
|
4185
|
+
toast9.error(result.message || "Erro ao remover credencial");
|
|
4477
4186
|
}
|
|
4478
4187
|
} catch {
|
|
4479
|
-
|
|
4188
|
+
toast9.error("Erro ao remover credencial");
|
|
4480
4189
|
} finally {
|
|
4481
4190
|
setRemoveTarget(null);
|
|
4482
4191
|
}
|
|
@@ -4488,11 +4197,11 @@ function ToolCredentialsForm({
|
|
|
4488
4197
|
const url = `${gagentsApiUrl}/v1/${language}/${idWl}/accounts/${config.accountId}/oauth/connect?id_tool=${cred.id_tool}`;
|
|
4489
4198
|
window.open(url, "_blank");
|
|
4490
4199
|
}
|
|
4491
|
-
return /* @__PURE__ */
|
|
4492
|
-
/* @__PURE__ */
|
|
4493
|
-
/* @__PURE__ */
|
|
4494
|
-
/* @__PURE__ */
|
|
4495
|
-
|
|
4200
|
+
return /* @__PURE__ */ jsxs17("div", { className: "space-y-4", children: [
|
|
4201
|
+
/* @__PURE__ */ jsx19("div", { className: "flex items-center gap-3", children: /* @__PURE__ */ jsxs17("div", { className: "relative flex-1 max-w-md", children: [
|
|
4202
|
+
/* @__PURE__ */ jsx19(Search3, { "aria-hidden": "true", className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
|
|
4203
|
+
/* @__PURE__ */ jsx19(
|
|
4204
|
+
Input8,
|
|
4496
4205
|
{
|
|
4497
4206
|
placeholder: "Buscar credenciais\\u2026",
|
|
4498
4207
|
"aria-label": "Buscar credenciais",
|
|
@@ -4504,7 +4213,7 @@ function ToolCredentialsForm({
|
|
|
4504
4213
|
}
|
|
4505
4214
|
)
|
|
4506
4215
|
] }) }),
|
|
4507
|
-
/* @__PURE__ */
|
|
4216
|
+
/* @__PURE__ */ jsx19(
|
|
4508
4217
|
DataTable3,
|
|
4509
4218
|
{
|
|
4510
4219
|
columns,
|
|
@@ -4513,27 +4222,27 @@ function ToolCredentialsForm({
|
|
|
4513
4222
|
emptyMessage: "Nenhuma credencial encontrada"
|
|
4514
4223
|
}
|
|
4515
4224
|
),
|
|
4516
|
-
/* @__PURE__ */
|
|
4517
|
-
/* @__PURE__ */
|
|
4518
|
-
/* @__PURE__ */
|
|
4519
|
-
/* @__PURE__ */
|
|
4520
|
-
/* @__PURE__ */
|
|
4521
|
-
/* @__PURE__ */
|
|
4522
|
-
|
|
4225
|
+
/* @__PURE__ */ jsx19(Dialog5, { open: showCreateDialog, onOpenChange: setShowCreateDialog, children: /* @__PURE__ */ jsxs17(DialogContent5, { children: [
|
|
4226
|
+
/* @__PURE__ */ jsx19(DialogHeader5, { children: /* @__PURE__ */ jsx19(DialogTitle5, { children: "Nova Credencial" }) }),
|
|
4227
|
+
/* @__PURE__ */ jsxs17("div", { className: "space-y-4", children: [
|
|
4228
|
+
/* @__PURE__ */ jsxs17("div", { children: [
|
|
4229
|
+
/* @__PURE__ */ jsx19("label", { htmlFor: "cred-tool", className: "mb-1 block text-sm font-medium", children: "Ferramenta *" }),
|
|
4230
|
+
/* @__PURE__ */ jsxs17(
|
|
4231
|
+
Select2,
|
|
4523
4232
|
{
|
|
4524
4233
|
value: createForm.id_tool,
|
|
4525
4234
|
onValueChange: (val) => setCreateForm((f) => ({ ...f, id_tool: val })),
|
|
4526
4235
|
children: [
|
|
4527
|
-
/* @__PURE__ */
|
|
4528
|
-
/* @__PURE__ */
|
|
4236
|
+
/* @__PURE__ */ jsx19(SelectTrigger2, { id: "cred-tool", children: /* @__PURE__ */ jsx19(SelectValue2, { placeholder: "Selecione a ferramenta" }) }),
|
|
4237
|
+
/* @__PURE__ */ jsx19(SelectContent2, { children: tools.map((tool) => /* @__PURE__ */ jsx19(SelectItem2, { value: String(tool.id), children: tool.name }, tool.id)) })
|
|
4529
4238
|
]
|
|
4530
4239
|
}
|
|
4531
4240
|
)
|
|
4532
4241
|
] }),
|
|
4533
|
-
/* @__PURE__ */
|
|
4534
|
-
/* @__PURE__ */
|
|
4535
|
-
/* @__PURE__ */
|
|
4536
|
-
|
|
4242
|
+
/* @__PURE__ */ jsxs17("div", { children: [
|
|
4243
|
+
/* @__PURE__ */ jsx19("label", { htmlFor: "cred-label", className: "mb-1 block text-sm font-medium", children: "Label *" }),
|
|
4244
|
+
/* @__PURE__ */ jsx19(
|
|
4245
|
+
Input8,
|
|
4537
4246
|
{
|
|
4538
4247
|
id: "cred-label",
|
|
4539
4248
|
name: "label",
|
|
@@ -4543,10 +4252,10 @@ function ToolCredentialsForm({
|
|
|
4543
4252
|
}
|
|
4544
4253
|
)
|
|
4545
4254
|
] }),
|
|
4546
|
-
/* @__PURE__ */
|
|
4547
|
-
/* @__PURE__ */
|
|
4548
|
-
/* @__PURE__ */
|
|
4549
|
-
|
|
4255
|
+
/* @__PURE__ */ jsxs17("div", { children: [
|
|
4256
|
+
/* @__PURE__ */ jsx19("label", { htmlFor: "cred-credential", className: "mb-1 block text-sm font-medium", children: "Credencial *" }),
|
|
4257
|
+
/* @__PURE__ */ jsx19(
|
|
4258
|
+
Input8,
|
|
4550
4259
|
{
|
|
4551
4260
|
id: "cred-credential",
|
|
4552
4261
|
name: "credential",
|
|
@@ -4561,10 +4270,10 @@ function ToolCredentialsForm({
|
|
|
4561
4270
|
}
|
|
4562
4271
|
)
|
|
4563
4272
|
] }),
|
|
4564
|
-
/* @__PURE__ */
|
|
4565
|
-
/* @__PURE__ */
|
|
4566
|
-
/* @__PURE__ */
|
|
4567
|
-
|
|
4273
|
+
/* @__PURE__ */ jsxs17("div", { children: [
|
|
4274
|
+
/* @__PURE__ */ jsx19("label", { htmlFor: "cred-expires", className: "mb-1 block text-sm font-medium", children: "Data de Expira\xE7\xE3o (opcional)" }),
|
|
4275
|
+
/* @__PURE__ */ jsx19(
|
|
4276
|
+
Input8,
|
|
4568
4277
|
{
|
|
4569
4278
|
id: "cred-expires",
|
|
4570
4279
|
name: "expires",
|
|
@@ -4575,17 +4284,17 @@ function ToolCredentialsForm({
|
|
|
4575
4284
|
)
|
|
4576
4285
|
] })
|
|
4577
4286
|
] }),
|
|
4578
|
-
/* @__PURE__ */
|
|
4579
|
-
/* @__PURE__ */
|
|
4580
|
-
|
|
4287
|
+
/* @__PURE__ */ jsxs17(DialogFooter5, { children: [
|
|
4288
|
+
/* @__PURE__ */ jsx19(
|
|
4289
|
+
Button12,
|
|
4581
4290
|
{
|
|
4582
4291
|
variant: "outline",
|
|
4583
4292
|
onClick: () => setShowCreateDialog(false),
|
|
4584
4293
|
children: "Cancelar"
|
|
4585
4294
|
}
|
|
4586
4295
|
),
|
|
4587
|
-
/* @__PURE__ */
|
|
4588
|
-
|
|
4296
|
+
/* @__PURE__ */ jsx19(
|
|
4297
|
+
Button12,
|
|
4589
4298
|
{
|
|
4590
4299
|
onClick: handleCreate,
|
|
4591
4300
|
disabled: !createForm.id_tool || !createForm.label.trim() || !createForm.credentials_encrypted.trim() || createMutation.isPending,
|
|
@@ -4594,32 +4303,32 @@ function ToolCredentialsForm({
|
|
|
4594
4303
|
)
|
|
4595
4304
|
] })
|
|
4596
4305
|
] }) }),
|
|
4597
|
-
/* @__PURE__ */
|
|
4598
|
-
|
|
4306
|
+
/* @__PURE__ */ jsx19(
|
|
4307
|
+
Dialog5,
|
|
4599
4308
|
{
|
|
4600
4309
|
open: !!editTarget,
|
|
4601
4310
|
onOpenChange: (open) => !open && setEditTarget(null),
|
|
4602
|
-
children: /* @__PURE__ */
|
|
4603
|
-
/* @__PURE__ */
|
|
4604
|
-
/* @__PURE__ */
|
|
4605
|
-
/* @__PURE__ */
|
|
4606
|
-
/* @__PURE__ */
|
|
4607
|
-
/* @__PURE__ */
|
|
4608
|
-
|
|
4311
|
+
children: /* @__PURE__ */ jsxs17(DialogContent5, { children: [
|
|
4312
|
+
/* @__PURE__ */ jsx19(DialogHeader5, { children: /* @__PURE__ */ jsx19(DialogTitle5, { children: "Editar Credencial" }) }),
|
|
4313
|
+
/* @__PURE__ */ jsxs17("div", { className: "space-y-4", children: [
|
|
4314
|
+
/* @__PURE__ */ jsxs17("div", { children: [
|
|
4315
|
+
/* @__PURE__ */ jsx19("label", { htmlFor: "edit-cred-tool", className: "mb-1 block text-sm font-medium", children: "Ferramenta *" }),
|
|
4316
|
+
/* @__PURE__ */ jsxs17(
|
|
4317
|
+
Select2,
|
|
4609
4318
|
{
|
|
4610
4319
|
value: editForm.id_tool,
|
|
4611
4320
|
onValueChange: (val) => setEditForm((f) => ({ ...f, id_tool: val })),
|
|
4612
4321
|
children: [
|
|
4613
|
-
/* @__PURE__ */
|
|
4614
|
-
/* @__PURE__ */
|
|
4322
|
+
/* @__PURE__ */ jsx19(SelectTrigger2, { id: "edit-cred-tool", children: /* @__PURE__ */ jsx19(SelectValue2, { placeholder: "Selecione a ferramenta" }) }),
|
|
4323
|
+
/* @__PURE__ */ jsx19(SelectContent2, { children: tools.map((tool) => /* @__PURE__ */ jsx19(SelectItem2, { value: String(tool.id), children: tool.name }, tool.id)) })
|
|
4615
4324
|
]
|
|
4616
4325
|
}
|
|
4617
4326
|
)
|
|
4618
4327
|
] }),
|
|
4619
|
-
/* @__PURE__ */
|
|
4620
|
-
/* @__PURE__ */
|
|
4621
|
-
/* @__PURE__ */
|
|
4622
|
-
|
|
4328
|
+
/* @__PURE__ */ jsxs17("div", { children: [
|
|
4329
|
+
/* @__PURE__ */ jsx19("label", { htmlFor: "edit-cred-label", className: "mb-1 block text-sm font-medium", children: "Label" }),
|
|
4330
|
+
/* @__PURE__ */ jsx19(
|
|
4331
|
+
Input8,
|
|
4623
4332
|
{
|
|
4624
4333
|
id: "edit-cred-label",
|
|
4625
4334
|
name: "label",
|
|
@@ -4629,10 +4338,10 @@ function ToolCredentialsForm({
|
|
|
4629
4338
|
}
|
|
4630
4339
|
)
|
|
4631
4340
|
] }),
|
|
4632
|
-
/* @__PURE__ */
|
|
4633
|
-
/* @__PURE__ */
|
|
4634
|
-
/* @__PURE__ */
|
|
4635
|
-
|
|
4341
|
+
/* @__PURE__ */ jsxs17("div", { children: [
|
|
4342
|
+
/* @__PURE__ */ jsx19("label", { htmlFor: "edit-cred-credential", className: "mb-1 block text-sm font-medium", children: "Nova Credencial (vazio = manter atual)" }),
|
|
4343
|
+
/* @__PURE__ */ jsx19(
|
|
4344
|
+
Input8,
|
|
4636
4345
|
{
|
|
4637
4346
|
id: "edit-cred-credential",
|
|
4638
4347
|
name: "credential",
|
|
@@ -4647,10 +4356,10 @@ function ToolCredentialsForm({
|
|
|
4647
4356
|
}
|
|
4648
4357
|
)
|
|
4649
4358
|
] }),
|
|
4650
|
-
/* @__PURE__ */
|
|
4651
|
-
/* @__PURE__ */
|
|
4652
|
-
/* @__PURE__ */
|
|
4653
|
-
|
|
4359
|
+
/* @__PURE__ */ jsxs17("div", { children: [
|
|
4360
|
+
/* @__PURE__ */ jsx19("label", { htmlFor: "edit-cred-expires", className: "mb-1 block text-sm font-medium", children: "Data de Expira\xE7\xE3o" }),
|
|
4361
|
+
/* @__PURE__ */ jsx19(
|
|
4362
|
+
Input8,
|
|
4654
4363
|
{
|
|
4655
4364
|
id: "edit-cred-expires",
|
|
4656
4365
|
name: "expires",
|
|
@@ -4660,10 +4369,10 @@ function ToolCredentialsForm({
|
|
|
4660
4369
|
}
|
|
4661
4370
|
)
|
|
4662
4371
|
] }),
|
|
4663
|
-
/* @__PURE__ */
|
|
4664
|
-
/* @__PURE__ */
|
|
4665
|
-
/* @__PURE__ */
|
|
4666
|
-
|
|
4372
|
+
/* @__PURE__ */ jsxs17("div", { children: [
|
|
4373
|
+
/* @__PURE__ */ jsx19("label", { htmlFor: "edit-cred-status", className: "mb-1 block text-sm font-medium", children: "Status" }),
|
|
4374
|
+
/* @__PURE__ */ jsxs17(
|
|
4375
|
+
Select2,
|
|
4667
4376
|
{
|
|
4668
4377
|
value: editForm.status || void 0,
|
|
4669
4378
|
onValueChange: (val) => setEditForm((f) => ({
|
|
@@ -4671,20 +4380,20 @@ function ToolCredentialsForm({
|
|
|
4671
4380
|
status: val
|
|
4672
4381
|
})),
|
|
4673
4382
|
children: [
|
|
4674
|
-
/* @__PURE__ */
|
|
4675
|
-
/* @__PURE__ */
|
|
4676
|
-
/* @__PURE__ */
|
|
4677
|
-
/* @__PURE__ */
|
|
4383
|
+
/* @__PURE__ */ jsx19(SelectTrigger2, { id: "edit-cred-status", children: /* @__PURE__ */ jsx19(SelectValue2, {}) }),
|
|
4384
|
+
/* @__PURE__ */ jsxs17(SelectContent2, { children: [
|
|
4385
|
+
/* @__PURE__ */ jsx19(SelectItem2, { value: "active", children: "Ativo" }),
|
|
4386
|
+
/* @__PURE__ */ jsx19(SelectItem2, { value: "expired", children: "Expirado" })
|
|
4678
4387
|
] })
|
|
4679
4388
|
]
|
|
4680
4389
|
}
|
|
4681
4390
|
)
|
|
4682
4391
|
] })
|
|
4683
4392
|
] }),
|
|
4684
|
-
/* @__PURE__ */
|
|
4685
|
-
/* @__PURE__ */
|
|
4686
|
-
/* @__PURE__ */
|
|
4687
|
-
|
|
4393
|
+
/* @__PURE__ */ jsxs17(DialogFooter5, { children: [
|
|
4394
|
+
/* @__PURE__ */ jsx19(Button12, { variant: "outline", onClick: () => setEditTarget(null), children: "Cancelar" }),
|
|
4395
|
+
/* @__PURE__ */ jsx19(
|
|
4396
|
+
Button12,
|
|
4688
4397
|
{
|
|
4689
4398
|
onClick: handleSaveEdit,
|
|
4690
4399
|
disabled: updateMutation.isPending,
|
|
@@ -4695,20 +4404,20 @@ function ToolCredentialsForm({
|
|
|
4695
4404
|
] })
|
|
4696
4405
|
}
|
|
4697
4406
|
),
|
|
4698
|
-
/* @__PURE__ */
|
|
4699
|
-
|
|
4407
|
+
/* @__PURE__ */ jsx19(
|
|
4408
|
+
AlertDialog4,
|
|
4700
4409
|
{
|
|
4701
4410
|
open: !!removeTarget,
|
|
4702
4411
|
onOpenChange: (open) => !open && setRemoveTarget(null),
|
|
4703
|
-
children: /* @__PURE__ */
|
|
4704
|
-
/* @__PURE__ */
|
|
4705
|
-
/* @__PURE__ */
|
|
4706
|
-
/* @__PURE__ */
|
|
4412
|
+
children: /* @__PURE__ */ jsxs17(AlertDialogContent4, { children: [
|
|
4413
|
+
/* @__PURE__ */ jsxs17(AlertDialogHeader4, { children: [
|
|
4414
|
+
/* @__PURE__ */ jsx19(AlertDialogTitle4, { children: "Remover credencial?" }),
|
|
4415
|
+
/* @__PURE__ */ jsx19(AlertDialogDescription4, { children: "A credencial ser\xE1 removida permanentemente." })
|
|
4707
4416
|
] }),
|
|
4708
|
-
/* @__PURE__ */
|
|
4709
|
-
/* @__PURE__ */
|
|
4710
|
-
/* @__PURE__ */
|
|
4711
|
-
|
|
4417
|
+
/* @__PURE__ */ jsxs17(AlertDialogFooter4, { children: [
|
|
4418
|
+
/* @__PURE__ */ jsx19(AlertDialogCancel4, { children: "Cancelar" }),
|
|
4419
|
+
/* @__PURE__ */ jsx19(
|
|
4420
|
+
AlertDialogAction4,
|
|
4712
4421
|
{
|
|
4713
4422
|
onClick: handleRemove,
|
|
4714
4423
|
disabled: deleteMutation.isPending,
|
|
@@ -4723,26 +4432,26 @@ function ToolCredentialsForm({
|
|
|
4723
4432
|
}
|
|
4724
4433
|
|
|
4725
4434
|
// src/components/tools/tool-form-dialog.tsx
|
|
4726
|
-
import { useState as
|
|
4435
|
+
import { useState as useState12 } from "react";
|
|
4727
4436
|
import {
|
|
4728
|
-
Dialog as
|
|
4729
|
-
DialogContent as
|
|
4730
|
-
DialogHeader as
|
|
4731
|
-
DialogTitle as
|
|
4732
|
-
DialogFooter as
|
|
4733
|
-
Button as
|
|
4734
|
-
Input as
|
|
4735
|
-
Textarea as
|
|
4736
|
-
Label as
|
|
4737
|
-
Select as
|
|
4738
|
-
SelectContent as
|
|
4739
|
-
SelectItem as
|
|
4740
|
-
SelectTrigger as
|
|
4741
|
-
SelectValue as
|
|
4437
|
+
Dialog as Dialog6,
|
|
4438
|
+
DialogContent as DialogContent6,
|
|
4439
|
+
DialogHeader as DialogHeader6,
|
|
4440
|
+
DialogTitle as DialogTitle6,
|
|
4441
|
+
DialogFooter as DialogFooter6,
|
|
4442
|
+
Button as Button13,
|
|
4443
|
+
Input as Input9,
|
|
4444
|
+
Textarea as Textarea2,
|
|
4445
|
+
Label as Label7,
|
|
4446
|
+
Select as Select3,
|
|
4447
|
+
SelectContent as SelectContent3,
|
|
4448
|
+
SelectItem as SelectItem3,
|
|
4449
|
+
SelectTrigger as SelectTrigger3,
|
|
4450
|
+
SelectValue as SelectValue3
|
|
4742
4451
|
} from "@greatapps/greatauth-ui/ui";
|
|
4743
4452
|
import { Loader2 as Loader28 } from "lucide-react";
|
|
4744
|
-
import { toast as
|
|
4745
|
-
import { jsx as
|
|
4453
|
+
import { toast as toast10 } from "sonner";
|
|
4454
|
+
import { jsx as jsx20, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
4746
4455
|
var TOOL_AUTH_TYPES = [
|
|
4747
4456
|
{ value: "none", label: "Nenhuma" },
|
|
4748
4457
|
{ value: "api_key", label: "API Key" },
|
|
@@ -4789,9 +4498,9 @@ function ToolFormDialog({
|
|
|
4789
4498
|
const isEditing = !!tool;
|
|
4790
4499
|
const createTool = useCreateTool(config);
|
|
4791
4500
|
const updateTool = useUpdateTool(config);
|
|
4792
|
-
const [form, setForm] =
|
|
4793
|
-
const [slugManuallyEdited, setSlugManuallyEdited] =
|
|
4794
|
-
const [lastResetKey, setLastResetKey] =
|
|
4501
|
+
const [form, setForm] = useState12(() => toolToFormState(tool));
|
|
4502
|
+
const [slugManuallyEdited, setSlugManuallyEdited] = useState12(false);
|
|
4503
|
+
const [lastResetKey, setLastResetKey] = useState12(
|
|
4795
4504
|
() => `${tool?.id}-${open}`
|
|
4796
4505
|
);
|
|
4797
4506
|
const resetKey = `${tool?.id}-${open}`;
|
|
@@ -4838,27 +4547,27 @@ function ToolFormDialog({
|
|
|
4838
4547
|
try {
|
|
4839
4548
|
if (isEditing) {
|
|
4840
4549
|
await updateTool.mutateAsync({ id: tool.id, body });
|
|
4841
|
-
|
|
4550
|
+
toast10.success("Ferramenta atualizada");
|
|
4842
4551
|
} else {
|
|
4843
4552
|
await createTool.mutateAsync(
|
|
4844
4553
|
body
|
|
4845
4554
|
);
|
|
4846
|
-
|
|
4555
|
+
toast10.success("Ferramenta criada");
|
|
4847
4556
|
}
|
|
4848
4557
|
onOpenChange(false);
|
|
4849
4558
|
} catch (err) {
|
|
4850
|
-
|
|
4559
|
+
toast10.error(
|
|
4851
4560
|
err instanceof Error ? err.message : isEditing ? "Erro ao atualizar ferramenta" : "Erro ao criar ferramenta"
|
|
4852
4561
|
);
|
|
4853
4562
|
}
|
|
4854
4563
|
}
|
|
4855
|
-
return /* @__PURE__ */
|
|
4856
|
-
/* @__PURE__ */
|
|
4857
|
-
/* @__PURE__ */
|
|
4858
|
-
/* @__PURE__ */
|
|
4859
|
-
/* @__PURE__ */
|
|
4860
|
-
/* @__PURE__ */
|
|
4861
|
-
|
|
4564
|
+
return /* @__PURE__ */ jsx20(Dialog6, { open, onOpenChange, children: /* @__PURE__ */ jsxs18(DialogContent6, { className: "sm:max-w-lg", children: [
|
|
4565
|
+
/* @__PURE__ */ jsx20(DialogHeader6, { children: /* @__PURE__ */ jsx20(DialogTitle6, { children: isEditing ? "Editar Ferramenta" : "Nova Ferramenta" }) }),
|
|
4566
|
+
/* @__PURE__ */ jsxs18("form", { onSubmit: handleSubmit, className: "space-y-4", children: [
|
|
4567
|
+
/* @__PURE__ */ jsxs18("div", { className: "space-y-2", children: [
|
|
4568
|
+
/* @__PURE__ */ jsx20(Label7, { htmlFor: "tool-name", children: "Nome *" }),
|
|
4569
|
+
/* @__PURE__ */ jsx20(
|
|
4570
|
+
Input9,
|
|
4862
4571
|
{
|
|
4863
4572
|
id: "tool-name",
|
|
4864
4573
|
name: "name",
|
|
@@ -4876,12 +4585,12 @@ function ToolFormDialog({
|
|
|
4876
4585
|
disabled: isPending
|
|
4877
4586
|
}
|
|
4878
4587
|
),
|
|
4879
|
-
form.nameError && /* @__PURE__ */
|
|
4588
|
+
form.nameError && /* @__PURE__ */ jsx20("p", { className: "text-sm text-destructive", children: "Nome \xE9 obrigat\xF3rio" })
|
|
4880
4589
|
] }),
|
|
4881
|
-
/* @__PURE__ */
|
|
4882
|
-
/* @__PURE__ */
|
|
4883
|
-
/* @__PURE__ */
|
|
4884
|
-
|
|
4590
|
+
/* @__PURE__ */ jsxs18("div", { className: "space-y-2", children: [
|
|
4591
|
+
/* @__PURE__ */ jsx20(Label7, { htmlFor: "tool-slug", children: "Slug (identificador \xFAnico) *" }),
|
|
4592
|
+
/* @__PURE__ */ jsx20(
|
|
4593
|
+
Input9,
|
|
4885
4594
|
{
|
|
4886
4595
|
id: "tool-slug",
|
|
4887
4596
|
name: "slug",
|
|
@@ -4898,13 +4607,13 @@ function ToolFormDialog({
|
|
|
4898
4607
|
disabled: isPending
|
|
4899
4608
|
}
|
|
4900
4609
|
),
|
|
4901
|
-
/* @__PURE__ */
|
|
4902
|
-
form.slugError && /* @__PURE__ */
|
|
4610
|
+
/* @__PURE__ */ jsx20("p", { className: "text-xs text-muted-foreground", children: "Gerado automaticamente a partir do nome. Usado internamente para identificar a ferramenta." }),
|
|
4611
|
+
form.slugError && /* @__PURE__ */ jsx20("p", { className: "text-sm text-destructive", children: "Slug \xE9 obrigat\xF3rio" })
|
|
4903
4612
|
] }),
|
|
4904
|
-
/* @__PURE__ */
|
|
4905
|
-
/* @__PURE__ */
|
|
4906
|
-
/* @__PURE__ */
|
|
4907
|
-
|
|
4613
|
+
/* @__PURE__ */ jsxs18("div", { className: "space-y-2", children: [
|
|
4614
|
+
/* @__PURE__ */ jsx20(Label7, { htmlFor: "tool-type", children: "Tipo de Autentica\xE7\xE3o *" }),
|
|
4615
|
+
/* @__PURE__ */ jsxs18(
|
|
4616
|
+
Select3,
|
|
4908
4617
|
{
|
|
4909
4618
|
value: form.type,
|
|
4910
4619
|
onValueChange: (value) => {
|
|
@@ -4916,18 +4625,18 @@ function ToolFormDialog({
|
|
|
4916
4625
|
},
|
|
4917
4626
|
disabled: isPending,
|
|
4918
4627
|
children: [
|
|
4919
|
-
/* @__PURE__ */
|
|
4920
|
-
/* @__PURE__ */
|
|
4628
|
+
/* @__PURE__ */ jsx20(SelectTrigger3, { id: "tool-type", children: /* @__PURE__ */ jsx20(SelectValue3, { placeholder: "Selecione o tipo" }) }),
|
|
4629
|
+
/* @__PURE__ */ jsx20(SelectContent3, { children: TOOL_AUTH_TYPES.map((t) => /* @__PURE__ */ jsx20(SelectItem3, { value: t.value, children: t.label }, t.value)) })
|
|
4921
4630
|
]
|
|
4922
4631
|
}
|
|
4923
4632
|
),
|
|
4924
|
-
/* @__PURE__ */
|
|
4925
|
-
form.typeError && /* @__PURE__ */
|
|
4633
|
+
/* @__PURE__ */ jsx20("p", { className: "text-xs text-muted-foreground", children: "Define se a ferramenta requer credenciais para funcionar." }),
|
|
4634
|
+
form.typeError && /* @__PURE__ */ jsx20("p", { className: "text-sm text-destructive", children: "Tipo \xE9 obrigat\xF3rio" })
|
|
4926
4635
|
] }),
|
|
4927
|
-
/* @__PURE__ */
|
|
4928
|
-
/* @__PURE__ */
|
|
4929
|
-
/* @__PURE__ */
|
|
4930
|
-
|
|
4636
|
+
/* @__PURE__ */ jsxs18("div", { className: "space-y-2", children: [
|
|
4637
|
+
/* @__PURE__ */ jsx20(Label7, { htmlFor: "tool-description", children: "Descri\xE7\xE3o" }),
|
|
4638
|
+
/* @__PURE__ */ jsx20(
|
|
4639
|
+
Textarea2,
|
|
4931
4640
|
{
|
|
4932
4641
|
id: "tool-description",
|
|
4933
4642
|
name: "description",
|
|
@@ -4939,10 +4648,10 @@ function ToolFormDialog({
|
|
|
4939
4648
|
}
|
|
4940
4649
|
)
|
|
4941
4650
|
] }),
|
|
4942
|
-
/* @__PURE__ */
|
|
4943
|
-
/* @__PURE__ */
|
|
4944
|
-
/* @__PURE__ */
|
|
4945
|
-
|
|
4651
|
+
/* @__PURE__ */ jsxs18("div", { className: "space-y-2", children: [
|
|
4652
|
+
/* @__PURE__ */ jsx20(Label7, { htmlFor: "tool-function-defs", children: "Defini\xE7\xF5es de Fun\xE7\xE3o (JSON)" }),
|
|
4653
|
+
/* @__PURE__ */ jsx20(
|
|
4654
|
+
Textarea2,
|
|
4946
4655
|
{
|
|
4947
4656
|
id: "tool-function-defs",
|
|
4948
4657
|
name: "functionDefs",
|
|
@@ -4973,12 +4682,12 @@ function ToolFormDialog({
|
|
|
4973
4682
|
disabled: isPending
|
|
4974
4683
|
}
|
|
4975
4684
|
),
|
|
4976
|
-
/* @__PURE__ */
|
|
4977
|
-
form.jsonError && /* @__PURE__ */
|
|
4685
|
+
/* @__PURE__ */ jsx20("p", { className: "text-xs text-muted-foreground", children: "Array de defini\xE7\xF5es no formato OpenAI Function Calling." }),
|
|
4686
|
+
form.jsonError && /* @__PURE__ */ jsx20("p", { className: "text-sm text-destructive", children: "JSON inv\xE1lido" })
|
|
4978
4687
|
] }),
|
|
4979
|
-
/* @__PURE__ */
|
|
4980
|
-
/* @__PURE__ */
|
|
4981
|
-
|
|
4688
|
+
/* @__PURE__ */ jsxs18(DialogFooter6, { children: [
|
|
4689
|
+
/* @__PURE__ */ jsx20(
|
|
4690
|
+
Button13,
|
|
4982
4691
|
{
|
|
4983
4692
|
type: "button",
|
|
4984
4693
|
variant: "outline",
|
|
@@ -4987,8 +4696,8 @@ function ToolFormDialog({
|
|
|
4987
4696
|
children: "Cancelar"
|
|
4988
4697
|
}
|
|
4989
4698
|
),
|
|
4990
|
-
/* @__PURE__ */
|
|
4991
|
-
isPending ? /* @__PURE__ */
|
|
4699
|
+
/* @__PURE__ */ jsxs18(Button13, { type: "submit", disabled: isPending, children: [
|
|
4700
|
+
isPending ? /* @__PURE__ */ jsx20(Loader28, { "aria-hidden": "true", className: "mr-2 h-4 w-4 animate-spin" }) : null,
|
|
4992
4701
|
isEditing ? "Salvar" : "Criar"
|
|
4993
4702
|
] })
|
|
4994
4703
|
] })
|
|
@@ -4998,12 +4707,12 @@ function ToolFormDialog({
|
|
|
4998
4707
|
|
|
4999
4708
|
// src/components/capabilities/advanced-tab.tsx
|
|
5000
4709
|
import { Info as Info2 } from "lucide-react";
|
|
5001
|
-
import { jsx as
|
|
4710
|
+
import { jsx as jsx21, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
5002
4711
|
function AdvancedTab({ config, agentId, gagentsApiUrl }) {
|
|
5003
4712
|
const { data: credentialsData, isLoading: isLoadingCredentials } = useToolCredentials(config);
|
|
5004
4713
|
const credentials = credentialsData?.data ?? [];
|
|
5005
|
-
const [editingTool, setEditingTool] =
|
|
5006
|
-
const [showToolForm, setShowToolForm] =
|
|
4714
|
+
const [editingTool, setEditingTool] = useState13(null);
|
|
4715
|
+
const [showToolForm, setShowToolForm] = useState13(false);
|
|
5007
4716
|
function handleEditTool(tool) {
|
|
5008
4717
|
setEditingTool(tool);
|
|
5009
4718
|
setShowToolForm(true);
|
|
@@ -5012,24 +4721,24 @@ function AdvancedTab({ config, agentId, gagentsApiUrl }) {
|
|
|
5012
4721
|
setShowToolForm(open);
|
|
5013
4722
|
if (!open) setEditingTool(null);
|
|
5014
4723
|
}
|
|
5015
|
-
return /* @__PURE__ */
|
|
5016
|
-
/* @__PURE__ */
|
|
5017
|
-
/* @__PURE__ */
|
|
5018
|
-
/* @__PURE__ */
|
|
4724
|
+
return /* @__PURE__ */ jsxs19("div", { className: "space-y-8", children: [
|
|
4725
|
+
/* @__PURE__ */ jsxs19("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: [
|
|
4726
|
+
/* @__PURE__ */ jsx21(Info2, { className: "mt-0.5 h-4 w-4 shrink-0 text-blue-600 dark:text-blue-400" }),
|
|
4727
|
+
/* @__PURE__ */ jsxs19("p", { className: "text-sm text-blue-800 dark:text-blue-300", children: [
|
|
5019
4728
|
"Use as abas ",
|
|
5020
|
-
/* @__PURE__ */
|
|
4729
|
+
/* @__PURE__ */ jsx21("strong", { children: "Capacidades" }),
|
|
5021
4730
|
" e ",
|
|
5022
|
-
/* @__PURE__ */
|
|
4731
|
+
/* @__PURE__ */ jsx21("strong", { children: "Integra\xE7\xF5es" }),
|
|
5023
4732
|
" para configura\xE7\xE3o simplificada. Esta aba oferece controlo manual avan\xE7ado sobre ferramentas e credenciais."
|
|
5024
4733
|
] })
|
|
5025
4734
|
] }),
|
|
5026
|
-
/* @__PURE__ */
|
|
5027
|
-
/* @__PURE__ */
|
|
5028
|
-
/* @__PURE__ */
|
|
4735
|
+
/* @__PURE__ */ jsxs19("section", { className: "space-y-3", children: [
|
|
4736
|
+
/* @__PURE__ */ jsx21("h3", { className: "text-sm font-medium", children: "Ferramentas" }),
|
|
4737
|
+
/* @__PURE__ */ jsx21(ToolsTable, { onEdit: handleEditTool, config })
|
|
5029
4738
|
] }),
|
|
5030
|
-
/* @__PURE__ */
|
|
5031
|
-
/* @__PURE__ */
|
|
5032
|
-
/* @__PURE__ */
|
|
4739
|
+
/* @__PURE__ */ jsxs19("section", { className: "space-y-3", children: [
|
|
4740
|
+
/* @__PURE__ */ jsx21("h3", { className: "text-sm font-medium", children: "Credenciais" }),
|
|
4741
|
+
/* @__PURE__ */ jsx21(
|
|
5033
4742
|
ToolCredentialsForm,
|
|
5034
4743
|
{
|
|
5035
4744
|
credentials,
|
|
@@ -5039,7 +4748,7 @@ function AdvancedTab({ config, agentId, gagentsApiUrl }) {
|
|
|
5039
4748
|
}
|
|
5040
4749
|
)
|
|
5041
4750
|
] }),
|
|
5042
|
-
/* @__PURE__ */
|
|
4751
|
+
/* @__PURE__ */ jsx21(
|
|
5043
4752
|
ToolFormDialog,
|
|
5044
4753
|
{
|
|
5045
4754
|
open: showToolForm,
|
|
@@ -5052,7 +4761,7 @@ function AdvancedTab({ config, agentId, gagentsApiUrl }) {
|
|
|
5052
4761
|
}
|
|
5053
4762
|
|
|
5054
4763
|
// src/pages/agent-capabilities-page.tsx
|
|
5055
|
-
import { jsx as
|
|
4764
|
+
import { jsx as jsx22, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
5056
4765
|
function defaultResolveWizardMeta(card) {
|
|
5057
4766
|
return {
|
|
5058
4767
|
capabilities: [
|
|
@@ -5070,8 +4779,8 @@ function AgentCapabilitiesPage({
|
|
|
5070
4779
|
loadConfigOptions,
|
|
5071
4780
|
onWizardComplete
|
|
5072
4781
|
}) {
|
|
5073
|
-
const [wizardOpen, setWizardOpen] =
|
|
5074
|
-
const [activeCard, setActiveCard] =
|
|
4782
|
+
const [wizardOpen, setWizardOpen] = useState14(false);
|
|
4783
|
+
const [activeCard, setActiveCard] = useState14(null);
|
|
5075
4784
|
const handleConnect = useCallback6(
|
|
5076
4785
|
(card) => {
|
|
5077
4786
|
setActiveCard(card);
|
|
@@ -5089,28 +4798,28 @@ function AgentCapabilitiesPage({
|
|
|
5089
4798
|
if (!open) setActiveCard(null);
|
|
5090
4799
|
}, []);
|
|
5091
4800
|
const wizardMeta = activeCard ? resolveWizardMeta(activeCard) : null;
|
|
5092
|
-
return /* @__PURE__ */
|
|
5093
|
-
/* @__PURE__ */
|
|
5094
|
-
/* @__PURE__ */
|
|
5095
|
-
/* @__PURE__ */
|
|
4801
|
+
return /* @__PURE__ */ jsxs20("div", { className: "space-y-4", children: [
|
|
4802
|
+
/* @__PURE__ */ jsxs20("div", { children: [
|
|
4803
|
+
/* @__PURE__ */ jsx22("h2", { className: "text-lg font-semibold", children: "Capacidades e Integra\xE7\xF5es" }),
|
|
4804
|
+
/* @__PURE__ */ jsx22("p", { className: "text-sm text-muted-foreground", children: "Configure o que este agente pode fazer e quais servi\xE7os externos ele utiliza." })
|
|
5096
4805
|
] }),
|
|
5097
|
-
/* @__PURE__ */
|
|
5098
|
-
/* @__PURE__ */
|
|
5099
|
-
/* @__PURE__ */
|
|
5100
|
-
/* @__PURE__ */
|
|
4806
|
+
/* @__PURE__ */ jsxs20(Tabs, { defaultValue: "capacidades", children: [
|
|
4807
|
+
/* @__PURE__ */ jsxs20(TabsList, { children: [
|
|
4808
|
+
/* @__PURE__ */ jsxs20(TabsTrigger, { value: "capacidades", className: "flex items-center gap-1.5", children: [
|
|
4809
|
+
/* @__PURE__ */ jsx22(Blocks, { "aria-hidden": "true", className: "h-3.5 w-3.5" }),
|
|
5101
4810
|
"Capacidades"
|
|
5102
4811
|
] }),
|
|
5103
|
-
/* @__PURE__ */
|
|
5104
|
-
/* @__PURE__ */
|
|
4812
|
+
/* @__PURE__ */ jsxs20(TabsTrigger, { value: "integracoes", className: "flex items-center gap-1.5", children: [
|
|
4813
|
+
/* @__PURE__ */ jsx22(Plug3, { "aria-hidden": "true", className: "h-3.5 w-3.5" }),
|
|
5105
4814
|
"Integra\xE7\xF5es"
|
|
5106
4815
|
] }),
|
|
5107
|
-
/* @__PURE__ */
|
|
5108
|
-
/* @__PURE__ */
|
|
4816
|
+
/* @__PURE__ */ jsxs20(TabsTrigger, { value: "avancado", className: "flex items-center gap-1.5", children: [
|
|
4817
|
+
/* @__PURE__ */ jsx22(Settings3, { "aria-hidden": "true", className: "h-3.5 w-3.5" }),
|
|
5109
4818
|
"Avan\xE7ado"
|
|
5110
4819
|
] })
|
|
5111
4820
|
] }),
|
|
5112
|
-
/* @__PURE__ */
|
|
5113
|
-
/* @__PURE__ */
|
|
4821
|
+
/* @__PURE__ */ jsx22(TabsContent, { value: "capacidades", className: "mt-4", children: /* @__PURE__ */ jsx22(CapabilitiesTab, { config, agentId }) }),
|
|
4822
|
+
/* @__PURE__ */ jsx22(TabsContent, { value: "integracoes", className: "mt-4", children: /* @__PURE__ */ jsx22(
|
|
5114
4823
|
IntegrationsTab,
|
|
5115
4824
|
{
|
|
5116
4825
|
config,
|
|
@@ -5118,7 +4827,7 @@ function AgentCapabilitiesPage({
|
|
|
5118
4827
|
onConnect: handleConnect
|
|
5119
4828
|
}
|
|
5120
4829
|
) }),
|
|
5121
|
-
/* @__PURE__ */
|
|
4830
|
+
/* @__PURE__ */ jsx22(TabsContent, { value: "avancado", className: "mt-4", children: /* @__PURE__ */ jsx22(
|
|
5122
4831
|
AdvancedTab,
|
|
5123
4832
|
{
|
|
5124
4833
|
config,
|
|
@@ -5127,7 +4836,7 @@ function AgentCapabilitiesPage({
|
|
|
5127
4836
|
}
|
|
5128
4837
|
) })
|
|
5129
4838
|
] }),
|
|
5130
|
-
activeCard && wizardMeta && /* @__PURE__ */
|
|
4839
|
+
activeCard && wizardMeta && /* @__PURE__ */ jsx22(
|
|
5131
4840
|
IntegrationWizard,
|
|
5132
4841
|
{
|
|
5133
4842
|
open: wizardOpen,
|
|
@@ -5152,8 +4861,8 @@ import {
|
|
|
5152
4861
|
TabsTrigger as TabsTrigger2,
|
|
5153
4862
|
TabsContent as TabsContent2
|
|
5154
4863
|
} from "@greatapps/greatauth-ui/ui";
|
|
5155
|
-
import {
|
|
5156
|
-
import { jsx as
|
|
4864
|
+
import { Target as Target2, FileText as FileText2, MessageCircle as MessageCircle2, Blocks as Blocks2 } from "lucide-react";
|
|
4865
|
+
import { jsx as jsx23, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
5157
4866
|
function AgentTabs({
|
|
5158
4867
|
agent,
|
|
5159
4868
|
config,
|
|
@@ -5164,33 +4873,28 @@ function AgentTabs({
|
|
|
5164
4873
|
onWizardComplete
|
|
5165
4874
|
}) {
|
|
5166
4875
|
const apiUrl = gagentsApiUrl || config.baseUrl;
|
|
5167
|
-
return /* @__PURE__ */
|
|
5168
|
-
/* @__PURE__ */
|
|
5169
|
-
/* @__PURE__ */
|
|
5170
|
-
/* @__PURE__ */
|
|
4876
|
+
return /* @__PURE__ */ jsxs21(Tabs2, { defaultValue: "prompt", children: [
|
|
4877
|
+
/* @__PURE__ */ jsxs21(TabsList2, { children: [
|
|
4878
|
+
/* @__PURE__ */ jsxs21(TabsTrigger2, { value: "prompt", className: "flex items-center gap-1.5", children: [
|
|
4879
|
+
/* @__PURE__ */ jsx23(FileText2, { "aria-hidden": "true", className: "h-3.5 w-3.5" }),
|
|
5171
4880
|
"Prompt"
|
|
5172
4881
|
] }),
|
|
5173
|
-
/* @__PURE__ */
|
|
5174
|
-
/* @__PURE__ */
|
|
4882
|
+
/* @__PURE__ */ jsxs21(TabsTrigger2, { value: "objetivos", className: "flex items-center gap-1.5", children: [
|
|
4883
|
+
/* @__PURE__ */ jsx23(Target2, { "aria-hidden": "true", className: "h-3.5 w-3.5" }),
|
|
5175
4884
|
"Objetivos"
|
|
5176
4885
|
] }),
|
|
5177
|
-
/* @__PURE__ */
|
|
5178
|
-
/* @__PURE__ */
|
|
5179
|
-
"Ferramentas"
|
|
5180
|
-
] }),
|
|
5181
|
-
/* @__PURE__ */ jsxs22(TabsTrigger2, { value: "capacidades", className: "flex items-center gap-1.5", children: [
|
|
5182
|
-
/* @__PURE__ */ jsx24(Blocks2, { "aria-hidden": "true", className: "h-3.5 w-3.5" }),
|
|
4886
|
+
/* @__PURE__ */ jsxs21(TabsTrigger2, { value: "capacidades", className: "flex items-center gap-1.5", children: [
|
|
4887
|
+
/* @__PURE__ */ jsx23(Blocks2, { "aria-hidden": "true", className: "h-3.5 w-3.5" }),
|
|
5183
4888
|
"Capacidades"
|
|
5184
4889
|
] }),
|
|
5185
|
-
/* @__PURE__ */
|
|
5186
|
-
/* @__PURE__ */
|
|
4890
|
+
/* @__PURE__ */ jsxs21(TabsTrigger2, { value: "conversas", className: "flex items-center gap-1.5", children: [
|
|
4891
|
+
/* @__PURE__ */ jsx23(MessageCircle2, { "aria-hidden": "true", className: "h-3.5 w-3.5" }),
|
|
5187
4892
|
"Conversas"
|
|
5188
4893
|
] })
|
|
5189
4894
|
] }),
|
|
5190
|
-
/* @__PURE__ */
|
|
5191
|
-
/* @__PURE__ */
|
|
5192
|
-
/* @__PURE__ */
|
|
5193
|
-
/* @__PURE__ */ jsx24(TabsContent2, { value: "capacidades", className: "mt-4", children: /* @__PURE__ */ jsx24(
|
|
4895
|
+
/* @__PURE__ */ jsx23(TabsContent2, { value: "prompt", className: "mt-4", children: /* @__PURE__ */ jsx23(AgentPromptEditor, { agent, config }) }),
|
|
4896
|
+
/* @__PURE__ */ jsx23(TabsContent2, { value: "objetivos", className: "mt-4", children: /* @__PURE__ */ jsx23(AgentObjectivesList, { agent, config }) }),
|
|
4897
|
+
/* @__PURE__ */ jsx23(TabsContent2, { value: "capacidades", className: "mt-4", children: /* @__PURE__ */ jsx23(
|
|
5194
4898
|
AgentCapabilitiesPage,
|
|
5195
4899
|
{
|
|
5196
4900
|
config,
|
|
@@ -5201,7 +4905,7 @@ function AgentTabs({
|
|
|
5201
4905
|
onWizardComplete
|
|
5202
4906
|
}
|
|
5203
4907
|
) }),
|
|
5204
|
-
/* @__PURE__ */
|
|
4908
|
+
/* @__PURE__ */ jsx23(TabsContent2, { value: "conversas", className: "mt-4", children: /* @__PURE__ */ jsx23(
|
|
5205
4909
|
AgentConversationsPanel,
|
|
5206
4910
|
{
|
|
5207
4911
|
agent,
|
|
@@ -5212,6 +4916,335 @@ function AgentTabs({
|
|
|
5212
4916
|
] });
|
|
5213
4917
|
}
|
|
5214
4918
|
|
|
4919
|
+
// src/components/agents/agent-tools-list.tsx
|
|
4920
|
+
import { useState as useState15 } from "react";
|
|
4921
|
+
import {
|
|
4922
|
+
Switch as Switch5,
|
|
4923
|
+
Badge as Badge9,
|
|
4924
|
+
Button as Button14,
|
|
4925
|
+
Skeleton as Skeleton6,
|
|
4926
|
+
AlertDialog as AlertDialog5,
|
|
4927
|
+
AlertDialogAction as AlertDialogAction5,
|
|
4928
|
+
AlertDialogCancel as AlertDialogCancel5,
|
|
4929
|
+
AlertDialogContent as AlertDialogContent5,
|
|
4930
|
+
AlertDialogDescription as AlertDialogDescription5,
|
|
4931
|
+
AlertDialogFooter as AlertDialogFooter5,
|
|
4932
|
+
AlertDialogHeader as AlertDialogHeader5,
|
|
4933
|
+
AlertDialogTitle as AlertDialogTitle5,
|
|
4934
|
+
Popover,
|
|
4935
|
+
PopoverContent,
|
|
4936
|
+
PopoverTrigger,
|
|
4937
|
+
Input as Input10,
|
|
4938
|
+
Textarea as Textarea3,
|
|
4939
|
+
Dialog as Dialog7,
|
|
4940
|
+
DialogContent as DialogContent7,
|
|
4941
|
+
DialogHeader as DialogHeader7,
|
|
4942
|
+
DialogTitle as DialogTitle7,
|
|
4943
|
+
DialogFooter as DialogFooter7,
|
|
4944
|
+
Label as Label8,
|
|
4945
|
+
Select as Select4,
|
|
4946
|
+
SelectContent as SelectContent4,
|
|
4947
|
+
SelectItem as SelectItem4,
|
|
4948
|
+
SelectTrigger as SelectTrigger4,
|
|
4949
|
+
SelectValue as SelectValue4
|
|
4950
|
+
} from "@greatapps/greatauth-ui/ui";
|
|
4951
|
+
import {
|
|
4952
|
+
Trash2 as Trash25,
|
|
4953
|
+
Plus as Plus2,
|
|
4954
|
+
Wrench,
|
|
4955
|
+
Settings2 as Settings22
|
|
4956
|
+
} from "lucide-react";
|
|
4957
|
+
import { toast as toast11 } from "sonner";
|
|
4958
|
+
import { jsx as jsx24, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
4959
|
+
function AgentToolsList({ agent, config }) {
|
|
4960
|
+
const { data: agentToolsData, isLoading } = useAgentTools(config, agent.id);
|
|
4961
|
+
const { data: allToolsData } = useTools(config);
|
|
4962
|
+
const addMutation = useAddAgentTool(config);
|
|
4963
|
+
const removeMutation = useRemoveAgentTool(config);
|
|
4964
|
+
const updateMutation = useUpdateAgentTool(config);
|
|
4965
|
+
const [removeTarget, setRemoveTarget] = useState15(null);
|
|
4966
|
+
const [addOpen, setAddOpen] = useState15(false);
|
|
4967
|
+
const [search, setSearch] = useState15("");
|
|
4968
|
+
const [configTarget, setConfigTarget] = useState15(null);
|
|
4969
|
+
const [configInstructions, setConfigInstructions] = useState15("");
|
|
4970
|
+
const [configCredentialId, setConfigCredentialId] = useState15("");
|
|
4971
|
+
const { data: credentialsData } = useToolCredentials(config);
|
|
4972
|
+
const allCredentials = credentialsData?.data || [];
|
|
4973
|
+
const agentTools = agentToolsData?.data || [];
|
|
4974
|
+
const allTools = (allToolsData?.data || []).filter((t) => !t.slug?.startsWith("gclinic_"));
|
|
4975
|
+
const assignedToolIds = new Set(agentTools.map((at) => at.id_tool));
|
|
4976
|
+
const visibleAgentTools = agentTools.filter((at) => {
|
|
4977
|
+
const tool = allTools.find((t) => t.id === at.id_tool);
|
|
4978
|
+
return !tool || !tool.slug?.startsWith("gclinic_");
|
|
4979
|
+
});
|
|
4980
|
+
const availableTools = allTools.filter((t) => !assignedToolIds.has(t.id));
|
|
4981
|
+
const filteredAvailable = availableTools.filter(
|
|
4982
|
+
(t) => t.name.toLowerCase().includes(search.toLowerCase())
|
|
4983
|
+
);
|
|
4984
|
+
function getToolInfo(idTool) {
|
|
4985
|
+
return allTools.find((t) => t.id === idTool);
|
|
4986
|
+
}
|
|
4987
|
+
async function handleToggleEnabled(agentTool, checked) {
|
|
4988
|
+
try {
|
|
4989
|
+
await updateMutation.mutateAsync({
|
|
4990
|
+
idAgent: agent.id,
|
|
4991
|
+
id: agentTool.id,
|
|
4992
|
+
body: { enabled: checked }
|
|
4993
|
+
});
|
|
4994
|
+
toast11.success(checked ? "Ferramenta ativada" : "Ferramenta desativada");
|
|
4995
|
+
} catch (err) {
|
|
4996
|
+
toast11.error(
|
|
4997
|
+
err instanceof Error ? err.message : "Erro ao alterar estado da ferramenta"
|
|
4998
|
+
);
|
|
4999
|
+
}
|
|
5000
|
+
}
|
|
5001
|
+
async function handleAdd(tool) {
|
|
5002
|
+
try {
|
|
5003
|
+
await addMutation.mutateAsync({
|
|
5004
|
+
idAgent: agent.id,
|
|
5005
|
+
body: { id_tool: tool.id }
|
|
5006
|
+
});
|
|
5007
|
+
toast11.success("Ferramenta adicionada");
|
|
5008
|
+
setAddOpen(false);
|
|
5009
|
+
setSearch("");
|
|
5010
|
+
} catch (err) {
|
|
5011
|
+
toast11.error(
|
|
5012
|
+
err instanceof Error ? err.message : "Erro ao adicionar ferramenta"
|
|
5013
|
+
);
|
|
5014
|
+
}
|
|
5015
|
+
}
|
|
5016
|
+
async function handleRemove() {
|
|
5017
|
+
if (!removeTarget) return;
|
|
5018
|
+
try {
|
|
5019
|
+
await removeMutation.mutateAsync({
|
|
5020
|
+
idAgent: agent.id,
|
|
5021
|
+
id: removeTarget.id
|
|
5022
|
+
});
|
|
5023
|
+
toast11.success("Ferramenta removida");
|
|
5024
|
+
} catch (err) {
|
|
5025
|
+
toast11.error(
|
|
5026
|
+
err instanceof Error ? err.message : "Erro ao remover ferramenta"
|
|
5027
|
+
);
|
|
5028
|
+
} finally {
|
|
5029
|
+
setRemoveTarget(null);
|
|
5030
|
+
}
|
|
5031
|
+
}
|
|
5032
|
+
function openConfig(agentTool) {
|
|
5033
|
+
setConfigTarget(agentTool);
|
|
5034
|
+
setConfigInstructions(agentTool.custom_instructions || "");
|
|
5035
|
+
setConfigCredentialId(agentTool.id_tool_credential ? String(agentTool.id_tool_credential) : "");
|
|
5036
|
+
}
|
|
5037
|
+
async function handleSaveConfig() {
|
|
5038
|
+
if (!configTarget) return;
|
|
5039
|
+
try {
|
|
5040
|
+
const newCredentialId = configCredentialId ? parseInt(configCredentialId, 10) : null;
|
|
5041
|
+
await updateMutation.mutateAsync({
|
|
5042
|
+
idAgent: agent.id,
|
|
5043
|
+
id: configTarget.id,
|
|
5044
|
+
body: {
|
|
5045
|
+
custom_instructions: configInstructions.trim() || null,
|
|
5046
|
+
id_tool_credential: newCredentialId
|
|
5047
|
+
}
|
|
5048
|
+
});
|
|
5049
|
+
toast11.success("Configura\xE7\xE3o atualizada");
|
|
5050
|
+
setConfigTarget(null);
|
|
5051
|
+
} catch (err) {
|
|
5052
|
+
toast11.error(
|
|
5053
|
+
err instanceof Error ? err.message : "Erro ao atualizar configura\xE7\xE3o"
|
|
5054
|
+
);
|
|
5055
|
+
}
|
|
5056
|
+
}
|
|
5057
|
+
if (isLoading) {
|
|
5058
|
+
return /* @__PURE__ */ jsx24("div", { className: "space-y-3 p-4", children: Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ jsx24(Skeleton6, { className: "h-14 w-full" }, i)) });
|
|
5059
|
+
}
|
|
5060
|
+
return /* @__PURE__ */ jsxs22("div", { className: "space-y-4 p-4", children: [
|
|
5061
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-center justify-between", children: [
|
|
5062
|
+
/* @__PURE__ */ jsxs22("h3", { className: "text-sm font-medium text-muted-foreground", children: [
|
|
5063
|
+
visibleAgentTools.length,
|
|
5064
|
+
" ferramenta",
|
|
5065
|
+
visibleAgentTools.length !== 1 ? "s" : "",
|
|
5066
|
+
" associada",
|
|
5067
|
+
visibleAgentTools.length !== 1 ? "s" : ""
|
|
5068
|
+
] }),
|
|
5069
|
+
/* @__PURE__ */ jsxs22(Popover, { open: addOpen, onOpenChange: setAddOpen, children: [
|
|
5070
|
+
/* @__PURE__ */ jsx24(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs22(Button14, { size: "sm", disabled: availableTools.length === 0, children: [
|
|
5071
|
+
/* @__PURE__ */ jsx24(Plus2, { className: "mr-2 h-4 w-4" }),
|
|
5072
|
+
"Adicionar Ferramenta"
|
|
5073
|
+
] }) }),
|
|
5074
|
+
/* @__PURE__ */ jsxs22(PopoverContent, { className: "w-72 p-0", align: "end", children: [
|
|
5075
|
+
/* @__PURE__ */ jsx24("div", { className: "p-2", children: /* @__PURE__ */ jsx24(
|
|
5076
|
+
Input10,
|
|
5077
|
+
{
|
|
5078
|
+
placeholder: "Buscar ferramenta\\u2026",
|
|
5079
|
+
"aria-label": "Buscar ferramenta",
|
|
5080
|
+
name: "search",
|
|
5081
|
+
value: search,
|
|
5082
|
+
onChange: (e) => setSearch(e.target.value),
|
|
5083
|
+
className: "h-8"
|
|
5084
|
+
}
|
|
5085
|
+
) }),
|
|
5086
|
+
/* @__PURE__ */ jsx24("div", { className: "max-h-48 overflow-y-auto", children: filteredAvailable.length === 0 ? /* @__PURE__ */ jsx24("p", { className: "p-3 text-center text-sm text-muted-foreground", children: "Nenhuma ferramenta dispon\xEDvel" }) : filteredAvailable.map((tool) => /* @__PURE__ */ jsxs22(
|
|
5087
|
+
"button",
|
|
5088
|
+
{
|
|
5089
|
+
type: "button",
|
|
5090
|
+
className: "flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-accent",
|
|
5091
|
+
onClick: () => handleAdd(tool),
|
|
5092
|
+
disabled: addMutation.isPending,
|
|
5093
|
+
children: [
|
|
5094
|
+
/* @__PURE__ */ jsx24(Wrench, { className: "h-4 w-4 text-muted-foreground" }),
|
|
5095
|
+
/* @__PURE__ */ jsx24("span", { className: "flex-1 font-medium", children: tool.name }),
|
|
5096
|
+
/* @__PURE__ */ jsx24(Badge9, { variant: "secondary", className: "text-xs", children: tool.type })
|
|
5097
|
+
]
|
|
5098
|
+
},
|
|
5099
|
+
tool.id
|
|
5100
|
+
)) })
|
|
5101
|
+
] })
|
|
5102
|
+
] })
|
|
5103
|
+
] }),
|
|
5104
|
+
visibleAgentTools.length === 0 ? /* @__PURE__ */ jsxs22("div", { className: "flex flex-col items-center justify-center rounded-lg border border-dashed p-8 text-center", children: [
|
|
5105
|
+
/* @__PURE__ */ jsx24(Wrench, { className: "mb-2 h-8 w-8 text-muted-foreground" }),
|
|
5106
|
+
/* @__PURE__ */ jsx24("p", { className: "text-sm text-muted-foreground", children: "Nenhuma ferramenta associada. Clique em 'Adicionar Ferramenta' para come\xE7ar." })
|
|
5107
|
+
] }) : /* @__PURE__ */ jsx24("div", { className: "space-y-2", children: visibleAgentTools.map((agentTool) => {
|
|
5108
|
+
const tool = getToolInfo(agentTool.id_tool);
|
|
5109
|
+
return /* @__PURE__ */ jsxs22(
|
|
5110
|
+
"div",
|
|
5111
|
+
{
|
|
5112
|
+
className: "flex items-center gap-3 rounded-lg border bg-card p-3",
|
|
5113
|
+
children: [
|
|
5114
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex flex-1 flex-col gap-1 min-w-0", children: [
|
|
5115
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-center gap-2", children: [
|
|
5116
|
+
/* @__PURE__ */ jsx24("span", { className: "truncate font-medium", children: tool?.name || `Ferramenta #${agentTool.id_tool}` }),
|
|
5117
|
+
tool?.type && /* @__PURE__ */ jsx24(Badge9, { variant: "secondary", className: "shrink-0 text-xs", children: tool.type })
|
|
5118
|
+
] }),
|
|
5119
|
+
agentTool.custom_instructions && /* @__PURE__ */ jsx24("p", { className: "truncate text-xs text-muted-foreground", children: agentTool.custom_instructions })
|
|
5120
|
+
] }),
|
|
5121
|
+
/* @__PURE__ */ jsx24(
|
|
5122
|
+
Switch5,
|
|
5123
|
+
{
|
|
5124
|
+
"aria-label": "Ativar/Desativar",
|
|
5125
|
+
checked: agentTool.enabled,
|
|
5126
|
+
onCheckedChange: (checked) => handleToggleEnabled(agentTool, checked),
|
|
5127
|
+
disabled: updateMutation.isPending
|
|
5128
|
+
}
|
|
5129
|
+
),
|
|
5130
|
+
/* @__PURE__ */ jsx24(
|
|
5131
|
+
Button14,
|
|
5132
|
+
{
|
|
5133
|
+
variant: "ghost",
|
|
5134
|
+
size: "icon",
|
|
5135
|
+
"aria-label": "Configurar",
|
|
5136
|
+
className: "shrink-0 text-muted-foreground hover:text-foreground",
|
|
5137
|
+
onClick: () => openConfig(agentTool),
|
|
5138
|
+
title: "Configurar instru\xE7\xF5es",
|
|
5139
|
+
children: /* @__PURE__ */ jsx24(Settings22, { className: "h-4 w-4" })
|
|
5140
|
+
}
|
|
5141
|
+
),
|
|
5142
|
+
/* @__PURE__ */ jsx24(
|
|
5143
|
+
Button14,
|
|
5144
|
+
{
|
|
5145
|
+
variant: "ghost",
|
|
5146
|
+
size: "icon",
|
|
5147
|
+
"aria-label": "Remover",
|
|
5148
|
+
className: "shrink-0 text-muted-foreground hover:text-destructive",
|
|
5149
|
+
onClick: () => setRemoveTarget(agentTool),
|
|
5150
|
+
children: /* @__PURE__ */ jsx24(Trash25, { className: "h-4 w-4" })
|
|
5151
|
+
}
|
|
5152
|
+
)
|
|
5153
|
+
]
|
|
5154
|
+
},
|
|
5155
|
+
agentTool.id
|
|
5156
|
+
);
|
|
5157
|
+
}) }),
|
|
5158
|
+
/* @__PURE__ */ jsx24(
|
|
5159
|
+
Dialog7,
|
|
5160
|
+
{
|
|
5161
|
+
open: !!configTarget,
|
|
5162
|
+
onOpenChange: (open) => !open && setConfigTarget(null),
|
|
5163
|
+
children: /* @__PURE__ */ jsxs22(DialogContent7, { className: "sm:max-w-lg", children: [
|
|
5164
|
+
/* @__PURE__ */ jsx24(DialogHeader7, { children: /* @__PURE__ */ jsx24(DialogTitle7, { children: "Instru\xE7\xF5es da Ferramenta" }) }),
|
|
5165
|
+
/* @__PURE__ */ jsxs22("div", { className: "space-y-4", children: [
|
|
5166
|
+
configTarget && getToolInfo(configTarget.id_tool)?.type !== "none" && /* @__PURE__ */ jsxs22("div", { className: "space-y-2", children: [
|
|
5167
|
+
/* @__PURE__ */ jsx24(Label8, { htmlFor: "tool-credential", children: "Credencial" }),
|
|
5168
|
+
/* @__PURE__ */ jsxs22(
|
|
5169
|
+
Select4,
|
|
5170
|
+
{
|
|
5171
|
+
value: configCredentialId || void 0,
|
|
5172
|
+
onValueChange: (val) => setConfigCredentialId(val === "__none__" ? "" : val),
|
|
5173
|
+
children: [
|
|
5174
|
+
/* @__PURE__ */ jsx24(SelectTrigger4, { id: "tool-credential", children: /* @__PURE__ */ jsx24(SelectValue4, { placeholder: "Selecione uma credencial (opcional)" }) }),
|
|
5175
|
+
/* @__PURE__ */ jsxs22(SelectContent4, { children: [
|
|
5176
|
+
/* @__PURE__ */ jsx24(SelectItem4, { value: "__none__", children: "Nenhuma (autom\xE1tico)" }),
|
|
5177
|
+
allCredentials.filter((c) => configTarget && c.id_tool === configTarget.id_tool && c.status === "active").map((c) => /* @__PURE__ */ jsx24(SelectItem4, { value: String(c.id), children: c.label || `Credencial #${c.id}` }, c.id))
|
|
5178
|
+
] })
|
|
5179
|
+
]
|
|
5180
|
+
}
|
|
5181
|
+
),
|
|
5182
|
+
/* @__PURE__ */ jsx24("p", { className: "text-xs text-muted-foreground", children: "Vincule uma credencial espec\xEDfica a esta ferramenta neste agente." })
|
|
5183
|
+
] }),
|
|
5184
|
+
/* @__PURE__ */ jsxs22("div", { className: "space-y-2", children: [
|
|
5185
|
+
/* @__PURE__ */ jsx24(Label8, { htmlFor: "tool-instructions", children: "Instru\xE7\xF5es Personalizadas" }),
|
|
5186
|
+
/* @__PURE__ */ jsx24(
|
|
5187
|
+
Textarea3,
|
|
5188
|
+
{
|
|
5189
|
+
id: "tool-instructions",
|
|
5190
|
+
name: "instructions",
|
|
5191
|
+
value: configInstructions,
|
|
5192
|
+
onChange: (e) => setConfigInstructions(e.target.value),
|
|
5193
|
+
placeholder: "Instru\\u00e7\\u00f5es sobre como e quando o agente deve usar esta ferramenta\\u2026",
|
|
5194
|
+
rows: 6
|
|
5195
|
+
}
|
|
5196
|
+
),
|
|
5197
|
+
/* @__PURE__ */ jsx24("p", { className: "text-xs text-muted-foreground", children: "Este texto \xE9 adicionado ao prompt do agente para orientar o uso da ferramenta." })
|
|
5198
|
+
] })
|
|
5199
|
+
] }),
|
|
5200
|
+
/* @__PURE__ */ jsxs22(DialogFooter7, { children: [
|
|
5201
|
+
/* @__PURE__ */ jsx24(
|
|
5202
|
+
Button14,
|
|
5203
|
+
{
|
|
5204
|
+
variant: "outline",
|
|
5205
|
+
onClick: () => setConfigTarget(null),
|
|
5206
|
+
children: "Cancelar"
|
|
5207
|
+
}
|
|
5208
|
+
),
|
|
5209
|
+
/* @__PURE__ */ jsx24(
|
|
5210
|
+
Button14,
|
|
5211
|
+
{
|
|
5212
|
+
onClick: handleSaveConfig,
|
|
5213
|
+
disabled: updateMutation.isPending,
|
|
5214
|
+
children: "Salvar"
|
|
5215
|
+
}
|
|
5216
|
+
)
|
|
5217
|
+
] })
|
|
5218
|
+
] })
|
|
5219
|
+
}
|
|
5220
|
+
),
|
|
5221
|
+
/* @__PURE__ */ jsx24(
|
|
5222
|
+
AlertDialog5,
|
|
5223
|
+
{
|
|
5224
|
+
open: !!removeTarget,
|
|
5225
|
+
onOpenChange: (open) => !open && setRemoveTarget(null),
|
|
5226
|
+
children: /* @__PURE__ */ jsxs22(AlertDialogContent5, { children: [
|
|
5227
|
+
/* @__PURE__ */ jsxs22(AlertDialogHeader5, { children: [
|
|
5228
|
+
/* @__PURE__ */ jsx24(AlertDialogTitle5, { children: "Remover ferramenta?" }),
|
|
5229
|
+
/* @__PURE__ */ jsx24(AlertDialogDescription5, { children: "A ferramenta ser\xE1 desassociada deste agente." })
|
|
5230
|
+
] }),
|
|
5231
|
+
/* @__PURE__ */ jsxs22(AlertDialogFooter5, { children: [
|
|
5232
|
+
/* @__PURE__ */ jsx24(AlertDialogCancel5, { children: "Cancelar" }),
|
|
5233
|
+
/* @__PURE__ */ jsx24(
|
|
5234
|
+
AlertDialogAction5,
|
|
5235
|
+
{
|
|
5236
|
+
onClick: handleRemove,
|
|
5237
|
+
disabled: removeMutation.isPending,
|
|
5238
|
+
children: "Remover"
|
|
5239
|
+
}
|
|
5240
|
+
)
|
|
5241
|
+
] })
|
|
5242
|
+
] })
|
|
5243
|
+
}
|
|
5244
|
+
)
|
|
5245
|
+
] });
|
|
5246
|
+
}
|
|
5247
|
+
|
|
5215
5248
|
// src/pages/agents-page.tsx
|
|
5216
5249
|
import { useState as useState16 } from "react";
|
|
5217
5250
|
import { Button as Button15 } from "@greatapps/greatauth-ui/ui";
|