Commit Graph

175 Commits

Author SHA1 Message Date
Christian Gick
8402f0e36a fix: Increase WildFiles RAG timeout from 5s to 15s
Embedding generation on CPU (bge-m3) takes ~3s, plus network latency
can exceed 5s causing silent failures and empty results.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:36:22 +02:00
Christian Gick
52412a8d02 chore: Trigger rebuild 2026-02-16 13:25:56 +02:00
Christian Gick
2e4090aff8 feat: Auto-rename DM rooms by default with improved title prompt
- DM rooms (1:1 with bot) now auto-rename after first response
  without needing !ai auto-rename on
- Group rooms still require explicit opt-in
- Skip rename if room already has a meaningful name
- Improved prompt: emoji prefix, 3-5 words, same language as chat
  (inspired by Open WebUI title generation)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:25:40 +02:00
Christian Gick
380c9dd11d chore: Trigger rebuild 2026-02-16 13:06:44 +02:00
Christian Gick
a0367f32e3 feat: Add RAG query rewriting for contextual follow-up questions
When a user asks "Wer ist Mieter in diesem Haus?" after discussing
a specific house, the raw message lacks context for RAG search.
Now uses a quick LLM call to resolve pronouns/references before
searching WildFiles (e.g. "diesem Haus" -> "Mieter Haus Coburg").

Also moved history fetch before RAG search so context is available.

Refs: WF-90

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:06:26 +02:00
Christian Gick
e1438c9abf chore: Trigger rebuild 2026-02-16 13:02:59 +02:00
Christian Gick
a80eb6f5b7 fix: Read source_url from top-level field in RAG response
source_url is now a top-level field on DocumentChunk, not nested
in metadata. Fall back to metadata for backwards compatibility.

Refs: WF-90

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:02:43 +02:00
Christian Gick
6d39038597 chore: Trigger rebuild 2026-02-16 08:52:14 +02:00
Christian Gick
1e317bbd6d feat(CF-1189): Add auto-rename, fix system prompt, load room settings
- Add !ai auto-rename on/off command to auto-name rooms based on conversation topic
- Persist auto-rename setting via room state event (ai.agiliton.auto_rename)
- Generate short title via LLM after first AI response, set as m.room.name
- Load persisted model and auto-rename settings lazily from room state
- Strengthen system prompt: prohibit asking about document storage, file locations
- Fix bot suggesting !ai commands and admin contact to users

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 08:48:44 +02:00
Christian Gick
0c82047ba8 fix(CF-1189): Fix room.timeline crash, add markdown rendering, improve verification routing
- Replace room.timeline (non-existent in nio) with client.room_messages() API
- Add markdown-to-HTML conversion for formatted Matrix messages
- Route in-room verification events from both UnknownEvent and RoomMessageUnknown

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 06:53:00 +02:00
Christian Gick
21635bb3ab feat(CF-1189): Add in-room SAS verification for E2E key sharing
Element withholds megolm keys from unverified devices. Implements
the full in-room m.key.verification.* protocol so Element Verify works.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 19:22:32 +02:00
Christian Gick
ac26c71709 feat: respond to all messages in DMs without requiring @mention
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 19:02:36 +02:00
Christian Gick
07dfc05f76 fix: bump openai to >=2.0 (required by livekit-agents 1.4)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 18:12:57 +02:00
Christian Gick
2c60a1562c feat(CF-1189): Add AI text bot + WildFiles RAG integration
Extends bot.py with text message handling:
- RoomMessageText callback with @mention detection
- LLM responses via LiteLLM (OpenAI-compatible)
- WildFiles document search (DocumentRAG class)
- Per-room model selection via room state events
- Commands: !ai help/models/set-model/search
- Typing indicators during AI response generation
- 30s staleness check to avoid replaying history

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 18:10:28 +02:00
Christian Gick
2917f6515a fix: set agent_name via rtc_session decorator, revert CLI flag
AgentServer in livekit-agents 1.4.x does not support --agent-name CLI
flag. The agent_name must be set on @server.rtc_session() decorator.
Also reverts docker-compose.yml command back to plain python agent.py start.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 17:25:34 +02:00
Christian Gick
d5af90c7c7 fix(CF-1170): Fix STT by correcting agent dispatch flow
Three fixes for voice agent not responding to speech:
1. Agent name: add --agent-name matrix-ai to CLI (was empty, dispatch couldnt match)
2. Move dispatch from on_invite to on_unknown call handler (dispatch when call starts, not on room join)
3. Use LiveKit room name from foci_preferred instead of raw Matrix room ID

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 17:21:32 +02:00
Christian Gick
7032fef5c4 fix: use standard ctx.connect() for audio pipeline (CF-1170)
Custom rtc.Room skipped ctx.connect(), leaving framework audio
input pipeline uninitialized. STT/VAD never received audio frames.
Switch to standard approach: ctx.connect() + ctx.room.
Added debug event logging for speech pipeline.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 13:55:15 +02:00
Christian Gick
ee4efd01ef fix: agent cleanup on disconnect + targeted audio input
- Agent disconnects custom room when all real participants leave
  (prevents zombie participants blocking auto-dispatch)
- Bot sends m.call.member state event on call detection
  (Element Call shows bot as joined)
- Use RoomInputOptions(participant_identity=...) to target real user
  audio input (framework agent-AJ_xxx participant was confusing RoomIO)
- Removed incorrect bot dispatch (Matrix room ID != LiveKit room name)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 13:41:53 +02:00
Christian Gick
a0debf0bd8 feat: Add cross-signing bootstrap + canonicaljson dep
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 08:19:38 +02:00
Christian Gick
a7b55a1696 fix: Persist login credentials for stable device ID
- Save user_id/device_id/access_token to crypto store on first login
- restore_login() on subsequent starts (no new device each restart)
- Enables proper Olm session persistence across restarts

CF-1147

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 08:03:51 +02:00
Christian Gick
d7044b613c fix: Auto-trust all devices for E2E decryption
Bot now trusts all room member devices on each sync, enabling
Megolm key exchange. Logs undecryptable events for debugging.

CF-1147

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 08:01:14 +02:00
Christian Gick
cbc61f1646 feat: Add E2E encryption support to Matrix bot
- matrix-nio[e2e] with libolm for Megolm encryption
- Persistent crypto store volume for key persistence
- Auto-accept key verification (SAS)
- Upload device keys on first login

CF-1147

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 07:56:46 +02:00
Christian Gick
7bc7318c5b refactor: Use ElevenLabs directly for both STT and TTS
- STT: elevenlabs.STT() (Scribe) instead of Whisper via LiteLLM
- TTS: elevenlabs.TTS() (already direct)
- LLM: still routed through LiteLLM/OpenRouter
- No extra API accounts needed — only ElevenLabs + OpenRouter

CF-1147

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 07:37:44 +02:00
Christian Gick
f057acc7b2 fix: correct package version constraints + use ElevenLabs directly
- livekit-plugins-silero 1.4.x (not 0.25)
- livekit/livekit-api 1.x (not 0.x)
- Use livekit-plugins-elevenlabs directly instead of routing through LiteLLM

CF-1147

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 07:34:41 +02:00
Christian Gick
fa65fbeb3d feat: Matrix AI voice agent (LiveKit + LiteLLM)
Bot @ai:agiliton.eu accepts room invites, dispatches LiveKit agent.
Agent joins call with STT (Groq Whisper) → LLM (Sonnet) → TTS (ElevenLabs)
pipeline, all routed through LiteLLM.

CF-1147

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 07:31:52 +02:00