feat(voice): unify Discord voice↔text session (squash of voice/text-unify)
Voice utterances and text messages on the same Discord channel now share one Claude session, and Echo's voice replies are mirrored back into the text channel. Replaces the old voice:<id> session-key split. Changes: - src/adapters/_text_chunks.py: new leaf module for split_message (used by both discord_bot and voice pipeline) - src/router.py: drop voice: prefix from session_key; add [voice] marker; strip leading [speaker:/[voice] tokens from user input (anti-jailbreak); remove dead double-clear of voice: key - src/claude_session.py: include personality/VOICE_MODE.md unconditionally (rules become per-turn-aware via [speaker:] prefix instead of session flag) - src/voice/pipeline.py: VoiceSession splits text_channel_id + voice_channel_id; resolve text channel per-send (no stale refs); mirror Echo's reply text into the text channel after route_message returns - src/adapters/discord_voice.py: /voice join passes both channel ids - src/adapters/discord_bot.py: import split_message from leaf module - personality/VOICE_MODE.md: rewrite as per-turn dynamic rules; add synthesis instructions for text turns after voice turns Tests: - tests/test_router.py: 4 new cases (plain channel_id, anti-jailbreak, text-adapter regression, no-double-clear) - tests/test_pipeline_mirror.py: new — Echo reply mirror chunking, empty guard, mirror_enabled=False, send-raises resilience - tests/test_voice_session_channel_ids.py: new — split-attr contract + metrics payload schema - tests/test_voice_session_cleanup.py: update for new kwargs Plan: /home/moltbot/.claude/plans/vreau-ca-tot-textul-greedy-rivest.md Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -76,10 +76,13 @@ def _make_session(
|
||||
record_enabled: bool = True,
|
||||
) -> VoiceSession:
|
||||
jsonl = tmp_path / ("transcripts.jsonl" if record_enabled else "noop.jsonl")
|
||||
# mock_text_channel kept resolvable via bot.get_channel for any future
|
||||
# send invocations; cleanup tests don't exercise mirror, just attribute.
|
||||
mock_bot.get_channel = MagicMock(return_value=mock_text_channel)
|
||||
return VoiceSession(
|
||||
channel_id=1001,
|
||||
text_channel_id=1001,
|
||||
voice_channel_id=2002,
|
||||
guild_id=42,
|
||||
text_channel=mock_text_channel,
|
||||
voice_client=mock_voice_client,
|
||||
bot=mock_bot,
|
||||
ttsq=mock_ttsq,
|
||||
|
||||
Reference in New Issue
Block a user