@greatapps/greatagents-ui 0.3.26 → 0.3.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -250,6 +250,9 @@ declare function createGagentsClient(config: GagentsClientConfig): {
250
250
  end_time: string;
251
251
  }) => Promise<ApiResponse<AvailabilityResult>>;
252
252
  disconnectCalendar: (idAccount: number, externalReference: string, provider?: string) => Promise<ApiResponse<void>>;
253
+ publishAgent: (idAccount: number, agentId: number, changeNotes?: string) => Promise<ApiResponse<{
254
+ version: number;
255
+ }>>;
253
256
  getCapabilities: (idAccount: number) => Promise<ApiResponse<CapabilitiesResponse>>;
254
257
  getAgentCapabilities: (idAccount: number, idAgent: number) => Promise<ApiResponse<AgentCapability[]>>;
255
258
  updateAgentCapabilities: (idAccount: number, idAgent: number, body: AgentCapabilitiesPayload) => Promise<ApiResponse<AgentCapability[]>>;
@@ -311,6 +314,9 @@ declare function useGagentsClient(config: GagentsHookConfig): {
311
314
  end_time: string;
312
315
  }) => Promise<ApiResponse<AvailabilityResult>>;
313
316
  disconnectCalendar: (idAccount: number, externalReference: string, provider?: string) => Promise<ApiResponse<void>>;
317
+ publishAgent: (idAccount: number, agentId: number, changeNotes?: string) => Promise<ApiResponse<{
318
+ version: number;
319
+ }>>;
314
320
  getCapabilities: (idAccount: number) => Promise<ApiResponse<CapabilitiesResponse>>;
315
321
  getAgentCapabilities: (idAccount: number, idAgent: number) => Promise<ApiResponse<AgentCapability[]>>;
316
322
  updateAgentCapabilities: (idAccount: number, idAgent: number, body: AgentCapabilitiesPayload) => Promise<ApiResponse<AgentCapability[]>>;
@@ -344,6 +350,12 @@ declare function useUpdateAgent(config: GagentsHookConfig): _tanstack_react_quer
344
350
  active?: boolean;
345
351
  };
346
352
  }, unknown>;
353
+ declare function usePublishAgent(config: GagentsHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<{
354
+ version: number;
355
+ }>, Error, {
356
+ id: number;
357
+ changeNotes?: string;
358
+ }, unknown>;
347
359
  declare function useDeleteAgent(config: GagentsHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<void>, Error, number, unknown>;
348
360
 
349
361
  declare function useTools(config: GagentsHookConfig, params?: Record<string, string>): _tanstack_react_query.UseQueryResult<{
@@ -822,4 +834,4 @@ interface IntegrationsManagementPageProps {
822
834
  }
823
835
  declare function IntegrationsManagementPage({ config, gagentsApiUrl, resolveWizardMeta, loadConfigOptions, onWizardComplete, title, subtitle, }: IntegrationsManagementPageProps): react_jsx_runtime.JSX.Element;
824
836
 
825
- export { AdvancedTab, type AdvancedTabProps, type Agent, AgentCapabilitiesPage, type AgentCapabilitiesPageProps, type AgentCapabilitiesPayload, type AgentCapability, AgentConversationsPanel, AgentConversationsTable, AgentDefinitionEditor, AgentDetailPage, type AgentDetailPageProps, AgentEditForm, AgentFormDialog, AgentObjectivesList, AgentRevisionTab, AgentTabs, type AgentTool, AgentToolsList, AgentsPage, type AgentsPageProps, AgentsTable, type ApiResponse, type AvailabilityConflict, type AvailabilityResult, type CalendarStatus, type CapabilitiesResponse, CapabilitiesTab, type CapabilitiesTabProps, type CapabilityCategory, type CapabilityModule, type CapabilityOperation, type ConfigOption, type ContactUser, type Conversation, ConversationFlowEditor, type ConversationFlowStep, ConversationView, CredentialsPage, type CredentialsPageProps, type GagentsClient, type GagentsClientConfig, type GagentsContact, type GagentsHookConfig, INTEGRATIONS_REGISTRY, type IntegrationAuthType, type IntegrationCapability, IntegrationCard, type IntegrationCardData, type IntegrationCardProps, type IntegrationCardState, type IntegrationDefinition, type IntegrationStatus, IntegrationWizard, type IntegrationWizardProps, IntegrationsManagementPage, type IntegrationsManagementPageProps, IntegrationsTab, type IntegrationsTabProps, type OAuthResult, type OAuthStatus, type Objective, type PromptVersion, Sortable, SortableContent, SortableItem, SortableItemHandle, SortableOverlay, type Tool, type ToolCredential, ToolCredentialsForm, ToolFormDialog, ToolsPage, type ToolsPageProps, ToolsTable, type WizardIntegrationMeta, type WizardStep, cn, createGagentsClient, useAddAgentTool, useAgent, useAgentCapabilities, useAgentConversations, useAgentTools, useAgents, useCapabilities, useContactUsers, useConversation, useConversations, useCreateAgent, useCreateObjective, useCreateTool, useCreateToolCredential, useDeleteAgent, useDeleteObjective, useDeleteTool, useDeleteToolCredential, useGagentsClient, useGagentsContacts, useIntegrationState, useObjectives, usePromptVersions, useRemoveAgentTool, useTool, useToolCredentials, useTools, useUpdateAgent, useUpdateAgentCapabilities, useUpdateAgentTool, useUpdateObjective, useUpdateTool, useUpdateToolCredential };
837
+ export { AdvancedTab, type AdvancedTabProps, type Agent, AgentCapabilitiesPage, type AgentCapabilitiesPageProps, type AgentCapabilitiesPayload, type AgentCapability, AgentConversationsPanel, AgentConversationsTable, AgentDefinitionEditor, AgentDetailPage, type AgentDetailPageProps, AgentEditForm, AgentFormDialog, AgentObjectivesList, AgentRevisionTab, AgentTabs, type AgentTool, AgentToolsList, AgentsPage, type AgentsPageProps, AgentsTable, type ApiResponse, type AvailabilityConflict, type AvailabilityResult, type CalendarStatus, type CapabilitiesResponse, CapabilitiesTab, type CapabilitiesTabProps, type CapabilityCategory, type CapabilityModule, type CapabilityOperation, type ConfigOption, type ContactUser, type Conversation, ConversationFlowEditor, type ConversationFlowStep, ConversationView, CredentialsPage, type CredentialsPageProps, type GagentsClient, type GagentsClientConfig, type GagentsContact, type GagentsHookConfig, INTEGRATIONS_REGISTRY, type IntegrationAuthType, type IntegrationCapability, IntegrationCard, type IntegrationCardData, type IntegrationCardProps, type IntegrationCardState, type IntegrationDefinition, type IntegrationStatus, IntegrationWizard, type IntegrationWizardProps, IntegrationsManagementPage, type IntegrationsManagementPageProps, IntegrationsTab, type IntegrationsTabProps, type OAuthResult, type OAuthStatus, type Objective, type PromptVersion, Sortable, SortableContent, SortableItem, SortableItemHandle, SortableOverlay, type Tool, type ToolCredential, ToolCredentialsForm, ToolFormDialog, ToolsPage, type ToolsPageProps, ToolsTable, type WizardIntegrationMeta, type WizardStep, cn, createGagentsClient, useAddAgentTool, useAgent, useAgentCapabilities, useAgentConversations, useAgentTools, useAgents, useCapabilities, useContactUsers, useConversation, useConversations, useCreateAgent, useCreateObjective, useCreateTool, useCreateToolCredential, useDeleteAgent, useDeleteObjective, useDeleteTool, useDeleteToolCredential, useGagentsClient, useGagentsContacts, useIntegrationState, useObjectives, usePromptVersions, usePublishAgent, useRemoveAgentTool, useTool, useToolCredentials, useTools, useUpdateAgent, useUpdateAgentCapabilities, useUpdateAgentTool, useUpdateObjective, useUpdateTool, useUpdateToolCredential };
package/dist/index.js CHANGED
@@ -89,6 +89,21 @@ function createGagentsClient(config) {
89
89
  void 0,
90
90
  { provider }
91
91
  ),
92
+ // --- Publish ---
93
+ publishAgent: async (idAccount, agentId, changeNotes) => {
94
+ const url = buildUrl(idAccount, `agents/${agentId}/publish`);
95
+ const res = await fetch(url, {
96
+ method: "POST",
97
+ headers: {
98
+ Authorization: `Bearer ${token}`,
99
+ "Content-Type": "application/json"
100
+ },
101
+ body: JSON.stringify({ change_notes: changeNotes || "" })
102
+ });
103
+ const json = await res.json();
104
+ if (json.status === 0 && !res.ok) throw new Error(json.message || "Erro ao publicar");
105
+ return json;
106
+ },
92
107
  // --- Capabilities ---
93
108
  getCapabilities: (idAccount) => request("GET", idAccount, "capabilities"),
94
109
  getAgentCapabilities: (idAccount, idAgent) => request("GET", idAccount, `agents/${idAgent}/capabilities`),
@@ -169,6 +184,24 @@ function useUpdateAgent(config) {
169
184
  }
170
185
  });
171
186
  }
187
+ function usePublishAgent(config) {
188
+ const queryClient = useQueryClient();
189
+ const client = useGagentsClient(config);
190
+ return useMutation({
191
+ mutationFn: async (variables) => {
192
+ return client.publishAgent(Number(config.accountId), variables.id, variables.changeNotes);
193
+ },
194
+ onSuccess: (_data, variables) => {
195
+ queryClient.invalidateQueries({ queryKey: ["greatagents", "agents"] });
196
+ queryClient.invalidateQueries({
197
+ queryKey: ["greatagents", "agent", config.accountId, variables.id]
198
+ });
199
+ queryClient.invalidateQueries({
200
+ queryKey: ["greatagents", "prompt-versions", config.accountId, variables.id]
201
+ });
202
+ }
203
+ });
204
+ }
172
205
  function useDeleteAgent(config) {
173
206
  const client = useGagentsClient(config);
174
207
  const queryClient = useQueryClient();
@@ -5771,9 +5804,23 @@ function AgentsPage({
5771
5804
 
5772
5805
  // src/pages/agent-detail-page.tsx
5773
5806
  import { useState as useState20 } from "react";
5774
- import { Badge as Badge10, Button as Button19, Skeleton as Skeleton7 } from "@greatapps/greatauth-ui/ui";
5807
+ import {
5808
+ AlertDialog as AlertDialog7,
5809
+ AlertDialogAction as AlertDialogAction7,
5810
+ AlertDialogCancel as AlertDialogCancel7,
5811
+ AlertDialogContent as AlertDialogContent7,
5812
+ AlertDialogDescription as AlertDialogDescription7,
5813
+ AlertDialogFooter as AlertDialogFooter7,
5814
+ AlertDialogHeader as AlertDialogHeader7,
5815
+ AlertDialogTitle as AlertDialogTitle7,
5816
+ Badge as Badge10,
5817
+ Button as Button19,
5818
+ Input as Input10,
5819
+ Skeleton as Skeleton7
5820
+ } from "@greatapps/greatauth-ui/ui";
5775
5821
  import { EntityAvatar as EntityAvatar2 } from "@greatapps/greatauth-ui";
5776
- import { ArrowLeft, Pencil as Pencil6 } from "lucide-react";
5822
+ import { ArrowLeft, Loader2 as Loader210, Pencil as Pencil6, Upload } from "lucide-react";
5823
+ import { toast as toast14 } from "sonner";
5777
5824
  import { jsx as jsx27, jsxs as jsxs25 } from "react/jsx-runtime";
5778
5825
  function AgentDetailPage({
5779
5826
  config,
@@ -5782,7 +5829,25 @@ function AgentDetailPage({
5782
5829
  renderChatLink
5783
5830
  }) {
5784
5831
  const { data: agent, isLoading } = useAgent(config, agentId);
5832
+ const publishAgent = usePublishAgent(config);
5785
5833
  const [editOpen, setEditOpen] = useState20(false);
5834
+ const [publishOpen, setPublishOpen] = useState20(false);
5835
+ const [publishNotes, setPublishNotes] = useState20("");
5836
+ async function handlePublish() {
5837
+ if (!agent) return;
5838
+ try {
5839
+ const result = await publishAgent.mutateAsync({ id: agent.id, changeNotes: publishNotes.trim() });
5840
+ setPublishOpen(false);
5841
+ setPublishNotes("");
5842
+ if (result.message?.includes("Sem altera\xE7\xF5es")) {
5843
+ toast14.info(result.message);
5844
+ } else {
5845
+ toast14.success(result.message || "Agente publicado");
5846
+ }
5847
+ } catch (err) {
5848
+ toast14.error(err instanceof Error ? err.message : "Erro ao publicar agente");
5849
+ }
5850
+ }
5786
5851
  if (isLoading) {
5787
5852
  return /* @__PURE__ */ jsxs25("div", { className: "flex flex-col gap-4 p-4", children: [
5788
5853
  /* @__PURE__ */ jsx27(Skeleton7, { className: "h-4 w-32" }),
@@ -5827,19 +5892,33 @@ function AgentDetailPage({
5827
5892
  )
5828
5893
  ] }) })
5829
5894
  ] }),
5830
- /* @__PURE__ */ jsxs25(
5831
- Button19,
5832
- {
5833
- variant: "outline",
5834
- size: "sm",
5835
- className: "shrink-0 self-start",
5836
- onClick: () => setEditOpen(true),
5837
- children: [
5838
- /* @__PURE__ */ jsx27(Pencil6, { className: "mr-2 h-4 w-4" }),
5839
- "Editar"
5840
- ]
5841
- }
5842
- )
5895
+ /* @__PURE__ */ jsxs25("div", { className: "flex gap-2 shrink-0 self-start", children: [
5896
+ /* @__PURE__ */ jsxs25(
5897
+ Button19,
5898
+ {
5899
+ variant: "default",
5900
+ size: "sm",
5901
+ onClick: () => setPublishOpen(true),
5902
+ disabled: publishAgent.isPending,
5903
+ children: [
5904
+ publishAgent.isPending ? /* @__PURE__ */ jsx27(Loader210, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx27(Upload, { className: "mr-2 h-4 w-4" }),
5905
+ "Publicar"
5906
+ ]
5907
+ }
5908
+ ),
5909
+ /* @__PURE__ */ jsxs25(
5910
+ Button19,
5911
+ {
5912
+ variant: "outline",
5913
+ size: "sm",
5914
+ onClick: () => setEditOpen(true),
5915
+ children: [
5916
+ /* @__PURE__ */ jsx27(Pencil6, { className: "mr-2 h-4 w-4" }),
5917
+ "Editar"
5918
+ ]
5919
+ }
5920
+ )
5921
+ ] })
5843
5922
  ] }) }),
5844
5923
  /* @__PURE__ */ jsx27(
5845
5924
  AgentTabs,
@@ -5858,7 +5937,36 @@ function AgentDetailPage({
5858
5937
  open: editOpen,
5859
5938
  onOpenChange: setEditOpen
5860
5939
  }
5861
- )
5940
+ ),
5941
+ /* @__PURE__ */ jsx27(AlertDialog7, { open: publishOpen, onOpenChange: setPublishOpen, children: /* @__PURE__ */ jsxs25(AlertDialogContent7, { children: [
5942
+ /* @__PURE__ */ jsxs25(AlertDialogHeader7, { children: [
5943
+ /* @__PURE__ */ jsx27(AlertDialogTitle7, { children: "Publicar nova vers\xE3o do agente?" }),
5944
+ /* @__PURE__ */ jsx27(AlertDialogDescription7, { children: "O prompt ser\xE1 actualizado com todas as configura\xE7\xF5es actuais e uma nova vers\xE3o ser\xE1 criada." })
5945
+ ] }),
5946
+ /* @__PURE__ */ jsx27("div", { className: "py-2", children: /* @__PURE__ */ jsx27(
5947
+ Input10,
5948
+ {
5949
+ value: publishNotes,
5950
+ onChange: (e) => setPublishNotes(e.target.value),
5951
+ placeholder: "O que mudou? (opcional)",
5952
+ onKeyDown: (e) => {
5953
+ if (e.key === "Enter") {
5954
+ e.preventDefault();
5955
+ handlePublish();
5956
+ }
5957
+ }
5958
+ }
5959
+ ) }),
5960
+ /* @__PURE__ */ jsxs25(AlertDialogFooter7, { children: [
5961
+ /* @__PURE__ */ jsx27(AlertDialogCancel7, { onClick: () => {
5962
+ setPublishNotes("");
5963
+ }, children: "Cancelar" }),
5964
+ /* @__PURE__ */ jsxs25(AlertDialogAction7, { onClick: handlePublish, disabled: publishAgent.isPending, children: [
5965
+ publishAgent.isPending && /* @__PURE__ */ jsx27(Loader210, { className: "mr-2 h-4 w-4 animate-spin" }),
5966
+ "Publicar"
5967
+ ] })
5968
+ ] })
5969
+ ] }) })
5862
5970
  ] });
5863
5971
  }
5864
5972
 
@@ -5984,7 +6092,7 @@ function CredentialsPage({
5984
6092
  // src/pages/integrations-management-page.tsx
5985
6093
  import { useCallback as useCallback8, useState as useState22 } from "react";
5986
6094
  import { useQueryClient as useQueryClient7 } from "@tanstack/react-query";
5987
- import { Plug as Plug5, Loader2 as Loader210 } from "lucide-react";
6095
+ import { Plug as Plug5, Loader2 as Loader211 } from "lucide-react";
5988
6096
  import { jsx as jsx31, jsxs as jsxs29 } from "react/jsx-runtime";
5989
6097
  function IntegrationsManagementPage({
5990
6098
  config,
@@ -6052,7 +6160,7 @@ function IntegrationsManagementPage({
6052
6160
  /* @__PURE__ */ jsx31("h1", { className: "text-xl font-semibold", children: title }),
6053
6161
  /* @__PURE__ */ jsx31("p", { className: "text-sm text-muted-foreground", children: subtitle })
6054
6162
  ] }) }),
6055
- cardsLoading ? /* @__PURE__ */ jsx31("div", { className: "flex items-center justify-center py-16", children: /* @__PURE__ */ jsx31(Loader210, { className: "h-6 w-6 animate-spin text-muted-foreground" }) }) : cards.length === 0 ? /* @__PURE__ */ jsxs29("div", { className: "flex flex-col items-center justify-center gap-3 py-16 text-muted-foreground", children: [
6163
+ cardsLoading ? /* @__PURE__ */ jsx31("div", { className: "flex items-center justify-center py-16", children: /* @__PURE__ */ jsx31(Loader211, { className: "h-6 w-6 animate-spin text-muted-foreground" }) }) : cards.length === 0 ? /* @__PURE__ */ jsxs29("div", { className: "flex flex-col items-center justify-center gap-3 py-16 text-muted-foreground", children: [
6056
6164
  /* @__PURE__ */ jsx31(Plug5, { className: "h-10 w-10" }),
6057
6165
  /* @__PURE__ */ jsx31("p", { className: "text-sm", children: "Nenhuma integra\xE7\xE3o dispon\xEDvel" })
6058
6166
  ] }) : /* @__PURE__ */ jsxs29("div", { className: "space-y-6", children: [
@@ -6160,6 +6268,7 @@ export {
6160
6268
  useIntegrationState,
6161
6269
  useObjectives,
6162
6270
  usePromptVersions,
6271
+ usePublishAgent,
6163
6272
  useRemoveAgentTool,
6164
6273
  useTool,
6165
6274
  useToolCredentials,