manager mcp: expose 'remind' tool sharing storage helper with agent surface

This commit is contained in:
damocles 2026-05-17 11:43:14 +02:00
parent 0e6bac8388
commit 1770b51845
6 changed files with 120 additions and 24 deletions

View file

@ -227,30 +227,32 @@ fn handle_remind(
timing: &hive_sh4re::ReminderTiming,
file_path: Option<&str>,
) -> AgentResponse {
let due_at = match resolve_due_at(timing) {
Ok(t) => t,
Err(e) => {
return AgentResponse::Err {
message: format!("invalid reminder timing: {e:#}"),
};
}
};
let (stored_message, stored_path) = match prepare_remind_storage(agent, message, file_path) {
Ok(pair) => pair,
Err(e) => return AgentResponse::Err { message: e },
};
match coord
match store_remind(coord, agent, message, timing, file_path) {
Ok(()) => AgentResponse::Ok,
Err(message) => AgentResponse::Err { message },
}
}
/// Shared remind-storage path used by both the agent and the manager
/// dispatchers. Validates timing, applies the auto-file overflow
/// dance (see [`prepare_remind_storage`]), and writes the reminder
/// row. Returns `Ok(())` on success, or a caller-ready error string
/// the dispatcher wraps in `*Response::Err`.
pub(crate) fn store_remind(
coord: &Arc<Coordinator>,
agent: &str,
message: &str,
timing: &hive_sh4re::ReminderTiming,
file_path: Option<&str>,
) -> Result<(), String> {
let due_at = resolve_due_at(timing).map_err(|e| format!("invalid reminder timing: {e:#}"))?;
let (stored_message, stored_path) = prepare_remind_storage(agent, message, file_path)?;
let id = coord
.broker
.store_reminder(agent, &stored_message, stored_path.as_deref(), due_at)
{
Ok(id) => {
tracing::info!(%id, %agent, %due_at, "reminder scheduled");
AgentResponse::Ok
}
Err(e) => AgentResponse::Err {
message: format!("failed to store reminder: {e:#}"),
},
}
.map_err(|e| format!("failed to store reminder: {e:#}"))?;
tracing::info!(%id, %agent, %due_at, "reminder scheduled");
Ok(())
}
/// Decide what we actually store in the reminders row, applying the