feat(app): answer registered chat channels in chat

- chatChannels[].answer: wakeWord (default) or everything. Chat uses
  call.chatWakeWords (else the voice wake words) with the shared
  designated-people switches.
- The brain's answer (reply via chat, not spoken) is posted as a Discord
  reply to the message, pinging nobody; failed or empty answers post
  nothing. Bots, channels with sending off and stops are not answered.
- Chat runs beside the voice conversation and never takes its turn.
- Core: send_chat_reply, chat_answer and the ReplyText event; the worker
  client's reply takes via.
- Specs (conversation, discord core) and the roadmap updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-11 22:36:43 +09:00
parent de35573e5f
commit a70ccda37e
11 changed files with 284 additions and 16 deletions

View File

@@ -114,12 +114,36 @@ request first, the answer stops (missed, `interrupted`) and the new request is a
running answer first, or does not come in time, the answer goes on and the new request waits. The
ranking is dropped when the running answer ends first.
## Chat calls
Registered chat channels are answered in chat, by text, beside the voice conversation: a chat message
never takes the voice turn and never goes through the response policy.
| Key | Default | Meaning |
|---|---|---|
| `chatChannels[].answer` | `"wakeWord"` | `wakeWord`: answer messages that call a wake word. `everything`: answer every message. |
- The wake words are `call.chatWakeWords` (or `voice.wakeWords` when it is `null`), with the same
similarity and the same designated-people switches as voice; `call.mode` is voice only.
- Only messages of a registered channel with reading on reach the loop (the core's rule), and only a
channel with sending on is answered: there an answer could not be posted, so none is asked for.
- Messages from bots (other bots and Jarvis itself) are never answered, so two bots cannot keep
answering each other.
- Only a request is answered: a stop in chat ("자비스 멈춰") is not a question and gets no answer.
- The brain answers through `reply` with `via: "chat"` and `speak: false`; the answer is posted in the
same channel as a Discord reply to the message (so the history records it as an answer to that
person), pinging nobody. A failed or empty answer posts nothing. Answers waited for over 5 minutes
are forgotten.
- Known limit: the worker writes one reply at a time, so a voice answer waits while a chat answer is
being written (the LLM's parallel requests for "answer everything" channels are M5/M6 settings).
## The conversation loop
`app/src/conversation.rs` runs between the core's events and everything else that reads them (every
event is passed on unchanged). It talks to the core through a small `Voice` interface (answer, cancel
one request, stop all, ask "addressed", ask "rank"), so the glue is tested with a fake.
- `Chat` and `ReplyText`: chat calls, above.
- `SpeechStart` opens the speaker's utterance; `SpeakingStopped` marks it ending.
- `Final`: a request gets the next id, `ended_at` = arrival minus the final's `wait_ms`, and goes
through call detection. Ignore closes the utterance. Stop stops all speech, runs the policy's stop,
@@ -149,5 +173,6 @@ modes) and every policy rule above with fake times (settling, ordering by end ti
interruption, ranking tie, ranking timeout, stop dropping the queue), and the conversation loop with a
fake voice side (answering and queueing, a busy drop recorded without text, voice stop, addressed yes,
no and timeout, interruption cancelling the right speech, a ranking deciding, end times from
`wait_ms`). `tests/worker_protocol.rs` checks an answer spoken under its id and both judgements against
`wait_ms`, and chat: an answer posted as a reply once, per-channel switches, no answers to bots or to
a stop, chat wake words and designated people, a failed answer posting nothing). `tests/worker_protocol.rs` checks an answer spoken under its id and both judgements against
the real Python worker with a fake brain.