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:
@@ -36,7 +36,7 @@ pub trait Voice {
|
||||
fn ask_addressed(&self, id: &str, user: u64, text: &str) -> bool;
|
||||
fn ask_rank(&self, id: &str, candidates: &[(String, u64, String)]) -> bool;
|
||||
/// Have the brain answer a chat message (not spoken); its text comes as `CoreEvent::ReplyText`.
|
||||
fn chat_answer(&self, id: &str, user: u64, text: &str) -> bool;
|
||||
fn chat_answer(&self, id: &str, user: u64, channel: u64, text: &str) -> bool;
|
||||
/// Post the chat answer `id` in `channel` as a reply to `message` (never pinging anyone), then
|
||||
/// tell the brain whether it was posted.
|
||||
fn send_reply(&self, id: &str, channel: u64, message: u64, text: &str);
|
||||
@@ -66,8 +66,8 @@ impl Voice for DiscordCore {
|
||||
fn ask_rank(&self, id: &str, candidates: &[(String, u64, String)]) -> bool {
|
||||
DiscordCore::ask_rank(self, id, candidates)
|
||||
}
|
||||
fn chat_answer(&self, id: &str, user: u64, text: &str) -> bool {
|
||||
DiscordCore::chat_answer(self, id, user, text)
|
||||
fn chat_answer(&self, id: &str, user: u64, channel: u64, text: &str) -> bool {
|
||||
DiscordCore::chat_answer(self, id, user, channel, text)
|
||||
}
|
||||
fn send_reply(&self, id: &str, channel: u64, message: u64, text: &str) {
|
||||
let core = self.clone();
|
||||
@@ -190,7 +190,7 @@ impl<V: Voice> Conversation<V> {
|
||||
self.chat_answers.retain(|_, (_, _, at)| now < *at + CHAT_ANSWER_KEPT);
|
||||
self.next_id += 1;
|
||||
let id = format!("c{}", self.next_id);
|
||||
if self.voice.chat_answer(&id, m.author_id, &m.content) {
|
||||
if self.voice.chat_answer(&id, m.author_id, m.channel_id, &m.content) {
|
||||
self.chat_answers.insert(id, (m.channel_id, m.message_id, now));
|
||||
}
|
||||
}
|
||||
@@ -485,6 +485,8 @@ mod tests {
|
||||
Addressed(String, u64),
|
||||
Rank(String, Vec<String>),
|
||||
ChatAnswer(String, u64, String),
|
||||
/// The channel a chat answer was asked for.
|
||||
ChatIn(u64),
|
||||
SendReply(String, u64, u64, String),
|
||||
NotPosted(String),
|
||||
}
|
||||
@@ -493,6 +495,7 @@ mod tests {
|
||||
struct Fake {
|
||||
did: Rc<RefCell<Vec<Did>>>,
|
||||
n: Rc<RefCell<u32>>,
|
||||
chat_in: Rc<RefCell<Vec<Did>>>,
|
||||
}
|
||||
impl Voice for Fake {
|
||||
fn answer(&self, user: u64, text: &str, _heard: (Instant, Instant)) -> Option<String> {
|
||||
@@ -520,7 +523,8 @@ mod tests {
|
||||
self.did.borrow_mut().push(Did::Rank(id.into(), c.iter().map(|x| x.0.clone()).collect()));
|
||||
true
|
||||
}
|
||||
fn chat_answer(&self, id: &str, user: u64, text: &str) -> bool {
|
||||
fn chat_answer(&self, id: &str, user: u64, channel: u64, text: &str) -> bool {
|
||||
self.chat_in.borrow_mut().push(Did::ChatIn(channel));
|
||||
self.did.borrow_mut().push(Did::ChatAnswer(id.into(), user, text.into()));
|
||||
true
|
||||
}
|
||||
@@ -869,6 +873,7 @@ mod tests {
|
||||
c.on_event(&chat(CH_WAKE, 5, A, false, "자비스 내일 일정 알려 줘"), t);
|
||||
let Did::ChatAnswer(id, user, text) = f.take().remove(0) else { panic!() };
|
||||
assert_eq!((user, text.as_str()), (A, "자비스 내일 일정 알려 줘"));
|
||||
assert_eq!(*f.chat_in.borrow(), vec![Did::ChatIn(CH_WAKE)], "the brain is told where it was asked");
|
||||
c.on_event(&CoreEvent::ReplyText { id: id.clone(), text: "내일은 비어 있어요.".into(), failed: false }, t);
|
||||
assert_eq!(f.take(), vec![Did::SendReply(id.clone(), CH_WAKE, 5, "내일은 비어 있어요.".into())]);
|
||||
// A second reply_text for the same id sends nothing.
|
||||
|
||||
Reference in New Issue
Block a user