# TaskPulse β AI Agent Scheduled Task Monitor
> **Let your AI agents self-report. You just glance at the dashboard.**
TaskPulse is a tracking and monitoring platform designed for AI agents' scheduled tasks. Unlike traditional CRUD-heavy admin panels, TaskPulse is **AI-native**: give your agents an API spec, and they autonomously register themselves, report execution results, and update their status β no manual form-filling required.
[π δΈζζζ‘£](./README.md)
---
## Philosophy
```
βββββββββββββββββββββββ
β TaskPulse Dashboardβ
β Unified Status Viewβ
ββββββββ¬βββββββββββ¬ββββ
β β
βββββββββββββββββββ βββββββββββββββββββ
βΌ βΌ
βββββββββββββββββββ ββββββββββββββββββββββββ
β AI Agent A β register tasks β execute β AI Agent B β
β ββ data sync β β report result + log β ββ order fetch β
β ββ report gen β β ββ inventory sync β
βββββββββββββββββββ ββββββββββββββββββββββββ
```
**AI-Native by Design**
Traditional schedulers require humans to fill forms and manage cron expressions. But AI agents can read API docs and act autonomously:
1. **Self-Register** β One API call to register both the agent and all its tasks
2. **Report Results** β After each execution, POST back the result with logs and duration
3. **Auto-Alert** β If a task misses its window, the system alerts automatically
The only thing humans need to do: **open the dashboard and see the big picture.**
---
## Features
### π€ AI-Native Onboarding
- **Batch Registration**: `POST /api/agents/register-with-tasks` β agent + tasks in one shot
- **API Key Auth**: Each agent gets its own key for reporting
- **Re-registration**: Deleted agents can re-register anytime
- **Agent Avatars**: First-letter + deterministic color avatars for quick visual identification
### π Unified Dashboard
- **Summary Cards**: agent count, task count, 24h executions, pending alerts
- **Global Task View**: all tasks from all agents in one place
- **Task Tags**: label tasks (e.g. "data-sync", "critical"), filter by tags
- **Human-Readable Cron**: `*/5 * * * *` β "Every 5 minutes"
- **Localized Time**: all timestamps auto-converted from UTC to browser timezone
### β± Execution Tracking
- **Live Reporting**: agents POST results immediately after execution
- **Execution History**: full timeline per task, paginated
- **Log Viewer**: dark terminal-style viewer for debugging
- **Search & Filter**: by task name, tags, and status
### π¨ Timeout Alerts & Notifications
- **Auto-Scan**: background scheduler checks overdue tasks every 60s
- **Grace Window**: per-task tolerance to avoid false alerts
- **Multi-Channel**: Feishu (Lark) webhook, email SMTP, generic webhook
- **Alert Acknowledgment**: mark alerts as handled for closed-loop management
### π¨ Modern UI
- **Dark Theme**: gradient backgrounds + neon accents
- **Full-Width Layout**: maximizes screen usage
- **Responsive**: adapts to different screen sizes
---
## Tech Stack
| Layer | Technology |
|---|---|
| Backend | Python FastAPI (async) |
| Production Server | Gunicorn + Uvicorn Worker |
| Frontend | Vue 3 + Element Plus |
| Build Tool | Vite |
| Database | MySQL 8.0 |
| Validation | Pydantic v2 |
| ORM | SQLAlchemy 2.0 (async) |
| Auth | JWT (python-jose) + bcrypt |
| Scheduler | APScheduler (async loop) |
| Deployment | Monolithic (FastAPI serves SPA) |
---
## Quick Start
### Local Development
```bash
# 1. Clone
git clone https://github.com/oventh/TaskPulse.git
cd TaskPulse
# 2. Backend
cd backend
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env # edit .env with your DB config
uvicorn app.main:app --reload --port 8000
# 3. Frontend (new terminal)
cd frontend
npm install
npm run dev # http://localhost:3000
```
> Frontend dev server proxies `/api` to `localhost:8000`.
### Production Deployment
```bash
# 1. Build frontend
cd frontend && npm install && npm run build
# 2. Deploy to server
rsync -avz --exclude='.venv' --exclude='node_modules' --exclude='.git' \
./ user@server:/home/app/taskpulse/
# 3. Install deps + start with Gunicorn
cd /home/app/taskpulse/backend
python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
.venv/bin/gunicorn app.main:app \
-k uvicorn.workers.UvicornWorker \
-b 0.0.0.0:8000 -w 2 --preload --daemon
```
---
## Agent Integration
Let your AI agent self-register in 3 steps:
```python
import requests
BASE = "https://your-domain.com"
# 1. Register agent + all its tasks (one API call)
resp = requests.post(f"{BASE}/api/agents/register-with-tasks", json={
"name": "my-agent",
"description": "My AI Agent",
"tasks": [
{"name": "sync-data", "cron_expression": "*/5 * * * *"},
{"name": "daily-report", "cron_expression": "0 9 * * *"}
]
})
data = resp.json()
API_KEY = data["agent"]["api_key"] # β save this
AGENT_ID = data["agent"]["id"]
# 2. Report execution result after each run
requests.post(f"{BASE}/api/tasks/{TASK_ID}/executions",
headers={"Authorization": f"Bearer {API_KEY}"},
json={"status": "success", "duration_ms": 1500, "log": "Task completed"})
```
> For curl, batch registration, and more examples, see the Chinese doc [AGENT_GUIDE.md](./AGENT_GUIDE.md).
---
## Configuration
| Variable | Default | Description |
|----------|---------|-------------|
| `TASKPULSE_DB_HOST` | localhost | MySQL host |
| `TASKPULSE_DB_PORT` | 3306 | MySQL port |
| `TASKPULSE_DB_USER` | dbuser | Database user |
| `TASKPULSE_DB_PASSWORD` | - | Database password |
| `TASKPULSE_DB_NAME` | taskpulse | Database name |
| `TASKPULSE_DEBUG` | true | Debug mode (false in production) |
| `TASKPULSE_SECRET_KEY` | - | JWT signing key |
| `TASKPULSE_SMTP_*` | - | Email notification config |
See `backend/.env.example` for the full list.
---
## API Overview
### Agents
| Method | Path | Description |
|--------|------|-------------|
| POST | `/api/agents` | Register an agent (returns API Key) |
| **POST** | **`/api/agents/register-with-tasks`** | **π Batch register agent + tasks** |
| GET | `/api/agents` | List all agents |
| PUT | `/api/agents/{id}` | Update agent name/description |
| DELETE | `/api/agents/{id}` | Delete agent (cascades to tasks) |
### Tasks
| Method | Path | Description |
|--------|------|-------------|
| POST | `/api/tasks?agent_id=X` | Create a scheduled task |
| GET | `/api/tasks` | List tasks (`?q=&tags=&status=` filters) |
| PUT | `/api/tasks/{id}` | Update task name/tags/description |
| DELETE | `/api/tasks/{id}` | Delete a task |
### Execution Reporting
| Method | Path | Description |
|--------|------|-------------|
| POST | `/api/tasks/{id}/executions` | **Agent reports execution result** |
| GET | `/api/tasks/{id}/executions` | View execution history (paginated) |
| GET | `/api/tasks/{id}/executions/{eid}` | View single execution detail |
### Dashboard & Config
| Method | Path | Description |
|--------|------|-------------|
| GET | `/api/dashboard/summary` | Dashboard summary stats |
| GET | `/api/dashboard/tasks` | Dashboard full task view |
| GET | `/api/system/config` | Get system config |
| PUT | `/api/system/config` | Update system config (Base URL) |
### Alerts & Notifications
| Method | Path | Description |
|--------|------|-------------|
| GET | `/api/alerts` | List alerts |
| POST | `/api/alerts/{id}/acknowledge` | Acknowledge an alert |
| POST | `/api/notification-channels` | Add notification channel |
Full OpenAPI docs at `/docs` (Swagger UI).
---
## Project Structure
```
taskpulse/
βββ backend/
β βββ app/
β β βββ main.py # FastAPI entry + SPA static files + lifecycle
β β βββ config.py # Environment variables (pydantic-settings)
β β βββ database.py # Async MySQL connection
β β βββ models/ # SQLAlchemy models (6 tables)
β β βββ schemas/ # Pydantic request/response models
β β βββ api/ # REST API routes (7 modules)
β β βββ services/ # Business logic layer
β β βββ scheduler.py # β° Background scheduler (timeout detection)
β β βββ notification.py # π’ Feishu/Email/Webhook sender
β βββ alembic/ # DB migrations
β βββ requirements.txt
βββ frontend/
β βββ src/
β β βββ views/ # 6 pages (dark theme)
β β βββ router/ # Route guards + login redirect
β β βββ api/ # Axios client + 401 interceptor
β β βββ assets/ # Global styles + Element Plus overrides
β βββ package.json
βββ AGENT_GUIDE.md # Agent API guide (Chinese)
βββ README.md # Documentation (Chinese)
βββ README.en.md # Documentation (English)
```
---
## License
MIT License Β© 2026