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

@@ -17,6 +17,14 @@ pub struct ChatChannelSettings {
pub read: bool,
/// The assistant may send messages to this channel.
pub send: bool,
/// The assistant may edit the messages it wrote here (Discord allows only those).
pub edit: bool,
/// The assistant may add reactions here.
pub react: bool,
/// The assistant may delete messages here (needs Manage Messages for other people's). Off by default.
pub delete: bool,
/// The assistant may pin and unpin messages here. Off by default.
pub pin: bool,
}
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -225,6 +233,10 @@ pub fn parse_settings(raw: &Value) -> Result<Settings, SettingsError> {
description: get_str(Some(m), "description", &path, "")?,
read: get_bool(Some(m), "read", &path, true)?,
send: get_bool(Some(m), "send", &path, true)?,
edit: get_bool(Some(m), "edit", &path, true)?,
react: get_bool(Some(m), "react", &path, true)?,
delete: get_bool(Some(m), "delete", &path, false)?,
pin: get_bool(Some(m), "pin", &path, false)?,
});
}
@@ -307,7 +319,8 @@ mod tests {
assert_eq!(s.voice.wake_words, vec!["자비스", "javis"]);
assert_eq!(s.voice.stt.get("end_silence_ms"), Some(&json!(250)));
assert_eq!(s.chat_channels, vec![ChatChannelSettings { id: IDN, name: "일정".into(),
description: "일정 올리는 곳".into(), read: true, send: false }]);
description: "일정 올리는 곳".into(), read: true, send: false, edit: true, react: true, delete: false,
pin: false }]);
assert_eq!(s.voice_worker.args, vec!["--melo-python", "/m/python"]);
assert_eq!(s.voice_worker.cwd, PathBuf::from("/repo/src"));
}