Documentation
¶
Overview ¶
Package mtx provides a standalone Matrix messaging CLI for agentic coordination.
Index ¶
- Variables
- func Execute() error
- func ResolveRoomID(arg string, resolve AliasResolver) (string, error)
- func ServerName(homeserver string) string
- func TokenFromEnv() (string, error)
- type AliasResolver
- type AliasResponse
- type Authenticator
- type Client
- func (c *Client) CreateDMRoom(invite string) (*Room, error)
- func (c *Client) CreateRoom(name, topic string) (*Room, error)
- func (c *Client) CreateRoomWithAlias(name, topic, aliasName string) (*Room, error)
- func (c *Client) EventContext(roomID, eventID string) (string, error)
- func (c *Client) GetDirectRooms(userID string) (map[string][]string, error)
- func (c *Client) GetPresence(userID string) (*PresenceResponse, error)
- func (c *Client) GetProfile(userID string) error
- func (c *Client) GetRoomInfo(roomID string) (*RoomInfo, error)
- func (c *Client) Invite(roomID, userID string) error
- func (c *Client) Join(roomIDOrAlias string) (string, error)
- func (c *Client) JoinedRooms() (*JoinedRooms, error)
- func (c *Client) Leave(roomID string) error
- func (c *Client) Login(username, password string) (*Registration, error)
- func (c *Client) Members(roomID string) ([]Member, error)
- func (c *Client) Messages(roomID string, limit int) (*Messages, error)
- func (c *Client) MessagesFrom(roomID, from string, limit int, dir string) (*Messages, error)
- func (c *Client) PublicRooms() (*PublicRoomsResponse, error)
- func (c *Client) Register(username, password, token string) (*Registration, error)
- func (c *Client) ResolveAlias(alias string) (*AliasResponse, error)
- func (c *Client) Send(roomID, message string) (string, error)
- func (c *Client) SetDirectRooms(userID string, rooms map[string][]string) error
- func (c *Client) SetRoomAlias(alias, roomID string) error
- func (c *Client) Sync(ctx context.Context, since string, timeout int, roomID string) (*SyncResponse, error)
- func (c *Client) WhoAmI() (*WhoAmIResponse, error)
- type Config
- type DMRoomCreator
- type EventContextGetter
- type Inviter
- type JoinedRooms
- type Member
- type MemberLister
- type Message
- type MessageFromReader
- type MessageReader
- type MessageSender
- type Messages
- type PresenceResponse
- type PublicRoom
- type PublicRoomLister
- type PublicRoomsResponse
- type Registerer
- type Registration
- type Room
- type RoomCreator
- type RoomInfo
- type RoomInfoGetter
- type RoomJoiner
- type RoomLeaver
- type RoomLister
- type SyncInviteState
- type SyncInvitedRoom
- type SyncJoinedRoom
- type SyncResponse
- type SyncRooms
- type SyncTimeline
- type WhoAmIGetter
- type WhoAmIResponse
Constants ¶
This section is empty.
Variables ¶
var (
Homeserver string
)
Package-level config set via PersistentPreRunE from the loaded Config.
Functions ¶
func ResolveRoomID ¶
func ResolveRoomID(arg string, resolve AliasResolver) (string, error)
ResolveRoomID resolves a room argument that may be a room ID, full alias, or short alias name into a room ID.
func ServerName ¶
ServerName extracts the hostname from a homeserver URL.
func TokenFromEnv ¶
TokenFromEnv reads the Matrix access token. It checks MTX_TOKEN first, then walks up from CWD looking for .mtx/env files.
Types ¶
type AliasResolver ¶
type AliasResolver func(alias string) (*AliasResponse, error)
AliasResolver resolves a room alias to a room ID.
type AliasResponse ¶
AliasResponse is returned when resolving a room alias.
type Authenticator ¶
type Authenticator func(username, password string) (*Registration, error)
Authenticator logs into a Matrix account.
type Client ¶
Client performs HTTP requests against a Matrix homeserver.
func (*Client) CreateDMRoom ¶
CreateDMRoom creates a direct-message room and invites the target user. Uses trusted_private_chat preset so the invited user can join immediately.
func (*Client) CreateRoom ¶
CreateRoom creates a new Matrix room with an optional topic.
func (*Client) CreateRoomWithAlias ¶
CreateRoomWithAlias creates a room with a canonical alias.
func (*Client) EventContext ¶
EventContext returns the pagination token after a given event.
func (*Client) GetDirectRooms ¶
GetDirectRooms retrieves the m.direct account data for the user.
func (*Client) GetPresence ¶
func (c *Client) GetPresence(userID string) (*PresenceResponse, error)
GetPresence retrieves a user's presence status.
func (*Client) GetProfile ¶
GetProfile retrieves a user's profile. Returns an error if the user does not exist.
func (*Client) GetRoomInfo ¶
GetRoomInfo retrieves the name and topic for a room.
func (*Client) JoinedRooms ¶
func (c *Client) JoinedRooms() (*JoinedRooms, error)
JoinedRooms returns the list of rooms the user has joined.
func (*Client) Login ¶
func (c *Client) Login(username, password string) (*Registration, error)
Login authenticates and returns an access token.
func (*Client) MessagesFrom ¶
MessagesFrom retrieves messages starting from a pagination token.
func (*Client) PublicRooms ¶
func (c *Client) PublicRooms() (*PublicRoomsResponse, error)
PublicRooms returns public rooms on the server.
func (*Client) Register ¶
func (c *Client) Register(username, password, token string) (*Registration, error)
Register creates a new Matrix user account.
func (*Client) ResolveAlias ¶
func (c *Client) ResolveAlias(alias string) (*AliasResponse, error)
ResolveAlias resolves a room alias to a room ID.
func (*Client) SetDirectRooms ¶
SetDirectRooms updates the m.direct account data for the user.
func (*Client) SetRoomAlias ¶
SetRoomAlias registers an alias for a room.
func (*Client) Sync ¶
func (c *Client) Sync(ctx context.Context, since string, timeout int, roomID string) (*SyncResponse, error)
Sync performs a Matrix sync request. timeout is in seconds.
func (*Client) WhoAmI ¶
func (c *Client) WhoAmI() (*WhoAmIResponse, error)
WhoAmI returns the user ID for the current access token.
type Config ¶
type Config struct {
Homeserver string `yaml:"homeserver"`
}
Config holds mtx configuration.
type DMRoomCreator ¶
DMRoomCreator creates a direct-message room with an invited user.
type EventContextGetter ¶
EventContextGetter returns a pagination token after a given event.
type JoinedRooms ¶
type JoinedRooms struct {
Rooms []string `json:"joined_rooms"`
}
JoinedRooms is returned when listing joined rooms.
type MemberLister ¶
MemberLister lists the members of a room.
type Message ¶
type Message struct {
Sender string `json:"sender"`
Type string `json:"type"`
Content map[string]interface{} `json:"content"`
EventID string `json:"event_id"`
}
Message represents a single Matrix timeline event.
type MessageFromReader ¶
MessageFromReader reads messages starting from a pagination token.
type MessageReader ¶
MessageReader reads messages from a Matrix room.
type MessageSender ¶
MessageSender sends a message to a Matrix room.
type PresenceResponse ¶
type PresenceResponse struct {
Presence string `json:"presence"`
LastActiveAgo int `json:"last_active_ago"`
CurrentlyActive bool `json:"currently_active"`
}
PresenceResponse is returned by the presence endpoint.
type PublicRoom ¶
type PublicRoom struct {
RoomID string `json:"room_id"`
Name string `json:"name"`
Topic string `json:"topic"`
CanonicalAlias string `json:"canonical_alias"`
NumJoined int `json:"num_joined_members"`
}
PublicRoom represents a room in the public room listing.
type PublicRoomLister ¶
type PublicRoomLister func() (*PublicRoomsResponse, error)
PublicRoomLister lists public rooms on the server.
type PublicRoomsResponse ¶
type PublicRoomsResponse struct {
Chunk []PublicRoom `json:"chunk"`
}
PublicRoomsResponse is the response from the public rooms endpoint.
type Registerer ¶
type Registerer func(username, password, token string) (*Registration, error)
Registerer registers a Matrix user account.
type Registration ¶
type Registration struct {
UserID string `json:"user_id"`
AccessToken string `json:"access_token"`
DeviceID string `json:"device_id"`
}
Registration is returned by register and login endpoints.
type Room ¶
type Room struct {
RoomID string `json:"room_id"`
}
Room is returned when creating a room.
type RoomCreator ¶
RoomCreator creates a Matrix room.
type RoomInfoGetter ¶
RoomInfoGetter retrieves room name and topic.
type RoomJoiner ¶
RoomJoiner joins a room by ID or alias.
type RoomLister ¶
type RoomLister func() (*JoinedRooms, error)
RoomLister lists joined Matrix rooms.
type SyncInviteState ¶
type SyncInviteState struct {
Events []Message `json:"events"`
}
SyncInviteState contains stripped state events for an invited room.
type SyncInvitedRoom ¶
type SyncInvitedRoom struct {
InviteState SyncInviteState `json:"invite_state"`
}
SyncInvitedRoom contains invite state from a sync response.
type SyncJoinedRoom ¶
type SyncJoinedRoom struct {
Timeline SyncTimeline `json:"timeline"`
}
SyncJoinedRoom contains timeline data for a joined room.
type SyncResponse ¶
SyncResponse is a simplified Matrix sync response.
type SyncRooms ¶
type SyncRooms struct {
Join map[string]SyncJoinedRoom `json:"join"`
Invite map[string]SyncInvitedRoom `json:"invite"`
}
SyncRooms contains room data from a sync response.
type SyncTimeline ¶
type SyncTimeline struct {
Events []Message `json:"events"`
}
SyncTimeline contains timeline events from a sync.
type WhoAmIGetter ¶
type WhoAmIGetter func() (*WhoAmIResponse, error)
WhoAmIGetter retrieves the current user's identity.
type WhoAmIResponse ¶
type WhoAmIResponse struct {
UserID string `json:"user_id"`
}
WhoAmIResponse is returned by the whoami endpoint.