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

@@ -275,6 +275,9 @@ model Agent {
frequency String @default("manual") // manual, hourly, daily, weekly, monthly
lastRun DateTime?
nextRun DateTime?
scheduledTime String? @default("08:00") // HH:mm in user's local time
scheduledDay Int? // 0-6 for weekly (Mon=0), 1-31 for monthly
timezone String? // IANA timezone, e.g. "Europe/Paris"
isEnabled Boolean @default(true)
targetNotebookId String?
sourceNotebookId String? // For monitor type: notebook to watch