Scheduler
Mia includes a built-in task scheduler that runs cron-based AI tasks automatically. Set up daily standups, weekly summaries, or any recurring prompt.
How It Works
Section titled “How It Works”The scheduler uses node-cron for timing and persists task definitions to ~/.mia/scheduled-tasks.json. Tasks survive daemon restarts.
┌─────────────────────┐│ scheduled-tasks ││ .json │└─────────┬───────────┘ │ load on startup ▼┌─────────────────────┐│ node-cron jobs │◄─── cron trigger└─────────┬───────────┘ │ ▼┌─────────────────────┐│ Plugin Dispatch │──► AI generates response└─────────┬───────────┘ │ ▼┌─────────────────────┐│ P2P Broadcast │──► Results sent to mobile└─────────────────────┘Managing Tasks
Section titled “Managing Tasks”Add a Task
Section titled “Add a Task”# Standup every weekday at 9ammia scheduler add "0 9 * * 1-5" "Write a standup report for recent commits"
# Weekly changelog every Friday at 5pmmia scheduler add "0 17 * * 5" "Generate a changelog for this week's changes"
# Daily code review reminder at 2pmmia scheduler add "0 14 * * *" "Check for open PRs that need review"List Tasks
Section titled “List Tasks”mia scheduler listShows all tasks with their status, last run time, and next scheduled run.
Control Tasks
Section titled “Control Tasks”mia scheduler start <id> # Enable a disabled taskmia scheduler stop <id> # Disable without deletingmia scheduler delete <id> # Permanently removemia scheduler test <id> # Run immediately (ignores schedule)Task Definition
Section titled “Task Definition”interface ScheduledTask { id: string // Unique identifier name: string // Human-readable name cronExpression: string // Cron schedule (e.g., "0 9 * * MON") task: string // Prompt to dispatch to AI enabled: boolean // Whether the task is active createdAt: number // Creation timestamp lastRun?: number // Last execution timestamp nextRun?: string // Human-readable next run time nextRunMs?: number // Next run as epoch milliseconds runCount: number // Total times executed timeoutMs?: number // Per-task timeout override consecutiveSkips?: number // Times skipped due to overlap}Overlap Prevention
Section titled “Overlap Prevention”If a task is still running when its next cron trigger fires, the new execution is skipped rather than queued. The consecutiveSkips counter tracks how often this happens — useful for identifying tasks that need longer timeouts or less frequent schedules.
Timeouts
Section titled “Timeouts”Each task has a configurable timeout:
- Default: 5 minutes (300,000ms)
- Global override:
scheduler.defaultTimeoutMsin config - Per-task: Set
timeoutMson individual tasks
If a task exceeds its timeout, the dispatch is aborted.
Mobile Integration
Section titled “Mobile Integration”Scheduled tasks are fully accessible from the mobile app:
- View all tasks with status and next run time
- Create new tasks
- Enable/disable tasks
- Delete tasks
- View task results (synced via P2P)
Cron Expression Reference
Section titled “Cron Expression Reference”| Expression | Schedule |
|---|---|
* * * * * | Every minute |
0 * * * * | Every hour |
0 9 * * * | Daily at 9am |
0 9 * * 1-5 | Weekdays at 9am |
0 9 * * MON | Every Monday at 9am |
0 */6 * * * | Every 6 hours |
0 9,17 * * * | 9am and 5pm daily |
0 0 1 * * | First of each month |