feat(#2039): list matrix identities in get_agent_meta

This commit is contained in:
damocles 2026-06-27 11:51:34 +02:00 committed by mara
commit 5b442796ca
3 changed files with 59 additions and 0 deletions

View file

@ -417,9 +417,24 @@ async fn handle_get_agent_meta(
status_set_at,
hive_name,
swarm_name,
matrix_accounts: read_agent_matrix_identities(target),
}
}
/// Read the target agent's matrix identities from the daemon's
/// `matrix-accounts.json` snapshot (under the agent's state dir).
/// Best-effort: an absent / unparseable snapshot (no matrix provisioning,
/// or the daemon not up yet) yields an empty list. The `MatrixIdentity`
/// serde shape matches the snapshot entries; the snapshot's `live` field is
/// ignored (only live accounts are written).
fn read_agent_matrix_identities(agent: &str) -> Vec<hive_sh4re::MatrixIdentity> {
let path = Coordinator::agent_notes_dir(agent).join("matrix-accounts.json");
std::fs::read_to_string(&path)
.ok()
.and_then(|s| serde_json::from_str::<Vec<hive_sh4re::MatrixIdentity>>(&s).ok())
.unwrap_or_default()
}
/// `Status` — count of pending (unread) inbox messages for `agent`.
fn handle_status(coord: &Arc<Coordinator>, agent: &str) -> hive_sh4re::Response {
match coord.broker.count_pending(agent) {