feat(#2659): serve hive-matrix-mcp over persistent streamable-http, drop stdio bridge
This commit is contained in:
parent
ae8d1aaac4
commit
a66b7ab298
21 changed files with 411 additions and 856 deletions
|
|
@ -15,6 +15,7 @@
|
|||
//! never wakes on its own message.
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::hash::BuildHasher;
|
||||
|
||||
use matrix_sdk::{Client, ruma::OwnedRoomId};
|
||||
use tokio::sync::Mutex;
|
||||
|
|
@ -39,9 +40,9 @@ use crate::{handlers, wake};
|
|||
/// out by `collect_unread_with_ids` (after a rebuild a stale read receipt can
|
||||
/// otherwise leave a self-authored message counted as unread and self-wake
|
||||
/// the agent).
|
||||
pub async fn sweep_unread(
|
||||
pub async fn sweep_unread<S: BuildHasher>(
|
||||
client: &Client,
|
||||
notified: &Mutex<HashSet<OwnedRoomId>>,
|
||||
notified: &Mutex<HashSet<OwnedRoomId, S>>,
|
||||
account_tag: Option<&str>,
|
||||
) {
|
||||
let unread = handlers::collect_unread_with_ids(client).await;
|
||||
|
|
@ -52,7 +53,11 @@ pub async fn sweep_unread(
|
|||
// outside it, drop from `notified` on success (retry next tick on fail).
|
||||
let stale: Vec<OwnedRoomId> = {
|
||||
let active = notified.lock().await;
|
||||
active.difference(&unread_ids).cloned().collect()
|
||||
active
|
||||
.iter()
|
||||
.filter(|id| !unread_ids.contains(*id))
|
||||
.cloned()
|
||||
.collect()
|
||||
};
|
||||
for id in stale {
|
||||
if wake::send_todo_clear(Some(id.as_str()), false)
|
||||
|
|
@ -95,9 +100,9 @@ pub async fn sweep_unread(
|
|||
/// than on every sync tick; it is pruned to the current invite set each
|
||||
/// pass so a withdrawn-then-reissued invite wakes again. The agent
|
||||
/// decides whether to accept or reject by calling `resolve_invite`.
|
||||
pub async fn sweep_invites(
|
||||
pub async fn sweep_invites<S: BuildHasher>(
|
||||
client: &Client,
|
||||
notified: &Mutex<HashSet<OwnedRoomId>>,
|
||||
notified: &Mutex<HashSet<OwnedRoomId, S>>,
|
||||
account_tag: Option<&str>,
|
||||
) {
|
||||
let current = client.invited_rooms();
|
||||
|
|
@ -110,7 +115,10 @@ pub async fn sweep_invites(
|
|||
// tick on failure).
|
||||
let stale: Vec<OwnedRoomId> = {
|
||||
let seen = notified.lock().await;
|
||||
seen.difference(¤t_ids).cloned().collect()
|
||||
seen.iter()
|
||||
.filter(|id| !current_ids.contains(*id))
|
||||
.cloned()
|
||||
.collect()
|
||||
};
|
||||
for id in stale {
|
||||
if wake::send_todo_clear(Some(&invite_key(&id)), false)
|
||||
|
|
|
|||
Loading…
Reference in a new issue