LiveKit Service Integration Design
Overview
This document outlines the design for integrating LiveKit as a managed service in Voice Mode, similar to how Whisper and Kokoro are currently managed.
Architecture Overview
Voice Mode
├── CLI Commands
│ ├── voice-mode livekit install
│ ├── voice-mode livekit start/stop/status
│ └── voice-mode livekit uninstall
├── MCP Tools
│ ├── install_livekit()
│ ├── Extended service() tool
│ └── livekit_status()
└── Service Management
├── systemd/launchd templates
├── Health checks
└── Auto-discovery
Installation Strategy
Binary Installation
- macOS: Use
brew install livekit(already available) - Linux: Use official install script:
curl -sSL https://get.livekit.io | bash - Fallback: Direct binary download from GitHub releases
Service Location
- Install to:
~/.voicemode/services/livekit/ - Binary:
~/.voicemode/services/livekit/livekit-server - Config:
~/.voicemode/services/livekit/livekit.yaml - Logs:
~/.voicemode/logs/livekit/
Configuration
Dev Mode (Default)
# ~/.voicemode/services/livekit/livekit.yaml
port: 7880
rtc:
port_range_start: 50000
port_range_end: 60000
use_external_ip: false
keys:
devkey: secret
log_level: info
Environment Variables
LIVEKIT_URL=ws://localhost:7880
LIVEKIT_API_KEY=devkey
LIVEKIT_API_SECRET=secret
Service Templates
systemd Template
[Unit]
Description=Voice Mode LiveKit Server
After=network.target
[Service]
Type=simple
ExecStart={LIVEKIT_BIN} --config {CONFIG_FILE} --dev
WorkingDirectory={WORKING_DIR}
ExecStartPost=/bin/sh -c 'while ! curl -sf http://127.0.0.1:{LIVEKIT_PORT}/health >/dev/null 2>&1; do echo "Waiting for LiveKit..."; sleep 1; done'
Restart=on-failure
RestartSec=10
[Install]
WantedBy=default.target
launchd Template
<dict>
<key>Label</key>
<string>com.voicemode.livekit</string>
<key>ProgramArguments</key>
<array>
<string>{LIVEKIT_BIN}</string>
<string>--config</string>
<string>{CONFIG_FILE}</string>
<string>--dev</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
Implementation Plan
Phase 1: Core Installation
Create
voice_mode/tools/services/livekit/install.py- Platform detection (macOS/Linux)
- Binary installation (brew/curl/direct download)
- Service file generation
- Config file creation
Create
voice_mode/tools/services/livekit/uninstall.py- Service removal
- Binary cleanup
- Config cleanup
Phase 2: Service Management
Extend
voice_mode/tools/service.py- Add LiveKit support
- Health check integration
- Status reporting
Create service templates
voice_mode/templates/systemd/voicemode-livekit.servicevoice_mode/templates/launchd/com.voicemode.livekit.plist
Phase 3: CLI Integration
- Add to
voice_mode/cli.py- Create
@voice_mode_main_cli.group()for livekit - Add all subcommands (install, start, stop, etc.)
- Create
Phase 4: MCP Tools
- Create/update MCP tools
install_livekittool- Update existing
servicetool - Add
livekit_statustool
Phase 5: Web Interface
- Update web interface in
docs/web/- Auto-detect local LiveKit server
- Connection configuration
- Fallback to cloud
Health Checks
LiveKit exposes health endpoints:
/health- Basic health check/- Returns LiveKit version info
Auto-Discovery
Add to provider discovery:
- Check port 7880 for LiveKit server
- Verify with health endpoint
- Add to provider registry
Testing Strategy
Installation Testing
- Test on macOS (brew)
- Test on Linux (curl script)
- Test fallback binary download
Service Testing
- Start/stop/restart
- Auto-start on boot
- Log rotation
Integration Testing
- Web interface connection
- Token generation
- Room creation
Migration from Previous Work
From the voice-mcp.tgz analysis:
- Reuse livekit-admin-mcp concepts for room management
- Adapt web interface from livekit/voice-assistant-frontend
- Use existing LiveKit documentation structure
Success Metrics
- One-command installation:
voice-mode livekit install - Service management parity with Whisper/Kokoro
- Web interface works locally
- TailScale remote access functional
- Graceful fallback to cloud LiveKit
Open Questions
- Should we bundle the web interface or serve from docs/web/?
- How to handle TURN server configuration for NAT traversal?
- Should we auto-install during first
converseif not present?
Next Steps
- Start with install.py implementation
- Test on both macOS and Linux
- Create service templates
- Integrate with CLI
- Update documentation