@greatapps/greatagents-ui 0.2.1 → 0.3.0
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 +10 -5
- package/dist/index.js +21 -33
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client/index.ts +3 -3
- package/src/components/agents/agent-form-dialog.tsx +1 -16
- package/src/components/agents/agent-prompt-editor.tsx +17 -9
- package/src/types/index.ts +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ interface Agent {
|
|
|
15
15
|
id: number;
|
|
16
16
|
id_account: number;
|
|
17
17
|
title: string;
|
|
18
|
-
prompt: string | null;
|
|
19
18
|
photo: string | null;
|
|
20
19
|
external_token: string | null;
|
|
21
20
|
openai_assistant_id: string | null;
|
|
@@ -163,8 +162,11 @@ interface GagentsClientConfig {
|
|
|
163
162
|
declare function createGagentsClient(config: GagentsClientConfig): {
|
|
164
163
|
listAgents: (idAccount: number, params?: Record<string, string>) => Promise<ApiResponse<Agent[]>>;
|
|
165
164
|
getAgent: (idAccount: number, id: number) => Promise<ApiResponse<Agent>>;
|
|
166
|
-
createAgent: (idAccount: number, body: Pick<Agent, "title"> & Partial<Pick<Agent, "
|
|
167
|
-
updateAgent: (idAccount: number, id: number, body: Partial<Pick<Agent, "title" | "
|
|
165
|
+
createAgent: (idAccount: number, body: Pick<Agent, "title"> & Partial<Pick<Agent, "photo" | "delay_typing" | "waiting_time">>) => Promise<ApiResponse<Agent>>;
|
|
166
|
+
updateAgent: (idAccount: number, id: number, body: Partial<Pick<Agent, "title" | "photo" | "delay_typing" | "waiting_time" | "active">> & {
|
|
167
|
+
prompt?: string;
|
|
168
|
+
change_notes?: string;
|
|
169
|
+
}) => Promise<ApiResponse<Agent>>;
|
|
168
170
|
deleteAgent: (idAccount: number, id: number) => Promise<ApiResponse<void>>;
|
|
169
171
|
listTools: (idAccount: number, params?: Record<string, string>) => Promise<ApiResponse<Tool[]>>;
|
|
170
172
|
getTool: (idAccount: number, id: number) => Promise<ApiResponse<Tool>>;
|
|
@@ -219,8 +221,11 @@ interface GagentsHookConfig {
|
|
|
219
221
|
declare function useGagentsClient(config: GagentsHookConfig): {
|
|
220
222
|
listAgents: (idAccount: number, params?: Record<string, string>) => Promise<ApiResponse<Agent[]>>;
|
|
221
223
|
getAgent: (idAccount: number, id: number) => Promise<ApiResponse<Agent>>;
|
|
222
|
-
createAgent: (idAccount: number, body: Pick<Agent, "title"> & Partial<Pick<Agent, "
|
|
223
|
-
updateAgent: (idAccount: number, id: number, body: Partial<Pick<Agent, "title" | "
|
|
224
|
+
createAgent: (idAccount: number, body: Pick<Agent, "title"> & Partial<Pick<Agent, "photo" | "delay_typing" | "waiting_time">>) => Promise<ApiResponse<Agent>>;
|
|
225
|
+
updateAgent: (idAccount: number, id: number, body: Partial<Pick<Agent, "title" | "photo" | "delay_typing" | "waiting_time" | "active">> & {
|
|
226
|
+
prompt?: string;
|
|
227
|
+
change_notes?: string;
|
|
228
|
+
}) => Promise<ApiResponse<Agent>>;
|
|
224
229
|
deleteAgent: (idAccount: number, id: number) => Promise<ApiResponse<void>>;
|
|
225
230
|
listTools: (idAccount: number, params?: Record<string, string>) => Promise<ApiResponse<Tool[]>>;
|
|
226
231
|
getTool: (idAccount: number, id: number) => Promise<ApiResponse<Tool>>;
|
package/dist/index.js
CHANGED
|
@@ -628,7 +628,6 @@ import {
|
|
|
628
628
|
DialogFooter,
|
|
629
629
|
Button as Button2,
|
|
630
630
|
Input as Input2,
|
|
631
|
-
Textarea,
|
|
632
631
|
Label
|
|
633
632
|
} from "@greatapps/greatauth-ui/ui";
|
|
634
633
|
import { Loader2 } from "lucide-react";
|
|
@@ -644,20 +643,17 @@ function AgentFormDialog({
|
|
|
644
643
|
const createAgent = useCreateAgent(config);
|
|
645
644
|
const updateAgent = useUpdateAgent(config);
|
|
646
645
|
const [title, setTitle] = useState2("");
|
|
647
|
-
const [prompt, setPrompt] = useState2("");
|
|
648
646
|
const [photo, setPhoto] = useState2("");
|
|
649
647
|
const [delayTyping, setDelayTyping] = useState2("");
|
|
650
648
|
const [waitingTime, setWaitingTime] = useState2("");
|
|
651
649
|
useEffect(() => {
|
|
652
650
|
if (agent) {
|
|
653
651
|
setTitle(agent.title);
|
|
654
|
-
setPrompt(agent.prompt || "");
|
|
655
652
|
setPhoto(agent.photo || "");
|
|
656
653
|
setDelayTyping(agent.delay_typing != null ? String(agent.delay_typing) : "");
|
|
657
654
|
setWaitingTime(agent.waiting_time != null ? String(agent.waiting_time) : "");
|
|
658
655
|
} else {
|
|
659
656
|
setTitle("");
|
|
660
|
-
setPrompt("");
|
|
661
657
|
setPhoto("");
|
|
662
658
|
setDelayTyping("");
|
|
663
659
|
setWaitingTime("");
|
|
@@ -670,7 +666,6 @@ function AgentFormDialog({
|
|
|
670
666
|
const body = {
|
|
671
667
|
title: title.trim()
|
|
672
668
|
};
|
|
673
|
-
if (prompt.trim()) body.prompt = prompt.trim();
|
|
674
669
|
if (photo.trim()) body.photo = photo.trim();
|
|
675
670
|
if (delayTyping.trim()) body.delay_typing = Number(delayTyping);
|
|
676
671
|
if (waitingTime.trim()) body.waiting_time = Number(waitingTime);
|
|
@@ -719,20 +714,6 @@ function AgentFormDialog({
|
|
|
719
714
|
}
|
|
720
715
|
)
|
|
721
716
|
] }),
|
|
722
|
-
/* @__PURE__ */ jsxs2("div", { className: "space-y-2", children: [
|
|
723
|
-
/* @__PURE__ */ jsx2(Label, { htmlFor: "agent-prompt", children: "Prompt do Sistema" }),
|
|
724
|
-
/* @__PURE__ */ jsx2(
|
|
725
|
-
Textarea,
|
|
726
|
-
{
|
|
727
|
-
id: "agent-prompt",
|
|
728
|
-
value: prompt,
|
|
729
|
-
onChange: (e) => setPrompt(e.target.value),
|
|
730
|
-
placeholder: "Instru\xE7\xF5es para o agente AI...",
|
|
731
|
-
rows: 6,
|
|
732
|
-
disabled: isPending
|
|
733
|
-
}
|
|
734
|
-
)
|
|
735
|
-
] }),
|
|
736
717
|
/* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
737
718
|
/* @__PURE__ */ jsxs2("div", { className: "space-y-2", children: [
|
|
738
719
|
/* @__PURE__ */ jsx2(Label, { htmlFor: "agent-delay", children: "Delay de Digita\xE7\xE3o (ms)" }),
|
|
@@ -983,7 +964,7 @@ import {
|
|
|
983
964
|
PopoverContent,
|
|
984
965
|
PopoverTrigger,
|
|
985
966
|
Input as Input4,
|
|
986
|
-
Textarea
|
|
967
|
+
Textarea,
|
|
987
968
|
Dialog as Dialog3,
|
|
988
969
|
DialogContent as DialogContent3,
|
|
989
970
|
DialogHeader as DialogHeader3,
|
|
@@ -1223,7 +1204,7 @@ function AgentToolsList({ agent, config }) {
|
|
|
1223
1204
|
/* @__PURE__ */ jsxs4("div", { className: "space-y-2", children: [
|
|
1224
1205
|
/* @__PURE__ */ jsx4(Label3, { children: "Instru\xE7\xF5es Personalizadas" }),
|
|
1225
1206
|
/* @__PURE__ */ jsx4(
|
|
1226
|
-
|
|
1207
|
+
Textarea,
|
|
1227
1208
|
{
|
|
1228
1209
|
value: configInstructions,
|
|
1229
1210
|
onChange: (e) => setConfigInstructions(e.target.value),
|
|
@@ -1289,7 +1270,7 @@ import {
|
|
|
1289
1270
|
Button as Button5,
|
|
1290
1271
|
Switch as Switch3,
|
|
1291
1272
|
Skeleton as Skeleton2,
|
|
1292
|
-
Textarea as
|
|
1273
|
+
Textarea as Textarea2,
|
|
1293
1274
|
Label as Label4,
|
|
1294
1275
|
Badge as Badge3,
|
|
1295
1276
|
Dialog as Dialog4,
|
|
@@ -2012,7 +1993,7 @@ function AgentObjectivesList({ agent, config }) {
|
|
|
2012
1993
|
/* @__PURE__ */ jsxs5("div", { className: "space-y-2", children: [
|
|
2013
1994
|
/* @__PURE__ */ jsx6(Label4, { children: "Instru\xE7\xF5es do Objetivo" }),
|
|
2014
1995
|
/* @__PURE__ */ jsx6(
|
|
2015
|
-
|
|
1996
|
+
Textarea2,
|
|
2016
1997
|
{
|
|
2017
1998
|
value: form.prompt,
|
|
2018
1999
|
onChange: (e) => setForm((f) => ({ ...f, prompt: e.target.value })),
|
|
@@ -2141,15 +2122,27 @@ function AgentPromptEditor({ config, agent }) {
|
|
|
2141
2122
|
const { data: objectivesData } = useObjectives(config, agent.id);
|
|
2142
2123
|
const { data: agentToolsData } = useAgentTools(config, agent.id);
|
|
2143
2124
|
const { data: toolsData } = useTools(config);
|
|
2125
|
+
const versions = versionsData?.data || [];
|
|
2126
|
+
const sortedVersions = [...versions].sort(
|
|
2127
|
+
(a, b) => new Date(b.datetime_add).getTime() - new Date(a.datetime_add).getTime()
|
|
2128
|
+
);
|
|
2129
|
+
const currentVersion = sortedVersions.find((v) => v.is_current) || sortedVersions[0] || null;
|
|
2130
|
+
const currentPromptContent = currentVersion?.prompt_content ?? "";
|
|
2144
2131
|
const [trackedAgentId, setTrackedAgentId] = useState7(agent.id);
|
|
2145
|
-
const [promptText, setPromptText] = useState7(
|
|
2132
|
+
const [promptText, setPromptText] = useState7(currentPromptContent);
|
|
2133
|
+
const [promptInitialized, setPromptInitialized] = useState7(false);
|
|
2146
2134
|
const [changeNotes, setChangeNotes] = useState7("");
|
|
2147
2135
|
const [showPreview, setShowPreview] = useState7(false);
|
|
2148
2136
|
const [compareVersionId, setCompareVersionId] = useState7(null);
|
|
2149
2137
|
const textareaRef = useRef(null);
|
|
2138
|
+
if (!promptInitialized && currentPromptContent && !isLoading) {
|
|
2139
|
+
setPromptText(currentPromptContent);
|
|
2140
|
+
setPromptInitialized(true);
|
|
2141
|
+
}
|
|
2150
2142
|
if (trackedAgentId !== agent.id) {
|
|
2151
2143
|
setTrackedAgentId(agent.id);
|
|
2152
|
-
setPromptText(
|
|
2144
|
+
setPromptText(currentPromptContent);
|
|
2145
|
+
setPromptInitialized(!!currentPromptContent);
|
|
2153
2146
|
setCompareVersionId(null);
|
|
2154
2147
|
}
|
|
2155
2148
|
const autoResize = useCallback3(() => {
|
|
@@ -2175,11 +2168,6 @@ function AgentPromptEditor({ config, agent }) {
|
|
|
2175
2168
|
});
|
|
2176
2169
|
}
|
|
2177
2170
|
}
|
|
2178
|
-
const versions = versionsData?.data || [];
|
|
2179
|
-
const sortedVersions = [...versions].sort(
|
|
2180
|
-
(a, b) => new Date(b.datetime_add).getTime() - new Date(a.datetime_add).getTime()
|
|
2181
|
-
);
|
|
2182
|
-
const currentVersion = sortedVersions.length > 0 ? sortedVersions[0] : null;
|
|
2183
2171
|
const compareVersion = sortedVersions.find((v) => v.id === compareVersionId);
|
|
2184
2172
|
const diffLines = currentVersion && compareVersion && compareVersion.id !== currentVersion.id ? computeDiff(compareVersion.prompt_content ?? "", currentVersion.prompt_content ?? "") : null;
|
|
2185
2173
|
async function handleSave() {
|
|
@@ -2846,7 +2834,7 @@ import {
|
|
|
2846
2834
|
DialogFooter as DialogFooter5,
|
|
2847
2835
|
Button as Button9,
|
|
2848
2836
|
Input as Input8,
|
|
2849
|
-
Textarea as
|
|
2837
|
+
Textarea as Textarea3,
|
|
2850
2838
|
Label as Label5,
|
|
2851
2839
|
Select as Select2,
|
|
2852
2840
|
SelectContent as SelectContent2,
|
|
@@ -3039,7 +3027,7 @@ function ToolFormDialog({
|
|
|
3039
3027
|
/* @__PURE__ */ jsxs11("div", { className: "space-y-2", children: [
|
|
3040
3028
|
/* @__PURE__ */ jsx13(Label5, { htmlFor: "tool-description", children: "Descri\xE7\xE3o" }),
|
|
3041
3029
|
/* @__PURE__ */ jsx13(
|
|
3042
|
-
|
|
3030
|
+
Textarea3,
|
|
3043
3031
|
{
|
|
3044
3032
|
id: "tool-description",
|
|
3045
3033
|
value: form.description,
|
|
@@ -3053,7 +3041,7 @@ function ToolFormDialog({
|
|
|
3053
3041
|
/* @__PURE__ */ jsxs11("div", { className: "space-y-2", children: [
|
|
3054
3042
|
/* @__PURE__ */ jsx13(Label5, { htmlFor: "tool-function-defs", children: "Defini\xE7\xF5es de Fun\xE7\xE3o (JSON)" }),
|
|
3055
3043
|
/* @__PURE__ */ jsx13(
|
|
3056
|
-
|
|
3044
|
+
Textarea3,
|
|
3057
3045
|
{
|
|
3058
3046
|
id: "tool-function-defs",
|
|
3059
3047
|
value: form.functionDefinitions,
|