@greatapps/greatagents-ui 0.3.2 → 0.3.4

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.
Files changed (38) hide show
  1. package/dist/index.d.ts +204 -1
  2. package/dist/index.js +1797 -125
  3. package/dist/index.js.map +1 -1
  4. package/package.json +1 -1
  5. package/src/client/index.ts +14 -0
  6. package/src/components/agents/agent-edit-form.tsx +4 -1
  7. package/src/components/agents/agent-form-dialog.tsx +5 -1
  8. package/src/components/agents/agent-objectives-list.tsx +15 -6
  9. package/src/components/agents/agent-prompt-editor.tsx +9 -5
  10. package/src/components/agents/agent-tabs.tsx +4 -4
  11. package/src/components/agents/agent-tools-list.tsx +12 -5
  12. package/src/components/agents/agents-table.tsx +7 -2
  13. package/src/components/capabilities/advanced-tab.tsx +82 -0
  14. package/src/components/capabilities/capabilities-tab.tsx +475 -0
  15. package/src/components/capabilities/integration-card.tsx +162 -0
  16. package/src/components/capabilities/integration-wizard.tsx +537 -0
  17. package/src/components/capabilities/integrations-tab.tsx +61 -0
  18. package/src/components/capabilities/types.ts +48 -0
  19. package/src/components/capabilities/wizard-steps/config-step.tsx +117 -0
  20. package/src/components/capabilities/wizard-steps/confirm-step.tsx +123 -0
  21. package/src/components/capabilities/wizard-steps/credentials-step.tsx +205 -0
  22. package/src/components/capabilities/wizard-steps/info-step.tsx +78 -0
  23. package/src/components/conversations/agent-conversations-table.tsx +13 -2
  24. package/src/components/conversations/conversation-view.tsx +2 -2
  25. package/src/components/tools/tool-credentials-form.tsx +34 -14
  26. package/src/components/tools/tool-form-dialog.tsx +9 -5
  27. package/src/components/tools/tools-table.tsx +8 -3
  28. package/src/data/integrations-registry.ts +23 -0
  29. package/src/hooks/index.ts +10 -0
  30. package/src/hooks/use-capabilities.ts +50 -0
  31. package/src/hooks/use-integrations.ts +114 -0
  32. package/src/index.ts +34 -0
  33. package/src/pages/agent-capabilities-page.tsx +159 -0
  34. package/src/pages/agent-detail-page.tsx +1 -0
  35. package/src/pages/index.ts +2 -0
  36. package/src/pages/integrations-management-page.tsx +166 -0
  37. package/src/types/capabilities.ts +32 -0
  38. package/src/types/index.ts +10 -0
@@ -57,6 +57,7 @@ export function AgentDetailPage({
57
57
  <Button
58
58
  variant="ghost"
59
59
  size="icon"
60
+ aria-label="Voltar"
60
61
  className="shrink-0 mt-1"
61
62
  onClick={onBack}
62
63
  >
@@ -1,4 +1,6 @@
1
1
  export { AgentsPage, type AgentsPageProps } from "./agents-page";
2
2
  export { AgentDetailPage, type AgentDetailPageProps } from "./agent-detail-page";
3
+ export { AgentCapabilitiesPage, type AgentCapabilitiesPageProps } from "./agent-capabilities-page";
3
4
  export { ToolsPage, type ToolsPageProps } from "./tools-page";
4
5
  export { CredentialsPage, type CredentialsPageProps } from "./credentials-page";
6
+ export { IntegrationsManagementPage, type IntegrationsManagementPageProps } from "./integrations-management-page";
@@ -0,0 +1,166 @@
1
+ 'use client';
2
+
3
+ import { useState, useMemo } from "react";
4
+ import { useToolCredentials, useAgents, useTools } from "../hooks";
5
+ import { ToolCredentialsForm } from "../components/tools/tool-credentials-form";
6
+ import { IntegrationsTab } from "../components/capabilities/integrations-tab";
7
+ import {
8
+ Badge,
9
+ Button,
10
+ Tabs,
11
+ TabsContent,
12
+ TabsList,
13
+ TabsTrigger,
14
+ } from "@greatapps/greatauth-ui/ui";
15
+ import { Plus, Plug, KeyRound, Info } from "lucide-react";
16
+ import type { GagentsHookConfig } from "../hooks/types";
17
+ import type { IntegrationCardData } from "../hooks/use-integrations";
18
+ import type { Agent, Tool, ToolCredential } from "../types";
19
+
20
+ export interface IntegrationsManagementPageProps {
21
+ config: GagentsHookConfig;
22
+ gagentsApiUrl: string;
23
+ /** Called when user clicks connect/reconnect on an integration card. */
24
+ onConnect?: (card: IntegrationCardData) => void;
25
+ title?: string;
26
+ subtitle?: string;
27
+ }
28
+
29
+ /**
30
+ * Build a map of credential id → list of agent names that use it.
31
+ * Cross-references tools (which link credential via id) with agents
32
+ * that have agent_tools referencing those tools.
33
+ *
34
+ * Since we don't have an account-level agent_tools endpoint, we
35
+ * approximate by checking which tools are linked to credentials and
36
+ * showing credential-level stats.
37
+ */
38
+ function useCredentialAgentSummary(
39
+ credentials: ToolCredential[],
40
+ tools: Tool[],
41
+ agents: Agent[],
42
+ ) {
43
+ return useMemo(() => {
44
+ // Build a set of tool IDs that have credentials
45
+ const toolIdsWithCredentials = new Set(
46
+ credentials.map((c) => c.id_tool).filter(Boolean),
47
+ );
48
+
49
+ // Count how many credentials are linked to tools that agents could use
50
+ const linkedCount = credentials.filter(
51
+ (c) => c.id_tool && toolIdsWithCredentials.has(c.id_tool),
52
+ ).length;
53
+
54
+ return {
55
+ totalCredentials: credentials.length,
56
+ linkedToTools: linkedCount,
57
+ totalAgents: agents.length,
58
+ totalTools: tools.length,
59
+ };
60
+ }, [credentials, tools, agents]);
61
+ }
62
+
63
+ export function IntegrationsManagementPage({
64
+ config,
65
+ gagentsApiUrl,
66
+ onConnect,
67
+ title = "Integrações e Credenciais",
68
+ subtitle = "Gerencie todas as integrações e credenciais da conta.",
69
+ }: IntegrationsManagementPageProps) {
70
+ const { data: credentialsData, isLoading: credentialsLoading } =
71
+ useToolCredentials(config);
72
+ const { data: agentsData } = useAgents(config);
73
+ const { data: toolsData } = useTools(config);
74
+ const [createOpen, setCreateOpen] = useState(false);
75
+
76
+ const credentials = credentialsData?.data || [];
77
+ const agents: Agent[] = agentsData?.data || [];
78
+ const tools: Tool[] = toolsData?.data || [];
79
+
80
+ const summary = useCredentialAgentSummary(credentials, tools, agents);
81
+
82
+ return (
83
+ <div className="flex flex-col gap-4 p-4 md:p-6">
84
+ <div className="flex items-center justify-between">
85
+ <div>
86
+ <h1 className="text-xl font-semibold">{title}</h1>
87
+ <p className="text-sm text-muted-foreground">{subtitle}</p>
88
+ </div>
89
+ </div>
90
+
91
+ <Tabs defaultValue="integrations" className="w-full">
92
+ <TabsList>
93
+ <TabsTrigger value="integrations" className="gap-2">
94
+ <Plug className="h-4 w-4" />
95
+ Integrações
96
+ </TabsTrigger>
97
+ <TabsTrigger value="credentials" className="gap-2">
98
+ <KeyRound className="h-4 w-4" />
99
+ Credenciais
100
+ </TabsTrigger>
101
+ </TabsList>
102
+
103
+ <TabsContent value="integrations" className="mt-4">
104
+ <IntegrationsTab
105
+ config={config}
106
+ agentId={null}
107
+ onConnect={onConnect ?? (() => {})}
108
+ />
109
+ </TabsContent>
110
+
111
+ <TabsContent value="credentials" className="mt-4">
112
+ {/* Summary bar */}
113
+ {!credentialsLoading && (
114
+ <div className="flex items-center gap-4 rounded-lg border bg-muted/50 px-4 py-3 mb-4">
115
+ <Info className="h-4 w-4 text-muted-foreground shrink-0" />
116
+ <div className="flex flex-wrap items-center gap-3 text-sm">
117
+ <span>
118
+ <Badge variant="secondary" className="mr-1">
119
+ {summary.totalCredentials}
120
+ </Badge>
121
+ {summary.totalCredentials === 1
122
+ ? "credencial configurada"
123
+ : "credenciais configuradas"}
124
+ </span>
125
+ <span className="text-muted-foreground">|</span>
126
+ <span>
127
+ <Badge variant="secondary" className="mr-1">
128
+ {summary.linkedToTools}
129
+ </Badge>
130
+ {summary.linkedToTools === 1
131
+ ? "vinculada a ferramentas"
132
+ : "vinculadas a ferramentas"}
133
+ </span>
134
+ <span className="text-muted-foreground">|</span>
135
+ <span>
136
+ <Badge variant="secondary" className="mr-1">
137
+ {summary.totalAgents}
138
+ </Badge>
139
+ {summary.totalAgents === 1
140
+ ? "agente na conta"
141
+ : "agentes na conta"}
142
+ </span>
143
+ </div>
144
+ </div>
145
+ )}
146
+
147
+ <div className="flex items-center justify-end mb-4">
148
+ <Button onClick={() => setCreateOpen(true)} size="sm">
149
+ <Plus className="mr-2 h-4 w-4" />
150
+ Nova Credencial
151
+ </Button>
152
+ </div>
153
+
154
+ <ToolCredentialsForm
155
+ config={config}
156
+ gagentsApiUrl={gagentsApiUrl}
157
+ credentials={credentials}
158
+ isLoading={credentialsLoading}
159
+ createOpen={createOpen}
160
+ onCreateOpenChange={setCreateOpen}
161
+ />
162
+ </TabsContent>
163
+ </Tabs>
164
+ </div>
165
+ );
166
+ }
@@ -0,0 +1,32 @@
1
+ export interface CapabilityOperation {
2
+ slug: string;
3
+ label: string;
4
+ description: string;
5
+ }
6
+
7
+ export interface CapabilityModule {
8
+ slug: string;
9
+ label: string;
10
+ description: string;
11
+ operations: string[];
12
+ }
13
+
14
+ export interface CapabilityCategory {
15
+ slug: string;
16
+ label: string;
17
+ modules: CapabilityModule[];
18
+ }
19
+
20
+ export interface CapabilitiesResponse {
21
+ product: string | null;
22
+ categories: CapabilityCategory[];
23
+ }
24
+
25
+ export interface AgentCapability {
26
+ module: string;
27
+ operations: string[];
28
+ }
29
+
30
+ export interface AgentCapabilitiesPayload {
31
+ capabilities: AgentCapability[];
32
+ }
@@ -154,3 +154,13 @@ export interface AvailabilityResult {
154
154
  conflicts: AvailabilityConflict[];
155
155
  failed_providers: Array<{ provider: string; error: string }>;
156
156
  }
157
+
158
+ // Capabilities
159
+ export type {
160
+ CapabilityOperation,
161
+ CapabilityModule,
162
+ CapabilityCategory,
163
+ CapabilitiesResponse,
164
+ AgentCapability,
165
+ AgentCapabilitiesPayload,
166
+ } from "./capabilities";