;
onRunCreated?: (execution: GraphExecutionMeta) => void;
+ onTriggerSetup?: (preset: LibraryAgentPreset) => void;
onScheduleCreated?: (schedule: GraphExecutionJobInfo) => void;
}
export function RunAgentModal({
triggerSlot,
agent,
+ initialInputValues,
+ initialInputCredentials,
onRunCreated,
+ onTriggerSetup,
onScheduleCreated,
}: Props) {
const {
@@ -71,6 +76,9 @@ export function RunAgentModal({
handleRun,
} = useAgentRunModal(agent, {
onRun: onRunCreated,
+ onSetupTrigger: onTriggerSetup,
+ initialInputValues,
+ initialInputCredentials,
});
const [isScheduleModalOpen, setIsScheduleModalOpen] = useState(false);
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/RunAgentModal/components/ModalRunSection/ModalRunSection.tsx b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/RunAgentModal/components/ModalRunSection/ModalRunSection.tsx
index c2528ccdc9..d8c4ecb730 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/RunAgentModal/components/ModalRunSection/ModalRunSection.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/RunAgentModal/components/ModalRunSection/ModalRunSection.tsx
@@ -26,7 +26,8 @@ export function ModalRunSection() {
return (
- {defaultRunType === "automatic-trigger" ? (
+ {defaultRunType === "automatic-trigger" ||
+ defaultRunType === "manual-trigger" ? (
- {defaultRunType === "automatic-trigger"
+ {defaultRunType === "automatic-trigger" ||
+ defaultRunType === "manual-trigger"
? "Set up Trigger"
: "Start Task"}
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/RunAgentModal/useAgentRunModal.tsx b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/RunAgentModal/useAgentRunModal.tsx
index 2d3da4bdc7..fcd3a7b87a 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/RunAgentModal/useAgentRunModal.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/RunAgentModal/useAgentRunModal.tsx
@@ -6,7 +6,6 @@ import {
getGetV2ListPresetsQueryKey,
usePostV2SetupTrigger,
} from "@/app/api/__generated__/endpoints/presets/presets";
-import { GraphExecutionJobInfo } from "@/app/api/__generated__/models/graphExecutionJobInfo";
import { GraphExecutionMeta } from "@/app/api/__generated__/models/graphExecutionMeta";
import { LibraryAgent } from "@/app/api/__generated__/models/libraryAgent";
import { LibraryAgentPreset } from "@/app/api/__generated__/models/libraryAgentPreset";
@@ -14,7 +13,7 @@ import { useToast } from "@/components/molecules/Toast/use-toast";
import { isEmpty } from "@/lib/utils";
import { analytics } from "@/services/analytics";
import { useQueryClient } from "@tanstack/react-query";
-import { useCallback, useMemo, useState } from "react";
+import { useCallback, useEffect, useMemo, useState } from "react";
import { showExecutionErrorToast } from "./errorHelpers";
export type RunVariant =
@@ -25,8 +24,9 @@ export type RunVariant =
interface UseAgentRunModalCallbacks {
onRun?: (execution: GraphExecutionMeta) => void;
- onCreateSchedule?: (schedule: GraphExecutionJobInfo) => void;
onSetupTrigger?: (preset: LibraryAgentPreset) => void;
+ initialInputValues?: Record;
+ initialInputCredentials?: Record;
}
export function useAgentRunModal(
@@ -36,18 +36,28 @@ export function useAgentRunModal(
const { toast } = useToast();
const queryClient = useQueryClient();
const [isOpen, setIsOpen] = useState(false);
- const [inputValues, setInputValues] = useState>({});
+ const [inputValues, setInputValues] = useState>(
+ callbacks?.initialInputValues || {},
+ );
const [inputCredentials, setInputCredentials] = useState>(
- {},
+ callbacks?.initialInputCredentials || {},
);
const [presetName, setPresetName] = useState("");
const [presetDescription, setPresetDescription] = useState("");
// Determine the default run type based on agent capabilities
- const defaultRunType: RunVariant = agent.has_external_trigger
- ? "automatic-trigger"
+ const defaultRunType: RunVariant = agent.trigger_setup_info
+ ? agent.trigger_setup_info.credentials_input_name
+ ? "automatic-trigger"
+ : "manual-trigger"
: "manual";
+ // Update input values/credentials if template is selected/unselected
+ useEffect(() => {
+ setInputValues(callbacks?.initialInputValues || {});
+ setInputCredentials(callbacks?.initialInputCredentials || {});
+ }, [callbacks?.initialInputValues, callbacks?.initialInputCredentials]);
+
// API mutations
const executeGraphMutation = usePostV1ExecuteGraphAgent({
mutation: {
@@ -105,11 +115,13 @@ export function useAgentRunModal(
},
});
- // Input schema validation
- const agentInputSchema = useMemo(
- () => agent.input_schema || { properties: {}, required: [] },
- [agent.input_schema],
- );
+ // Input schema validation (use trigger schema for triggered agents)
+ const agentInputSchema = useMemo(() => {
+ if (agent.trigger_setup_info?.config_schema) {
+ return agent.trigger_setup_info.config_schema;
+ }
+ return agent.input_schema || { properties: {}, required: [] };
+ }, [agent.input_schema, agent.trigger_setup_info]);
const agentInputFields = useMemo(() => {
if (
@@ -205,7 +217,10 @@ export function useAgentRunModal(
return;
}
- if (defaultRunType === "automatic-trigger") {
+ if (
+ defaultRunType === "automatic-trigger" ||
+ defaultRunType === "manual-trigger"
+ ) {
// Setup trigger
if (!presetName.trim()) {
toast({
@@ -262,7 +277,7 @@ export function useAgentRunModal(
setIsOpen,
// Run mode
- defaultRunType,
+ defaultRunType: defaultRunType as RunVariant,
// Form: regular inputs
inputValues,
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/other/EmptyTasks.tsx b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/other/EmptyTasks.tsx
index 62a75e4993..26bfbde882 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/other/EmptyTasks.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/other/EmptyTasks.tsx
@@ -2,6 +2,7 @@
import { getV1GetGraphVersion } from "@/app/api/__generated__/endpoints/graphs/graphs";
import { LibraryAgent } from "@/app/api/__generated__/models/libraryAgent";
+import { LibraryAgentPreset } from "@/app/api/__generated__/models/libraryAgentPreset";
import { Button } from "@/components/atoms/Button/Button";
import { Text } from "@/components/atoms/Text/Text";
import { ShowMoreText } from "@/components/molecules/ShowMoreText/ShowMoreText";
@@ -15,9 +16,10 @@ import { EmptyTasksIllustration } from "./EmptyTasksIllustration";
type Props = {
agent: LibraryAgent;
+ onTriggerSetup?: (preset: LibraryAgentPreset) => void;
};
-export function EmptyTasks({ agent }: Props) {
+export function EmptyTasks({ agent, onTriggerSetup }: Props) {
const { toast } = useToast();
async function handleExport() {
@@ -75,7 +77,7 @@ export function EmptyTasks({ agent }: Props) {
}
agent={agent}
- agentId={agent.id.toString()}
+ onTriggerSetup={onTriggerSetup}
/>