add list_accounts daemon op to hive-matrix-mcp
This commit is contained in:
parent
2efd95d0f5
commit
68b0894f5b
3 changed files with 90 additions and 1 deletions
|
|
@ -171,6 +171,16 @@ pub enum DaemonOp {
|
|||
#[serde(rename = "unread_summary")]
|
||||
UnreadSummary,
|
||||
|
||||
/// List the matrix accounts the daemon currently has a live,
|
||||
/// restored session for. Account-agnostic (does not resolve a single
|
||||
/// client — handled before client resolution in `socket::dispatch`):
|
||||
/// returns each restored account's name, homeserver, user id, primary
|
||||
/// flag, and a `live` flag. Backs the dashboard's per-account status
|
||||
/// (BE-4) — turns BE-1's token-present list into true online/offline
|
||||
/// + backfills the homeserver BE-1 leaves null.
|
||||
#[serde(rename = "list_accounts")]
|
||||
ListAccounts,
|
||||
|
||||
/// Liveness probe — fast "are you up?" round-trip that doesn't
|
||||
/// touch matrix-sdk. Not used by the in-tree stdio MCP bridge
|
||||
/// (which surfaces a daemon-down condition as a normal tool-call
|
||||
|
|
@ -332,4 +342,23 @@ mod tests {
|
|||
assert!(parsed.account.is_none());
|
||||
matches!(parsed.op, DaemonOp::UnreadCount);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn list_accounts_parses_as_account_agnostic_unit_variant() {
|
||||
// Registry-wide op: no fields, and callers omit `account`.
|
||||
let parsed: DaemonRequest =
|
||||
serde_json::from_str(r#"{"op":{"method":"list_accounts"}}"#).unwrap();
|
||||
assert!(parsed.account.is_none());
|
||||
matches!(parsed.op, DaemonOp::ListAccounts);
|
||||
// And it serialises back to the same tagged shape.
|
||||
let line = serde_json::to_string(&DaemonRequest {
|
||||
account: None,
|
||||
op: DaemonOp::ListAccounts,
|
||||
})
|
||||
.unwrap();
|
||||
assert!(
|
||||
line.contains("\"method\":\"list_accounts\""),
|
||||
"wire: {line}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue