mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
refactor(matrix): rewrite adapter from matrix-nio to mautrix-python
Translate all nio SDK calls to mautrix equivalents while preserving the adapter structure, business logic, and all features (E2EE, reactions, threading, mention gating, text batching, media caching, voice MSC3245). Key changes: - nio.AsyncClient -> mautrix.client.Client + HTTPAPI + MemoryStateStore - Manual E2EE key management -> OlmMachine with auto key lifecycle - isinstance(resp, nio.XxxResponse) -> mautrix returns values directly - add_event_callback per type -> single ROOM_MESSAGE handler with msgtype dispatch - Room state (member_count, display_name) via async state store lookups - Upload/download return ContentURI/bytes directly (no wrapper objects)
This commit is contained in:
parent
1850747172
commit
8053d48c8d
4 changed files with 578 additions and 837 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1724,7 +1724,7 @@ class GatewayRunner:
|
|||
elif platform == Platform.MATRIX:
|
||||
from gateway.platforms.matrix import MatrixAdapter, check_matrix_requirements
|
||||
if not check_matrix_requirements():
|
||||
logger.warning("Matrix: matrix-nio not installed or credentials not set. Run: pip install 'matrix-nio[e2e]'")
|
||||
logger.warning("Matrix: mautrix not installed or credentials not set. Run: pip install 'mautrix[encryption]'")
|
||||
return None
|
||||
return MatrixAdapter(config)
|
||||
|
||||
|
|
|
|||
|
|
@ -1464,7 +1464,7 @@ _PLATFORMS = [
|
|||
" Or via API: curl -X POST https://your-server/_matrix/client/v3/login \\",
|
||||
" -d '{\"type\":\"m.login.password\",\"user\":\"@bot:server\",\"password\":\"...\"}'",
|
||||
"4. Alternatively, provide user ID + password and Hermes will log in directly",
|
||||
"5. For E2EE: set MATRIX_ENCRYPTION=true (requires pip install 'matrix-nio[e2e]')",
|
||||
"5. For E2EE: set MATRIX_ENCRYPTION=true (requires pip install 'mautrix[encryption]')",
|
||||
"6. To find your user ID: it's @username:your-server (shown in Element profile)",
|
||||
],
|
||||
"vars": [
|
||||
|
|
|
|||
|
|
@ -1925,9 +1925,9 @@ def _setup_matrix():
|
|||
save_env_value("MATRIX_ENCRYPTION", "true")
|
||||
print_success("E2EE enabled")
|
||||
|
||||
matrix_pkg = "matrix-nio[e2e]" if want_e2ee else "matrix-nio"
|
||||
matrix_pkg = "mautrix[encryption]" if want_e2ee else "mautrix"
|
||||
try:
|
||||
__import__("nio")
|
||||
__import__("mautrix")
|
||||
except ImportError:
|
||||
print_info(f"Installing {matrix_pkg}...")
|
||||
import subprocess
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue