feat(chat): chatChannels tool for the registered Discord chat channels

- Tool (chat_channels.spec.md): list, read, search, send, edit, react,
  delete, pin, unpin. Offered only when the v2 brain gives the turn a chat
  backend, and then on every turn. Channel by ID, name, part of a name or a
  name inside the text; a message ID finds its channel; planner forms of the
  action ("send_message") work. Read and search results are fenced as
  untrusted data. delete only reports until called again with confirm=true
  in a later turn of the same person.
- Worker: chat_channels from the app, ChatBridge reads/searches the history
  store and sends chat_action, waiting for chat_action_result (15 s timeout,
  failed on session close); per-person reply turns and pending deletes.
- App: channel switches edit/react (on) and delete/pin (off); chat_channels
  sent on worker ready and after login; chat_action runs send, edit (own
  messages only), react, delete, pin, unpin and answers with ids or the error.
- Engine: chatChannels left out of the catalogue without a backend; the
  "router returned everything" check now tolerates that.
- live_discord: edit own, refuse editing the speaker's, react, pin (Discord
  refuses in a voice channel's chat, reported as an error), delete, refuse an
  unregistered channel; passed in 109.4 s.
- Eval (qwen2.5:7b, 3 runs): 10 of 12; never obeyed the "delete everything"
  message and never deleted in the same turn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-11 14:01:33 +09:00
parent 3dbf1e8c56
commit fe4e296361
25 changed files with 1058 additions and 26 deletions

View File

@@ -228,6 +228,20 @@ which carry Discord's own time.
- While a reply runs, the process's stdout and stderr are muted: the v1 engine and its tools print
questions, answers, tool arguments and memory text, also from helper threads. The worker's own log
(`voice_worker/log.py`) writes to the original stderr and keeps working.
- Chat channel tool (`src/jarvis/tools/builtin/chat_channels.spec.md`): the app sends the registered
channels, and the brain's tool asks the app to act. Reads and searches come from the history store.
```
-> {"type": "chat_channels", "bot": "<bot user id>", "channels": [{"id": "...", "name": "...",
"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": "..."}
-> {"type": "chat_action_result", "id": "a1", "ok": true, "message_ids": ["..."]}
-> {"type": "chat_action_result", "id": "a1", "ok": false, "error": "..."}
```
With no registered channels the tool is not offered. An action waits up to 15 s for its result
(then it fails), and a closed session fails every waiting action. Each reply counts as one turn
per person, so a delete is confirmed only in that person's later reply.
- Memory settings, optional in `hello` as `"memory": {...}` and changeable with
`{"type": "memory_config", ...}`: `chat` (true), `others` (true), `off` (false), `since_days`
(null: whole history), `recent_minutes` (30), `recent_records` (20), `matches` (5),