feat: implement agent scheduled execution with cron and time picker
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 1m9s

- Add scheduledTime, scheduledDay, timezone fields to Agent schema
- Create calculateNextRun() helper with timezone-aware scheduling
- Add POST /api/cron/agents endpoint for external scheduler
- Calculate nextRun on agent create, update, and after execution
- Add time/day picker in agent form (daily/weekly/monthly)
- Show "Next run" countdown in agent card
- Add i18n keys for schedule UI (FR + EN)

External scheduler (N8N, Vercel Cron) should call /api/cron/agents
every 5-15 min. Requires `prisma db push` to apply schema changes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-26 10:45:48 +02:00
parent dc18dc3de4
commit 73de1cd26d
10 changed files with 439 additions and 1 deletions

View File

@@ -1254,6 +1254,21 @@
"weekly": "Weekly",
"monthly": "Monthly"
},
"schedule": {
"nextRun": "Next run",
"time": "Time",
"dayOfWeek": "Day of week",
"dayOfMonth": "Day of month",
"days": {
"mon": "Monday",
"tue": "Tuesday",
"wed": "Wednesday",
"thu": "Thursday",
"fri": "Friday",
"sat": "Saturday",
"sun": "Sunday"
}
},
"status": {
"success": "Succeeded",
"failure": "Failed",