add a /clear-todos command that marks the agent's todos done
This commit is contained in:
parent
76882ec3b8
commit
dc0d08b7fb
1 changed files with 200 additions and 43 deletions
|
|
@ -570,15 +570,10 @@ async fn serve_main<S: Surface>(socket: &Path, poll_ms: u64) -> Result<()> {
|
|||
});
|
||||
// Before the first turn, so claude's own auto-load finds `AGENTS.md`.
|
||||
agents_md_migrate::run(&paths::state_dir());
|
||||
// Harness-local reminders: a due reminder fires
|
||||
// straight into an mpsc channel the serve loop races against the
|
||||
// broker long-poll (unlike todos, a fire carries real per-row data,
|
||||
// so a bare `Notify` doesn't fit — see `reminder_timer` docs).
|
||||
// Best-effort: `reminder_timer::run` parks forever (never sends)
|
||||
// instead of exiting when the store can't open, so the channel
|
||||
// never observes a "closed" state. Opened before the todo socket
|
||||
// below so the same `Arc` can be handed to its request dispatch
|
||||
// (reminder ops share the todo socket/listener).
|
||||
// Harness-local reminders fire into an mpsc channel the serve loop races
|
||||
// against the broker long-poll (see `reminder_timer`). Best-effort: it
|
||||
// parks forever instead of closing the channel when the store can't open.
|
||||
// Opened before the todo socket, which shares the same `Arc`.
|
||||
// Fold the pre-consolidation per-concern db files into the single
|
||||
// `hyperhive-state.sqlite`, if this is the first boot since the
|
||||
// upgrade — see `db_migrate` module docs. Best-effort: a failure here
|
||||
|
|
@ -595,16 +590,9 @@ async fn serve_main<S: Surface>(socket: &Path, poll_ms: u64) -> Result<()> {
|
|||
// Messages made inside this container rather than by the broker:
|
||||
// reminders and the swarm UI's operator input.
|
||||
let (local_msg_tx, local_msg_rx) = tokio::sync::mpsc::unbounded_channel();
|
||||
swarm_input::spawn(local_msg_tx.clone(), bus.clone(), interrupted.clone());
|
||||
let reminder_store = match reminders::Reminders::open(&paths::state_db()) {
|
||||
Ok(store) => Some(Arc::new(store)),
|
||||
Err(e) => {
|
||||
tracing::error!(error = ?e, "open reminders db failed — reminder delivery disabled");
|
||||
None
|
||||
}
|
||||
};
|
||||
tokio::spawn(reminder_timer::run(reminder_store.clone(), local_msg_tx));
|
||||
let (todo_wake, todos_store) = spawn_todo_socket(reminder_store.clone(), &bus);
|
||||
let reminder_store = open_reminders();
|
||||
let (todo_wake, todos_store) =
|
||||
start_local_inputs(reminder_store, local_msg_tx, &bus, &interrupted);
|
||||
// Self-announce this boot as a todo instead of relying on hive-c0re's
|
||||
// old `kick_agent` broker messages — see `boot_announce`'s module doc
|
||||
// for why this is strictly better than a host-side kick.
|
||||
|
|
@ -641,6 +629,32 @@ async fn serve_main<S: Surface>(socket: &Path, poll_ms: u64) -> Result<()> {
|
|||
.await
|
||||
}
|
||||
|
||||
/// Start what feeds the serve loop from inside the container: the reminder
|
||||
/// timer, the todo socket and the swarm UI's input, which also needs the todo
|
||||
/// store for `/clear-todos`.
|
||||
fn start_local_inputs(
|
||||
reminders: Option<Arc<reminders::Reminders>>,
|
||||
tx: tokio::sync::mpsc::UnboundedSender<hive_sh4re::inbox::DeliveredMessage>,
|
||||
bus: &Bus,
|
||||
interrupted: &Arc<std::sync::atomic::AtomicBool>,
|
||||
) -> (Arc<tokio::sync::Notify>, Option<Arc<todos::Todos>>) {
|
||||
tokio::spawn(reminder_timer::run(reminders.clone(), tx.clone()));
|
||||
let (todo_wake, todos) = spawn_todo_socket(reminders, bus);
|
||||
swarm_input::spawn(tx, bus.clone(), interrupted.clone(), todos.clone());
|
||||
(todo_wake, todos)
|
||||
}
|
||||
|
||||
/// The reminder store, or `None` (logged, reminders off) when it can't open.
|
||||
fn open_reminders() -> Option<Arc<reminders::Reminders>> {
|
||||
match reminders::Reminders::open(&paths::state_db()) {
|
||||
Ok(store) => Some(Arc::new(store)),
|
||||
Err(e) => {
|
||||
tracing::error!(error = ?e, "open reminders db failed — reminder delivery disabled");
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Hand the bus the session's handles the web UI reads from outside a turn.
|
||||
fn share_session_handles(bus: &Bus, session: &turn::AgentSession) {
|
||||
if let Some(canceller) = hive_runtime::Runtime::canceller(session) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue