Terraphim Agent Auto-Update System
Complete guide to the auto-update functionality built into terraphim-agent CLI.
Overview
Terraphim-agent includes a sophisticated auto-update system that seamlessly keeps your installation current with the latest releases from GitHub. The system is designed to be secure, user-friendly, and reliable.
Features
- π Automatic Updates: Binary replacement without manual intervention
- π Progress Tracking: Real-time download progress with status indicators
- π Secure Verification: GitHub Releases integration ensures authenticated updates
- π Cross-Platform: Works on Linux, macOS, and Windows
- π Version Intelligence: Smart version comparison and update availability detection
- β‘ Async-Safe: Designed to work seamlessly with async Rust applications
- π‘οΈ Error Handling: Graceful degradation and detailed error reporting
Quick Start
# Check if updates are available
# Update to latest version
# Get help for update commands
Commands Reference
check-update
Checks for available updates without installing them.
Output Examples:
- β
Up-to-date:
β Already running latest version: 1.0.0 - π¦ Update Available:
π¦ Update available: 1.0.0 β 1.0.1 - β Error:
β Update failed: Network error - Connection refused
update
Checks for updates and installs them if available.
Output Examples:
- π Success:
π Updated from 1.0.0 to 1.0.1 - β
No Update:
β Already running latest version: 1.0.0 - β Error:
β Update failed: Permission denied
Technical Architecture
Update Source
- Repository:
terraphim/terraphim-ai - Platform: GitHub Releases
- Authentication: Secure GitHub API integration
Implementation Details
- Core Library:
self_updatecrate - Architecture:
tokio::task::spawn_blockingfor async compatibility - Version Comparison: Semantic versioning with intelligent parsing
- Binary Verification: GitHub release signature verification
Runtime Safety
The system uses tokio::task::spawn_blocking to isolate the potentially blocking self_update operations from the async runtime, preventing conflicts like:
Cannot drop a runtime in a context where blocking is not allowedUpdate Process
- Version Detection: Current version extracted from binary metadata
- Release Query: Query GitHub Releases API for latest version
- Version Comparison: Compare current vs latest using semantic versioning
- Download: Fetch release binary for current platform and architecture
- Verification: Validate binary integrity and GitHub release authenticity
- Installation: Replace current binary with new version
- Cleanup: Remove temporary files and update status
Status Messages
| Status | Icon | Message | Meaning |
|--------|------|---------|---------|
| Checking | π | π Checking for terraphim-agent updates... | Querying GitHub Releases |
| Up-to-date | β
| β
Already running latest version: X.Y.Z | No updates needed |
| Available | π¦ | π¦ Update available: X.Y.Z β A.B.C | Update is ready to install |
| Updated | π | π Updated from X.Y.Z to A.B.C | Successfully updated |
| Failed | β | β Update failed: [error details] | Update process failed |
Troubleshooting
Common Issues
Network Connectivity
Error: Update failed: Network error - Connection refused
Solution: Check internet connection and GitHub accessibility
Permission Denied
Error: Update failed: Permission denied
Solution: Ensure you have write permissions to the binary location
# For system-wide installation
# For user installation
Binary Not Found
Error: Failed to execute update command: No such file or directory
Solution: Verify terraphim-agent is in your PATH
GitHub Rate Limiting
Error: Update failed: API rate limit exceeded
Solution: Wait for rate limit reset (typically 1 hour) or try again later
Debug Mode
Enable verbose logging for troubleshooting:
RUST_LOG=debug
RUST_LOG=debug Manual Installation
If auto-update fails, you can manually install:
# Download latest release
# Make executable
# Replace binary (system-wide)
# Or replace binary (user)
Security Considerations
- Source Verification: Updates only come from official GitHub Releases
- Binary Integrity: Release assets are verified during download
- No Arbitrary Execution: Only pre-built binaries are installed
- Transparent Process: All operations are logged and visible
- User Control: Updates are opt-in, no automatic background updates
Integration Examples
CI/CD Pipeline
#!/bin/bash
# Update terraphim-agent before running tests
if ; then
else
fi
# Run tests with latest version
Systemd Service
[Unit]
Description=Terraphim Agent Update
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/terraphim-agent update
User=terraphim
Group=terraphim
[Install]
WantedBy=multi-user.targetCron Job
# Weekly update check (Sundays at 2 AM)
API Reference (for developers)
The auto-update functionality is available as a Rust crate:
use ;
// Create updater configuration
let config = new
.with_version
.with_progress;
// Create updater instance
let updater = new;
// Check for updates
let status = updater.check_update.await?;
println!;
// Update if available
let status = updater.update.await?;
println!;Development
Testing Auto-Update Functionality
# Run integration tests
# Test with debug binary
Mock Updates (Development)
For testing without actual releases, you can:
- Create test releases in a fork
- Use environment variables to override repository
- Modify version strings for testing
Contributing
When contributing to the auto-update system:
- Test both
check-updateandupdatecommands - Verify cross-platform compatibility
- Add integration tests for new features
- Update documentation for API changes
- Test network error scenarios
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Discord: Terraphim Discord