Implementation:1ay1 Agentty Self Update
| Knowledge Sources | |
|---|---|
| Domains | Distribution, Updates |
| Last Updated | 2026-10-28 12:00 GMT |
Overview
Self-update against GitHub releases: background version check, `agentty update` command, and atomic binary replacement with fail-safe rollback.
Description
The agentty::update module implements self-update against GitHub releases. Design goals: never slow anything down (TUI check on a background thread, deferred past first paint, rate-limited by a 24h on-disk cache); make updating trivial (`agentty update`, `/update` in the palette); fail safe (download to sibling temp, verify, atomic rename — the running process keeps its old image).
Channel: GitHub releases of agentty-org/agentty, single-file binaries named `agentty-<os>-<arch>[.exe]`. Package-manager installs (rpm/pacman/ebuild) are detected by install-path heuristics and get a "use your package manager" message instead of a self-replace.
Usage
Import this when you need to: check for updates, perform a self-update, or query the current/latest version.
Code Reference
Source Location
- Repository: 1ay1_Agentty
- File: include/agentty/util/update.hpp
- Lines: 1-68
Signature
namespace agentty::update {
struct CheckResult {
bool update_available = false;
std::string current, latest, url, error;
};
[[nodiscard]] bool version_less(const std::string& a, const std::string& b);
[[nodiscard]] std::string current_version();
[[nodiscard]] CheckResult check_latest(bool force = false);
[[nodiscard]] std::optional<CheckResult> cached_check();
[[nodiscard]] std::string platform_asset();
[[nodiscard]] bool self_update_possible(std::string& reason);
[[nodiscard]] std::string perform_update(const std::string& tag,
const std::function<void(std::size_t, std::size_t)>& progress = {});
}
Import
#include "agentty/util/update.hpp"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| tag | std::string | Yes (perform) | The release tag to update to |
| force | bool | No (check) | Bypass the 24h cache |
Outputs
| Name | Type | Description |
|---|---|---|
| CheckResult | struct | update_available, current, latest, url, error |
| perform_update() | std::string | Empty on success; human error message on failure |
Usage Examples
Check and Perform Update
#include "agentty/util/update.hpp"
// Background check (rate-limited by 24h cache):
auto check = agentty::update::check_latest();
if (check.update_available) {
// Show "⬆ v{latest}" chip in status bar
// /update or `agentty update`:
auto err = agentty::update::perform_update(check.latest,
[](size_t done, size_t total) { /* progress */ });
if (!err.empty()) {
// err is a human-readable failure message
}
}