agora.matrix.client
Thin Matrix client wrapper around matrix-nio.
Exposes a small, domain-shaped MatrixClientProtocol so tests can inject a fake
without touching the network. AgoraMatrixClient is the production implementation
that delegates to nio.AsyncClient.
Functions
|
If |
|
Map a domain event type + content to what we actually send over the wire. |
Classes
Concrete |
|
Minimal surface used by the rest of the codebase. |
|
A |
|
One batch of events returned by |
- class agora.matrix.client.MatrixClientProtocol[source]
Bases:
ProtocolMinimal surface used by the rest of the codebase.
- __init__(*args, **kwargs)
- class agora.matrix.client.NullMatrixClient[source]
Bases:
objectA
MatrixClientProtocolthat needs no homeserver.Used when the Matrix surface is switched off (
enable_observer=False): the phased runner drives a whole lifecycle with nobody watching, and demanding a live Conduit for rooms no human will ever open is a hard dependency for nothing. With this client the documented path is Python + Ollama; Conduit becomes the optional live-observation view.This is not a void. Provenance is unconditional (F3): every call is recorded to
run.logat INFO, so the record of what an agent tried to communicate survives whether or not a homeserver existed. What disappears is only the delivery to a room.Two things this deliberately does NOT do:
It does not fake a human. Tools that block on a person (
request_review,await_user_decision) must fail LOUDLY rather than receive a synthetic answer — a fabricated approval is worse than no approval. Those tools checkToolContext.matrix_liveand refuse; the client never invents a vote.It does not silently swallow. Room ids and event ids are synthetic but marked (
!null-…/$null-…), so anything that logs or asserts on them shows plainly that no room existed.
- class agora.matrix.client.SyncBatch[source]
Bases:
objectOne batch of events returned by
sync_once.eventsis a list of(room_id, event_dict)tuples, each shaped like a raw Matrix timeline event (type,event_id,sender,content, optionalstate_key).next_sinceis the token to pass to the nextsync_oncecall.- __init__(events, next_since)
- class agora.matrix.client.AgoraMatrixClient[source]
Bases:
objectConcrete
MatrixClientProtocolbacked bynio.AsyncClient.- async send_event(room_id, event_type, content)[source]
Post a timeline event.
Some homeservers (notably Conduit) reject custom event types in
/sendwith HTTP 500. We wrap any non-m.room.*type into anm.room.messageenvelope withcom.agora.type/com.agora.datafor loss-free round-trip.unwrap_envelope()on the read side restores the original type.
- async download_file(mxc_uri, dest_dir)[source]
Download an
mxc://URI intodest_dirand return the local path.Caches by a hash of the MXC URI; subsequent calls with the same URI return the cached path without re-downloading.
- agora.matrix.client.wrap_for_homeserver(event_type, content)[source]
Map a domain event type + content to what we actually send over the wire.
Only Agora’s own custom events (
m.agora.*) are wrapped in anm.room.messageenvelope — those are the ones Conduit rejects with HTTP 500. Every other event type (m.room.*,m.poll.*,m.reaction,m.space.*, …) is Matrix-spec and passes through so native clients like Element render them correctly.