feat(#2569): merge harness-local todos into get_loose_ends
This commit is contained in:
parent
86d16efa07
commit
a2d44c7eb6
4 changed files with 34 additions and 2 deletions
|
|
@ -297,6 +297,30 @@ pub(super) async fn matrix_unread_summary() -> Option<Vec<MatrixRoomUnread>> {
|
|||
serde_json::from_value(serde_json::Value::Array(arr.clone())).ok()
|
||||
}
|
||||
|
||||
/// Query the harness's in-agent socket for this agent's local todos
|
||||
/// (loose-ends v2). Returns `None` when `HIVE_AGENT_SOCKET` is unset /
|
||||
/// absent or the query fails — best-effort, like [`matrix_unread_summary`],
|
||||
/// so an agent without the socket is not penalised.
|
||||
pub(super) async fn local_todos() -> Option<Vec<hive_sh4re::LooseEnd>> {
|
||||
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
|
||||
use tokio::net::UnixStream;
|
||||
let socket = std::env::var_os("HIVE_AGENT_SOCKET").map(std::path::PathBuf::from)?;
|
||||
if !socket.exists() {
|
||||
return None;
|
||||
}
|
||||
let mut stream = UnixStream::connect(&socket).await.ok()?;
|
||||
let mut req =
|
||||
serde_json::to_string(&hive_agent_sock::Request::ListTodos { subsystem: None }).ok()?;
|
||||
req.push('\n');
|
||||
stream.write_all(req.as_bytes()).await.ok()?;
|
||||
let mut lines = BufReader::new(stream).lines();
|
||||
let line = lines.next_line().await.ok()??;
|
||||
match serde_json::from_str::<hive_agent_sock::Response>(&line).ok()? {
|
||||
hive_agent_sock::Response::LooseEnds { loose_ends } => Some(loose_ends),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Format a `Vec<MatrixRoomUnread>` into a per-room summary string.
|
||||
/// Single room / single message collapses to one line; multi-room
|
||||
/// expands to a bulleted list. Returns an empty string for empty input.
|
||||
|
|
|
|||
Loading…
Reference in a new issue