hive-agent: a logged-in agent polls the swarm login, and logs out when it is deleted
wait_for_login read the store leaf only while the agent waited for a login. A logged-in agent now reads it every 5 minutes, and a paused one once before it resumes, so a login made or deleted in the swarm UI reaches an agent that never failed. A newer version is installed; a store that answers nothing stored after a version was installed means the stored login was deleted, and the agent is logged out as /api/logout does it, with the recorded version forgotten so the next login installs. A read that fails changes nothing.
This commit is contained in:
parent
71a4d1d255
commit
a2c9e9a8d4
1 changed files with 188 additions and 23 deletions
|
|
@ -191,6 +191,14 @@ pub async fn wait_for_login(
|
|||
version,
|
||||
"installed the claude credentials the swarm login stored"
|
||||
),
|
||||
Ok(claude_credentials::Outcome::Deleted { installed }) => {
|
||||
// Nothing to log out of, but the recorded version would
|
||||
// keep a restarted counter's first login from installing.
|
||||
tracing::info!(installed, "the swarm's stored claude login was deleted");
|
||||
if let Err(e) = pickup.forget_installed() {
|
||||
tracing::warn!(error = %format!("{e:#}"), "forgetting the installed login version failed");
|
||||
}
|
||||
}
|
||||
Ok(outcome) => tracing::debug!(?outcome, "no newer swarm claude credentials"),
|
||||
Err(e) => tracing::warn!(
|
||||
error = %format!("{e:#}"),
|
||||
|
|
@ -214,7 +222,7 @@ pub async fn wait_for_login(
|
|||
|
||||
/// The swarm-login pickup for `claude_dir`, or `None` when this process has
|
||||
/// no store to read from.
|
||||
fn swarm_pickup(
|
||||
pub(crate) fn swarm_pickup(
|
||||
claude_dir: &Path,
|
||||
) -> Option<claude_credentials::Pickup<claude_credentials::Store>> {
|
||||
match claude_credentials::Store::from_env() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue