feat(app): an activity log of what Jarvis did (chat actions, schedule deliveries)

Each chat channel action the brain's tool asked for and each schedule
delivery is recorded in activity/<day>.jsonl by kind, target, who asked and
outcome, never its text, kept 30 days. The worker's chat_action carries the
asker. A 한 일 screen lists the newest entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-14 16:51:18 +09:00
parent e8db417752
commit 04b603facd
17 changed files with 282 additions and 17 deletions

View File

@@ -366,6 +366,10 @@ impl AdminApi {
v
}).collect::<Vec<_>>()}))
}
"activity_list" => {
let limit = args.get("limit").and_then(Value::as_u64).unwrap_or(200).clamp(1, 1000) as usize;
Ok(json!({"items": crate::activity::Activity::new(self.dir()?.path()).recent(limit)}))
}
"schedule_delete" => {
let id: u64 = arg_str(&args, "id")?.parse().map_err(|_| "예약 ID가 올바르지 않습니다")?;
crate::schedule::Store::new(self.dir()?.path()).delete(id, None)?;
@@ -491,6 +495,20 @@ mod tests {
assert!(a.call("nope", json!({})).await.is_err());
}
#[tokio::test]
async fn the_activity_screen_reads_the_newest_entries() {
let (a, base) = api("api-activity");
let data = base.join("d");
a.call("folder_choose", json!({"path": data.to_string_lossy()})).await.unwrap();
assert_eq!(a.call("activity_list", json!({})).await.unwrap()["items"], json!([]));
let log = crate::activity::Activity::new(&data);
log.record("chat.send", "채널 1", None, true, None);
log.record("chat.delete", "채널 1 메시지 2", Some("9 가".into()), false, Some("no".into()));
let items = a.call("activity_list", json!({"limit": 1})).await.unwrap()["items"].clone();
assert_eq!(items.as_array().unwrap().len(), 1);
assert_eq!(items[0]["kind"], "chat.delete");
}
#[tokio::test]
async fn the_schedule_screen_lists_everyones_schedules_and_deletes_any() {
let (a, base) = api("api-schedule");