agent loop: claude drives; tool envelope (log/run/status/log)

This commit is contained in:
müde 2026-05-15 14:54:10 +02:00
parent a061f83cfa
commit 3c9d42b2a7
6 changed files with 147 additions and 47 deletions

View file

@ -86,6 +86,20 @@ impl Broker {
Ok(())
}
/// Number of undelivered messages addressed to `recipient`. Non-mutating
/// — used by the harness to surface "N unread" in tool-result status
/// lines without popping the queue.
pub fn count_pending(&self, recipient: &str) -> Result<u64> {
let conn = self.conn.lock().unwrap();
let n: i64 = conn.query_row(
"SELECT COUNT(*) FROM messages
WHERE recipient = ?1 AND delivered_at IS NULL",
params![recipient],
|row| row.get(0),
)?;
Ok(u64::try_from(n.max(0)).unwrap_or(0))
}
pub fn recv(&self, recipient: &str) -> Result<Option<Message>> {
let conn = self.conn.lock().unwrap();
let row: Option<(i64, String, String, String)> = conn