diff --git a/ui/web/src/i18n/locales/en/cron.json b/ui/web/src/i18n/locales/en/cron.json index 62f30a73..1951e88c 100644 --- a/ui/web/src/i18n/locales/en/cron.json +++ b/ui/web/src/i18n/locales/en/cron.json @@ -43,7 +43,8 @@ "messagePlaceholder": "What should the agent do?", "cancel": "Cancel", "create": "Create", - "creating": "Creating..." + "creating": "Creating...", + "payloadType": "Payload type" }, "enable": { "title": "Enable Cron Job", diff --git a/ui/web/src/i18n/locales/ko/cron.json b/ui/web/src/i18n/locales/ko/cron.json index 3fe81362..a9a02d36 100644 --- a/ui/web/src/i18n/locales/ko/cron.json +++ b/ui/web/src/i18n/locales/ko/cron.json @@ -43,7 +43,8 @@ "messagePlaceholder": "에이전트가 무엇을 해야 하나요?", "cancel": "취소", "create": "만들기", - "creating": "만드는 중..." + "creating": "만드는 중...", + "payloadType": "Payload 유형" }, "enable": { "title": "Cron 작업 활성화", diff --git a/ui/web/src/i18n/locales/vi/cron.json b/ui/web/src/i18n/locales/vi/cron.json index 44aadbac..189d7273 100644 --- a/ui/web/src/i18n/locales/vi/cron.json +++ b/ui/web/src/i18n/locales/vi/cron.json @@ -43,7 +43,8 @@ "messagePlaceholder": "Agent cần làm gì?", "cancel": "Hủy", "create": "Tạo", - "creating": "Đang tạo..." + "creating": "Đang tạo...", + "payloadType": "Loại payload" }, "enable": { "title": "Bật tác vụ định kỳ", diff --git a/ui/web/src/i18n/locales/zh/cron.json b/ui/web/src/i18n/locales/zh/cron.json index f00d3fb0..c69d9e84 100644 --- a/ui/web/src/i18n/locales/zh/cron.json +++ b/ui/web/src/i18n/locales/zh/cron.json @@ -43,7 +43,8 @@ "messagePlaceholder": "Agent应该做什么?", "cancel": "取消", "create": "创建", - "creating": "创建中..." + "creating": "创建中...", + "payloadType": "Payload 类型" }, "enable": { "title": "启用定时任务", diff --git a/ui/web/src/pages/cron/cron-form-dialog.tsx b/ui/web/src/pages/cron/cron-form-dialog.tsx index f017d0f5..25f2779d 100644 --- a/ui/web/src/pages/cron/cron-form-dialog.tsx +++ b/ui/web/src/pages/cron/cron-form-dialog.tsx @@ -13,7 +13,7 @@ import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Textarea } from "@/components/ui/textarea"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; -import type { CronSchedule } from "./hooks/use-cron"; +import type { CronCommandSpec, CronSchedule } from "./hooks/use-cron"; import { slugify } from "@/lib/slug"; import { useAgents } from "@/pages/agents/hooks/use-agents"; import { cronCreateSchema, type CronCreateFormData } from "@/schemas/cron.schema"; @@ -24,7 +24,8 @@ interface CronFormDialogProps { onSubmit: (data: { name: string; schedule: CronSchedule; - message: string; + message?: string; + command?: CronCommandSpec; agentId?: string; }) => Promise; } @@ -38,7 +39,9 @@ export function CronFormDialog({ open, onOpenChange, onSubmit }: CronFormDialogP mode: "onChange", defaultValues: { name: "", + payloadKind: "agent_turn", message: "", + commandJson: JSON.stringify({ argv: ["sh", "-c", "echo hello"] }, null, 2), agentId: "", scheduleKind: "every", everyValue: "60", @@ -47,6 +50,7 @@ export function CronFormDialog({ open, onOpenChange, onSubmit }: CronFormDialogP }); const scheduleKind = watch("scheduleKind"); + const payloadKind = watch("payloadKind"); const onFormSubmit = async (data: CronCreateFormData) => { let schedule: CronSchedule; @@ -58,10 +62,15 @@ export function CronFormDialog({ open, onOpenChange, onSubmit }: CronFormDialogP schedule = { kind: "at", atMs: Date.now() + 60000 }; } + const command = data.payloadKind === "command" + ? JSON.parse(data.commandJson || "{}") as CronCommandSpec + : undefined; + await onSubmit({ name: data.name, schedule, - message: data.message, + message: data.payloadKind === "agent_turn" ? data.message : undefined, + command, agentId: data.agentId || undefined, }); onOpenChange(false); @@ -115,6 +124,24 @@ export function CronFormDialog({ open, onOpenChange, onSubmit }: CronFormDialogP /> + +
+ +
+ {(["agent_turn", "command"] as const).map((kind) => ( + + ))} +
+
+
@@ -160,17 +187,33 @@ export function CronFormDialog({ open, onOpenChange, onSubmit }: CronFormDialogP

)} -
- -