feat: reminders and scheduled tasks (schedule tool, app store and delivery)
The brain gets a schedule tool (add, list, delete the asker's own reminders, timers and tasks) offered only with a schedule backend. The voice worker asks the app through schedule_action and runs fired tasks as reply via task with read-only tools, no MCP and a fresh short-term memory. The app keeps the schedules in config/schedules.json, fires them every 5 s, speaks them when the person is in Jarvis's voice channel and otherwise posts in the chat channel they asked in (or schedule.chatChannel for voice). A feature switch and a 예약 screen list and delete everyone's schedules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,8 @@ pub struct Services {
|
||||
pub game: Arc<crate::game::GameWatch>,
|
||||
/// Moves the LLM between the performance stages as games come and go.
|
||||
pub perf: std::sync::Mutex<Option<tokio::task::JoinHandle<()>>>,
|
||||
/// Fires the reminders and scheduled tasks (admin.spec.md, "Schedules").
|
||||
pub schedules: std::sync::Mutex<Option<tokio::task::JoinHandle<()>>>,
|
||||
}
|
||||
|
||||
/// The bot browser of a run (admin.spec.md, "Bot browser").
|
||||
@@ -68,6 +70,11 @@ impl Services {
|
||||
p.abort();
|
||||
let _ = p.await;
|
||||
}
|
||||
let schedules = self.schedules.lock().unwrap().take();
|
||||
if let Some(s) = schedules {
|
||||
s.abort();
|
||||
let _ = s.await;
|
||||
}
|
||||
self.game.stop();
|
||||
self.core.close().await;
|
||||
self.worker.close();
|
||||
@@ -191,7 +198,10 @@ pub async fn start_services(data_dir: &Path, llm: Arc<Llm>) -> Result<Services,
|
||||
|
||||
let (calls, response) = (settings.call.clone(), settings.response.clone());
|
||||
let chat_calls = conversation::ChatCalls::from_settings(&settings);
|
||||
let schedule_channel = settings.schedule_channel;
|
||||
let (core, core_events) = DiscordCore::new(settings, token, worker.clone(), worker_events);
|
||||
let schedule_store = Arc::new(crate::schedule::Store::new(data_dir));
|
||||
core.set_schedules(schedule_store.clone());
|
||||
// Call detection and the response policy answer what is heard; every event still reaches `events`.
|
||||
let (out, events) = mpsc::unbounded_channel();
|
||||
let conv = Conversation::new(core.clone(), calls, response).with_chat(chat_calls);
|
||||
@@ -203,9 +213,11 @@ pub async fn start_services(data_dir: &Path, llm: Arc<Llm>) -> Result<Services,
|
||||
return Err(after_stop(&llm, &browser, e.to_string()).await.into());
|
||||
}
|
||||
crate::info_log!("app", "services started");
|
||||
let schedules = std::sync::Mutex::new(Some(tokio::spawn(crate::schedule::run(schedule_store,
|
||||
Arc::new(core.clone()), schedule_channel))));
|
||||
let on = { let g = game.clone(); Arc::new(move || g.on()) };
|
||||
let perf = std::sync::Mutex::new(Some(tokio::spawn(perf_loop(perf_settings, llm.clone(), Arc::new(worker.clone()), on, RETRY_AFTER))));
|
||||
Ok(Services { core, events, worker, worker_process, missed, llm, browser, game, perf })
|
||||
Ok(Services { core, events, worker, worker_process, missed, llm, browser, game, perf, schedules })
|
||||
}
|
||||
|
||||
/// The brain as the performance stages see it: told the LLM's state, and asked to finish what it is
|
||||
|
||||
Reference in New Issue
Block a user