feat: multi-account matrix daemon (account-routed mcp surface)

This commit is contained in:
damocles 2026-06-15 20:23:42 +02:00
commit 8e79eb4f26
7 changed files with 613 additions and 156 deletions

View file

@ -119,6 +119,18 @@ pub fn format_unread_summary(rooms: &[crate::protocol::RoomUnread]) -> String {
out
}
/// Prepend an account marker to a wake `body` when the daemon serves
/// more than one matrix account. `tag` is `Some(name)` only in
/// multi-account mode; `None` returns `body` unchanged so single-account
/// wakes keep their exact format. Shape: `[acct:<name>] <body>`.
#[must_use]
pub fn tag_account(tag: Option<&str>, body: String) -> String {
match tag {
Some(name) => format!("[acct:{name}] {body}"),
None => body,
}
}
/// Truncate `s` to `max` Unicode chars, appending `…` when cut.
/// Char-based not byte-based so multi-byte content (most chat) doesn't
/// get cut mid-codepoint.
@ -177,4 +189,19 @@ mod tests {
let s = "hi";
assert_eq!(truncate_chars(s, 100), "hi");
}
#[test]
fn tag_account_none_is_passthrough() {
let body = "[matrix] @a:s in #x: hi".to_owned();
assert_eq!(tag_account(None, body.clone()), body);
}
#[test]
fn tag_account_some_prepends_marker() {
let body = "[matrix] @a:s in #x: hi".to_owned();
assert_eq!(
tag_account(Some("ccc"), body),
"[acct:ccc] [matrix] @a:s in #x: hi"
);
}
}