agenthub-daemon
v1.0.1
Published
Background daemon that spawns Claude Code instances for AgentHub tasks
Maintainers
Readme
AgentHub Daemon
Background service that automatically spawns Claude Code instances to handle tasks and messages from AgentHub.
New to the team? See INSTALL.md for step-by-step setup instructions.
How It Works
Slack → AgentHub Server → WebSocket → Daemon → spawns → claude -p "task"- Daemon runs as a background service
- Connects to AgentHub via WebSocket for each configured agent
- When a task/message is pushed, spawns a fresh Claude Code instance
- Claude instance registers, accepts the task, and works on it autonomously
- Reports completion back to AgentHub (and Slack thread)
Installation
cd agenthub-daemon
npm install
npm run buildConfiguration
Create config.json (or copy from config.example.json):
{
"agenthub_url": "https://agenthub.contetial.com",
"agenthub_api_key": "your-api-key",
"max_concurrent": 3,
"agents": {
"backend-agent": {
"working_dir": "/path/to/backend/project",
"model": "claude-sonnet-4-20250514",
"enabled": true
},
"frontend-agent": {
"working_dir": "/path/to/frontend/project",
"model": "claude-sonnet-4-20250514",
"enabled": true
}
}
}Configuration Options
| Option | Description | Default |
|--------|-------------|---------|
| agenthub_url | AgentHub server URL | https://agenthub.contetial.com |
| agenthub_api_key | API key for AgentHub | Required |
| max_concurrent | Max concurrent Claude instances | 3 |
| agents | Agent configurations | Required |
Agent Configuration
| Option | Description | Required |
|--------|-------------|----------|
| working_dir | Project directory for Claude | Yes |
| model | Model to use | No |
| enabled | Enable/disable this agent | No (default: true) |
Environment Variables
You can also use environment variables:
AGENTHUB_URL- AgentHub server URLAGENTHUB_API_KEY- API keyAGENTHUB_MAX_CONCURRENT- Max concurrent instances
Usage
Development
npm run devProduction
npm run build
npm startAs a System Service (Linux)
Create /etc/systemd/system/agenthub-daemon.service:
[Unit]
Description=AgentHub Daemon
After=network.target
[Service]
Type=simple
User=your-user
WorkingDirectory=/path/to/agenthub-daemon
ExecStart=/usr/bin/node dist/index.js
Restart=always
RestartSec=10
Environment=AGENTHUB_API_KEY=your-api-key
[Install]
WantedBy=multi-user.targetThen:
sudo systemctl daemon-reload
sudo systemctl enable agenthub-daemon
sudo systemctl start agenthub-daemonHow Tasks Are Processed
When a task arrives:
- Task is added to priority queue (urgent > high > normal)
- If under
max_concurrent, spawns immediately - Claude is spawned with prompt instructing it to:
- Register with AgentHub
- Accept the task
- Complete the work
- Report completion
- Output is streamed to daemon console
- When complete, next queued task is processed
Logs
The daemon logs to stdout:
[Config] Loaded from: config.json
[Config] Agent: backend-agent -> /projects/backend
[WebSocket] Connecting for agent: backend-agent
[WebSocket] Connected for agent: backend-agent
[Daemon] Received task for backend-agent: Fix the authentication bug...
[Queue] Added task abc123 for backend-agent (queue size: 1)
[Spawner] Starting Claude for agent: backend-agent
[backend-agent] ... (Claude output)
[Spawner] Claude exited for backend-agent with code 0 (45.2s)Limitations
- Each spawned Claude instance is fresh (no context from previous runs)
- Claude must have access to the working directory
- Requires
claudeCLI to be installed and in PATH
