Overview
Thehcom relay command enables cross-device synchronization of agents, messages, and events via MQTT. Share agent state across machines, laptops, servers, and cloud instances.
Quick Start
Device 1 (Create Relay Group)
Device 2 (Join Relay Group)
Relay Status
connected- MQTT active, syncingerror (reason)- Connection failedwaiting (daemon may not be running)- Daemon not starteddisabled- Sync disablednot configured- No relay setup
Create Relay Group
Public Brokers (default)
- broker.emqx.io:8883
- broker.hivemq.com:8883
- test.mosquitto.org:8883
Private Broker
mqtts://host:port- TLS encrypted (recommended)mqtt://host:port- Unencrypted (local only)
Connect to Relay
Join with Token
Re-enable Existing Relay
Disable Relay
- Stops syncing events
- Clears retained MQTT state
- Remote devices stop seeing your agents
- Config preserved (can re-enable with
relay connect)
Relay Daemon
Manage the background relay worker process.Show Daemon Status
Start Daemon
- Starts background worker
- Connects to MQTT broker
- Begins syncing events
Stop Daemon
- Graceful shutdown
- SIGKILL after 5s if hung
- Cleans up PID file
Restart Daemon
- Apply config changes
- Recover from errors
- Update daemon code
What Gets Synced
Events
- Messages between agents
- Status changes (active/listening/blocked)
- File edits (with collision detection)
- Command executions
- Lifecycle events (created/stopped)
Agents
- Agent registration (name, tool, status)
- Tags and display names
- Session state (not transcripts)
- Last heartbeat timestamps
NOT Synced
- Transcripts (privacy)
- Files (only paths tracked)
- Config settings
- Hooks
Remote Devices
View and interact with agents on other devices.List Remote Agents
:DEVICE_ID
Send Messages Cross-Device
Query Remote Events
Device IDs
Each device gets a 4-character short ID (FNV-1a hash of UUID).View Your Device ID
Auto-generated
- UUID stored in
~/.hcom/.tmp/device_id - Short ID displayed in relay status
- Used in remote agent names:
agent:DEVICE_ID
Token Format
Relay tokens encode:- Relay group UUID
- MQTT broker URL (or index for public brokers)
- Base64-encoded JSON
- Shareable (no secrets)
- Broker URL can be overridden with
--broker - Authentication via separate
--passwordflag
Broker Selection
Public Brokers
Free, no setup required:- broker.emqx.io:8883
- broker.hivemq.com:8883
- test.mosquitto.org:8883
- No configuration
- Automatic selection
- TLS encrypted
- Shared infrastructure
- Rate limits
- Less control
Private Brokers
Self-hosted or managed:- Full control
- Better performance
- Custom authentication
- No rate limits
- Requires setup
- Must be accessible from all devices
- Mosquitto (self-hosted)
- HiveMQ Cloud (managed)
- EMQX Cloud (managed)
Troubleshooting
Broker Unreachable
- Check network connectivity
- Try different broker:
hcom relay new - Use private broker with known availability
Authentication Errors
- Private broker requires password:
--password <secret> - Verify password matches across devices
- Check broker auth configuration
Daemon Not Running
Events Not Syncing
Check queue:- Daemon not running:
hcom relay daemon start - Network issues: check broker connectivity
- Restart daemon:
hcom relay daemon restart
Remote Agents Not Visible
Check device list:- Other devices may be offline
- Relay may be disabled on other devices
- Different relay groups (verify token)
- Verify all devices connected:
hcom relay status - Check timestamps: devices >90s stale are hidden
- Restart daemon:
hcom relay daemon restart
Security
TLS Encryption
All public brokers usemqtts:// (TLS encrypted).
Verify:
mqtts:// prefix
Relay Group UUID
- Unique per group
- Acts as namespace
- Prevents cross-group contamination
Authentication
Optional for private brokers:Data Privacy
- Transcripts NOT synced
- File contents NOT synced (only paths)
- Message content synced (use private broker for sensitive data)
Examples
Laptop + Cloud Server
Laptop:Multi-device Development
Desktop (main):Team Coordination
Team lead:Configuration
Relay settings stored in~/.hcom/config.toml:
Tips
- Use public brokers for quick setup
- Private brokers for production/team use
- Enable daemon on all devices for auto-sync
- Use device IDs to target specific machines
- Check relay status regularly
- Restart daemon after config changes
- Disable relay on battery-sensitive devices
See Also
- hcom list - View remote agents
- hcom send - Message remote agents
- hcom config - Relay settings
- hcom status - Verify relay connectivity