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

@@ -16,8 +16,10 @@ def _message(rec) -> dict:
class ChatBridge:
def __init__(self, session, loop: asyncio.AbstractEventLoop, turn: int, pending_deletes: dict):
def __init__(self, session, loop: asyncio.AbstractEventLoop, turn: int, pending_deletes: dict,
user: str | None = None):
self._session = session
self._user = user # who asked: the app records it with the action (admin.spec.md, "Activity")
self._loop = loop
self._channels = [dict(c) for c in session.chat_channels]
self.turn = turn
@@ -39,7 +41,8 @@ class ChatBridge:
return store.chat_channel_of(message_id) if store else None
def act(self, action: str, channel_id: str, **kw: Any) -> dict:
fut = asyncio.run_coroutine_threadsafe(self._session.chat_action(action, channel_id, kw), self._loop)
args = {**kw, "user": self._user} if self._user else kw
fut = asyncio.run_coroutine_threadsafe(self._session.chat_action(action, channel_id, args), self._loop)
try:
return fut.result(self._session.worker.chat_timeout_s + 5)
except Exception as e: # loop gone or the wait broke

View File

@@ -803,7 +803,7 @@ class Session:
debug_log(f"brain reply {rid} arrived before the previous answer: a turn is skipped",
"llm")
from .chat_bridge import ChatBridge
chat = ChatBridge(self, asyncio.get_running_loop(), turn, w.pending_deletes.setdefault(user, {})) \
chat = ChatBridge(self, asyncio.get_running_loop(), turn, w.pending_deletes.setdefault(user, {}), user) \
if self.chat_channels else None
from .schedule_bridge import ScheduleBridge
schedule = ScheduleBridge(self, asyncio.get_running_loop(), user, via,

View File

@@ -296,7 +296,8 @@ which carry Discord's own time.
"description": "...", "read": true, "send": true, "edit": true, "react": true,
"delete": false, "pin": false}]}
<- {"type": "chat_action", "id": "a1", "action": "send|edit|react|delete|pin|unpin",
"channel": "...", "message_id": "...", "text": "...", "emoji": "..."}
"channel": "...", "message_id": "...", "text": "...", "emoji": "...",
"user": "<id>"} // who asked; the app records it (Activity)
-> {"type": "chat_action_result", "id": "a1", "ok": true, "message_ids": ["..."]}
-> {"type": "chat_action_result", "id": "a1", "ok": false, "error": "..."}
```