Introduce a shared ConversationService (steward/bot/core.py) that owns the LLM call, history, knowledge-base search, and thread-memory keying behind a normalized ThreadKey, so both Telegram and Matrix drive the same pipeline. - Add steward/bot/matrix.py: a mautrix-python appservice bot that receives Synapse transactions and replies via the client-server API. - Refactor telegram.py handlers into thin wrappers over ConversationService. - Generalize ThreadMemoryStore/ThreadSummary to platform-scoped keys with legacy chat_id:thread_id migration. - Add a matrix config section (homeserver, tokens, room/user allowlists). - Rewrite main.py as async, starting Telegram and/or Matrix on one event loop. - Add mautrix>=0.21.0 dependency. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
25 lines
673 B
Python
25 lines
673 B
Python
"""Normalised conversation identity shared across platforms and storage."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
|
|
|
|
@dataclass(frozen=True, slots=True)
|
|
class ThreadKey:
|
|
"""Normalised identity of a conversation scope across platforms.
|
|
|
|
``platform`` is ``"telegram"`` or ``"matrix"``. ``scope`` is the chat/room/user
|
|
identifier as a string. ``thread`` is an optional sub-thread identifier.
|
|
"""
|
|
|
|
platform: str
|
|
scope: str
|
|
thread: str | None = None
|
|
|
|
def __str__(self) -> str:
|
|
parts = [self.platform, self.scope]
|
|
if self.thread:
|
|
parts.append(self.thread)
|
|
return ":".join(parts)
|