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:
javis-bot
2026-11-14 16:27:42 +09:00
parent 3d75d74f92
commit ea2d3ba958
32 changed files with 1568 additions and 59 deletions

View File

@@ -355,6 +355,23 @@ impl AdminApi {
Ok(json!({"targets": crate::collect::result_targets(dir.path()),
"items": crate::collect::results(dir.path(), target, limit)?}))
}
// Schedules (admin.spec.md, "Schedules"): every person's, and deleting any of them.
"schedules_list" => {
let items = crate::schedule::Store::new(self.dir()?.path()).all()?;
Ok(json!({"items": items.iter().map(|i| {
let mut v = json!(i);
v["id"] = json!(i.id.to_string());
v["user"] = json!(i.user.to_string());
v["channel"] = json!(i.channel.map(|c| c.to_string()));
v
}).collect::<Vec<_>>()}))
}
"schedule_delete" => {
let id: u64 = arg_str(&args, "id")?.parse().map_err(|_| "예약 ID가 올바르지 않습니다")?;
crate::schedule::Store::new(self.dir()?.path()).delete(id, None)?;
crate::info_log!("admin", "schedule {id} deleted");
Ok(json!({"deleted": id.to_string()}))
}
"channel_sync_status" => Ok(Value::Object(self.syncer()?.status().into_iter()
.map(|(id, s)| (id.to_string(), json!(s))).collect())),
"discord_channel_info" => {
@@ -474,6 +491,26 @@ mod tests {
assert!(a.call("nope", json!({})).await.is_err());
}
#[tokio::test]
async fn the_schedule_screen_lists_everyones_schedules_and_deletes_any() {
let (a, base) = api("api-schedule");
let data = base.join("d");
a.call("folder_choose", json!({"path": data.to_string_lossy()})).await.unwrap();
assert_eq!(a.call("schedules_list", json!({})).await.unwrap()["items"], json!([]));
let store = crate::schedule::Store::new(&data);
let now = chrono::Utc::now().timestamp();
store.add(123456789012345678, "가", "remind", "회의", now + 600, "none", "voice", None, now).unwrap();
let b = store.add(9, "나", "task", "날씨", now + 60, "daily", "chat", Some(77), now).unwrap();
let items = a.call("schedules_list", json!({})).await.unwrap()["items"].as_array().unwrap().clone();
// Soonest first; IDs as strings (JSON numbers lose Discord IDs).
assert_eq!(items.iter().map(|i| i["text"].as_str().unwrap()).collect::<Vec<_>>(), ["날씨", "회의"]);
assert_eq!(items[1]["user"], "123456789012345678");
assert_eq!(items[0]["channel"], "77");
a.call("schedule_delete", json!({"id": b.id.to_string()})).await.unwrap();
assert_eq!(store.all().unwrap().len(), 1);
assert!(a.call("schedule_delete", json!({"id": b.id.to_string()})).await.is_err());
}
#[tokio::test]
async fn collection_targets_are_saved_and_their_results_read_from_the_data_folder() {
let (a, base) = api("api-collect");