Command and Control center for distributed AI agent orchestration. Manages heterogeneous hardware clusters, syncs Ollama configurations, and intelligently routes AI inference tasks based on real-time resource availability.
To get TaskMaster running on your local machine or server, use the interactive setup script. This script automatically handles Python virtual environments, Node.js packages, and .env generation.
- Clone the repository:
git clone https://github.com/YOUR_ORG/TaskMaster.git cd TaskMaster - Run the interactive setup installer:
During setup, the script will automatically generate a secure 32-character
# On Windows setup_installer.batAPI_KEYfor you and prompt you to wire up Cloudflared. - Launch the development environment:
This starts the FastAPI backend (port 8000) and the React frontend (port 5173) simultaneously.
run_dev.bat
If you are deploying TaskMaster to production via Docker, you likely want to securely expose the dashboard and API to the internet so remote agents can connect. We use Cloudflare Zero Trust Tunnels to achieve this without exposing your server's IP.
- Go to your Cloudflare Zero Trust Dashboard -> Networks -> Tunnels.
- Click Create a tunnel (Select Cloudflared). Name it
TaskMaster. - In the Public Hostname Page, create two routes:
dashboard.example.com->HTTP://nginx:80api.example.com->HTTP://taskmaster_api:8000
- Copy your unique Tunnel Token.
- When running
setup_installer.bat, answer Y when asked if you want to configure a Cloudflare Tunnel, and paste your token. - Run
docker compose up -d --build. Your tunnel is now active!
TaskMaster features a modern, responsive React dashboard that gives you full visibility into your AI cluster:
- Live Agent Registry: View all connected worker nodes. See their OS, uptime, and available AI skills.
- Hardware Telemetry: Real-time graphs showing CPU utilization, RAM usage, and GPU VRAM availability across your entire fleet.
- Task Queue Monitoring: Watch tasks as they flow through the system. See which tasks are queued, which are actively processing, and exactly which agent claimed them.
- Model Synchronization: Ensure all your agents have the correct local Ollama models installed remotely.
TaskMaster's core innovation is its intelligent routing engine. It acts as the brain of your distributed AI cluster, ensuring tasks are sent to the hardware best equipped to handle them.
- Submission: A user or external application sends a REST
POSTrequest to TaskMaster containing the prompt, preferred model (e.g.,llama3), and required skills (e.g.,basic_chat). - Filtering (Matching): TaskMaster instantly filters the live registry of connected agents, discarding any nodes that are offline, lack the required skills, or don't have the requested model installed.
- Scoring: The remaining eligible agents are scored based on real-time hardware telemetry:
- GPU VRAM Available (Highest Weight)
- CPU Load (Low load preferred)
- System RAM Available
- Execution: The highest-scoring agent is assigned the task via a persistent WebSocket connection. The agent queries its local Ollama instance and processes the inference.
- Return: The agent sends the final generated text back to TaskMaster, which instantly relays the result back to the original requester.
User ββ(POST /api/task/submit)βββΊ TaskMaster
β (Scores agents)
βΌ
Agent A (Offline) Agent B (No VRAM) Agent C (Idle RTX 4090)
β
(Runs inference via Ollama)
β
User βββ(Relays final result)ββββββ TaskMaster βββ(POST /api/task/result)
All endpoints except / and /api/status require the X-API-Key header.
| Method | Path | Description |
|---|---|---|
GET |
/ |
Health check β confirms API is running |
GET |
/api/status |
Cluster status (agent counts, total RAM, GPU count, queue depth) |
| Method | Path | Description |
|---|---|---|
POST |
/api/heartbeat |
Agent sends hardware metrics (every 5s) |
POST |
/api/config/sync?agent_id=<id> |
Agent pulls its Ollama configuration |
POST |
/api/task/result |
Agent reports completed task results |
| Method | Path | Description |
|---|---|---|
GET |
/api/agents |
List all registered agents with status |
POST |
/api/task/submit |
Submit a task for intelligent routing |
GET |
/api/task/history |
Last 200 task events |
WS |
/ws/dashboard?key=<api_key> |
Real-time WebSocket feed |
curl -X POST http://localhost/api/task/submit \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"task_id": "task-001",
"template": "chat",
"parameters": {"prompt": "Explain quantum computing"},
"required_skills": ["basic_chat"],
"requires_gpu": false,
"preferred_model": "llama3"
}'curl -X POST http://localhost/api/heartbeat \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"agent_id": "workstation-01",
"os_info": "Windows 10",
"hardware": {
"cpu_percent": 15.2,
"ram_total_mb": 32768,
"ram_used_mb": 12500,
"disk_total_mb": 512000,
"disk_free_mb": 350000,
"gpu_available": true,
"gpu_details": [{
"id": 0, "name": "RTX 4070",
"load": 5.0, "memoryTotal": 12288,
"memoryUsed": 1024, "memoryFree": 11264,
"temperature": 42
}]
},
"skills": ["basic_chat", "summarize"],
"models": ["llama3:latest", "mistral:latest"]
}'Connect to /ws/dashboard?key=YOUR_API_KEY to receive real-time updates:
// Initial state snapshot (sent on connect)
{
"type": "initial_state",
"agents": { ... },
"system_status": { ... },
"task_history": [ ... ]
}
// Agent heartbeat update (sent every 5s per agent)
{
"type": "agent_update",
"agents": { ... },
"system_status": { ... }
}
// Task lifecycle event
{
"type": "task_event",
"task_id": "task-001",
"agent_id": "workstation-01",
"status": "routed"
}| Variable | Default | Description |
|---|---|---|
API_KEY |
changeme-taskmaster-secret |
Shared authentication key for all API requests |
HOST |
0.0.0.0 |
Backend bind address |
PORT |
8000 |
Backend bind port |
CORS_ORIGINS |
http://localhost:5173,... |
Allowed frontend origins (comma-separated) |
AGENT_TIMEOUT_SECONDS |
30 |
Seconds before an agent is marked offline |
CLOUDFLARE_TUNNEL_TOKEN |
(empty) | Cloudflare tunnel token for external access |
| Variable | Default | Description |
|---|---|---|
TASKMASTER_URL |
http://127.0.0.1:8000 |
URL of the TaskMaster API server |
AGENT_ID |
(hostname) | Unique identifier for this agent |
API_KEY |
changeme-taskmaster-secret |
Must match the server's API_KEY |
AGENT_SKILLS |
basic_chat |
Comma-separated skill tags |
HEARTBEAT_INTERVAL |
5 |
Seconds between heartbeats |
OLLAMA_URL |
http://127.0.0.1:11434 |
Local Ollama API endpoint |
CALLBACK_PORT |
9000 |
Port for receiving task callbacks |
| Variable | Default | Description |
|---|---|---|
VITE_API_URL |
(empty) | Backend API URL (empty = use dev proxy) |
VITE_WS_URL |
(empty) | WebSocket URL (empty = auto-detect) |
VITE_API_KEY |
changeme-taskmaster-secret |
Dashboard API key |
# Auto-commit and push with timestamp
python git_sync.py
# Custom commit message
python git_sync.py "Added GPU scheduling improvements"Authentication uses Windows Credential Manager (pre-configured via git config credential.helper manager).
TaskMaster/
βββ backend/ # FastAPI API server
β βββ main.py # Application entry point & routes
β βββ models.py # Pydantic data schemas
β βββ router.py # Agent registry & task routing engine
β βββ config.py # Settings loaded from .env
β βββ websocket_manager.py # Real-time WebSocket connection manager
β βββ cert_manager.py # mTLS certificate generation
β βββ requirements.txt # Python dependencies
β βββ Dockerfile # Backend container image
β βββ .env.example # Environment variable template
βββ frontend/ # React (Vite) dashboard
β βββ src/
β β βββ App.jsx # Main dashboard component
β β βββ index.css # Design system & styles
β β βββ main.jsx # React entry point
β βββ Dockerfile # Multi-stage build β nginx
β βββ package.json # Node dependencies
β βββ .env.example # Frontend env template
βββ agent/ # Deployable agent for worker nodes
β βββ agent.py # Core heartbeat & task loop
β βββ hardware_monitor.py # CPU/RAM/GPU/Disk telemetry
β βββ ollama_manager.py # Local Ollama API interface
β βββ requirements.txt # Python dependencies
β βββ setup_installer.bat # Windows setup script
β βββ setup_installer.sh # Linux setup script + systemd
βββ nginx/ # Reverse proxy configuration
β βββ nginx.conf # API proxy + WebSocket + static files
βββ cloudflared/ # Cloudflare tunnel config
β βββ config.yml # Tunnel routing rules
βββ docker-compose.yml # Production container orchestration
βββ .env.example # Root environment template
βββ .gitignore # Version control exclusions
βββ build.bat # Windows build script
βββ run_dev.bat # Windows development launcher
βββ git_sync.py # Automated GitHub push utility
βββ todo.txt # Project progress tracker
βββ README.md # This file
TaskMaster exposes a standard REST API. To integrate from any language:
import requests
TASKMASTER_URL = "http://your-server:80"
API_KEY = "your-api-key"
HEADERS = {"X-API-Key": API_KEY, "Content-Type": "application/json"}
# Check cluster health
status = requests.get(f"{TASKMASTER_URL}/api/status").json()
print(f"Online agents: {status['online_agents']}, GPUs: {status['total_gpu_count']}")
# Submit an inference task
task = {
"task_id": "my-app-001",
"template": "chat",
"parameters": {"prompt": "Translate 'hello' to French"},
"required_skills": ["basic_chat"],
"preferred_model": "llama3"
}
result = requests.post(f"{TASKMASTER_URL}/api/task/submit", json=task, headers=HEADERS).json()
print(f"Task routed to: {result.get('agent_id', 'queued')}")When an agent completes a task, it POSTs the result back to /api/task/result. You can poll /api/task/history to check for completion, or connect via the WebSocket to receive real-time task_event messages.
Licensed under the MIT License. See LICENSE for more information.