refactor(#2455): split hive-agent-mcp into its own bin crate

This commit is contained in:
damocles 2026-07-14 23:45:33 +02:00
commit e7f8254788
15 changed files with 334 additions and 100 deletions

View file

@ -5,7 +5,6 @@
//! stay in the binary because they touch the request enum variants directly.
use crate::events::Bus;
use crate::mcp::REDELIVERY_HINT;
use crate::turn::{TurnError, TurnOutcome};
use crate::turn_stats::TurnStatRow;
pub use hive_sh4re::wire_time::now_unix;
@ -23,38 +22,20 @@ pub fn format_wake_prompt(
unread: u64,
redelivered: bool,
) -> String {
let banner = if redelivered { REDELIVERY_HINT } else { "" };
let banner = if redelivered {
hive_sh4re::REDELIVERY_HINT
} else {
""
};
let tag = if id > 0 {
format!("[msg #{id}] ")
} else {
String::new()
};
let pending = pending_hint(unread);
let pending = hive_sh4re::pending_hint(unread);
format!("{banner}{tag}Incoming message from `{from}`:\n---\n{body}\n---{pending}")
}
/// Shared "(N more message(s) pending …)" advisory appended after both the
/// wake prompt body and the `recv` tool result whenever the inbox still has
/// queued messages once the current message/batch is popped. Returns an empty
/// string when `remaining == 0`. The leading `\n\n` separates it from the
/// preceding body/message block, and the suggested `max` is clamped to the
/// server-side recv cap so the hint never asks for more than one round-trip
/// can deliver. One builder so the wake prompt and the in-turn recv result
/// stay identical.
#[must_use]
pub fn pending_hint(remaining: u64) -> String {
if remaining == 0 {
return String::new();
}
let batch = remaining.min(u64::from(hive_sh4re::RECV_BATCH_MAX));
format!(
"\n\n({remaining} more message(s) pending in your inbox — call `mcp__hyperhive__recv` \
with `max: {batch}` to drain the next batch before acting. If the \
backlog is stale/already handled, `ack_until(up_to: <highest [msg #N] seen>)` \
clears everything up to that id in one call instead.)"
)
}
/// Field-named args for [`build_row`]. Mirrors the turn-stats row
/// columns; `outcome` and `bus` borrow for the duration of the call.
pub struct TurnRowArgs<'a> {