terraphim_update
Auto-update functionality for Terraphim AI binaries.
Overview
This crate provides a unified interface for self-updating Terraphim AI CLI tools using GitHub Releases as a distribution channel. It includes:
- Update checking: Check for available updates from GitHub Releases
- Binary updating: Self-update to the latest version
- Rollback support: Backup and rollback to previous versions
- Scheduler: Background periodic update checks
- Startup checks: Non-blocking update checks on application startup
Features
- Automatic update detection from GitHub Releases
- Safe self-update with signature verification (PGP)
- Backup and rollback support
- Configurable update intervals
- Tokio-based async scheduler for background checks
- Cross-platform support (Linux, macOS, Windows)
Usage
Basic Update Check
use check_for_updates_auto;
async
Update Binary
use update_binary;
async
Startup Check
use check_for_updates_startup;
async
Update Scheduler
use start_update_scheduler;
async
Backup and Rollback
use ;
use Path;
// Backup current binary
let backup_path = backup_binary?;
// Rollback to backup
rollback?;
Configuration
Update behavior can be configured through environment variables or config files:
Environment Variables
TERRAPHIM_AUTO_UPDATE- Enable/disable auto-update (default:true)TERRAPHIM_UPDATE_INTERVAL- Check interval in seconds (default:86400= 24 hours)
Example Configuration
Update Status
The crate returns various update statuses:
UpdateStatus::UpToDate(version)- Already running latest versionUpdateStatus::Available { current_version, latest_version }- Update available but not installedUpdateStatus::Updated { from_version, to_version }- Successfully updatedUpdateStatus::Failed(error)- Update failed
Integration with Binaries
CLI Integration
Add to Cargo.toml:
[]
= { = "../terraphim_update", = "1.0.0" }
Add CLI commands:
async
async
async
Agent Integration
Add startup check:
Rollback Instructions
List Available Backups
Rollback to Specific Version
Or manually:
Security
- Updates are downloaded from GitHub Releases over HTTPS
- PGP signature verification is supported (requires manual setup)
- Binary permissions are preserved during updates
- Backup files are created before updating
Testing
Run tests:
License
Apache-2.0