No description
  • Rust 91.5%
  • HTML 8.5%
Find a file
mik-tf 635619b6c4
Some checks failed
CI / build (push) Failing after 3s
chore: D-10 closure — service.toml + service_base!() across 3 binaries
hero_proc#102 D-10 sweep (T2, s115). Wires hero_matrixchat fully to the
canonical service.toml + service_base!() + handle_info_flag contract across
all three service binaries (hero_matrixchat, hero_matrixchat_server,
hero_matrixchat_admin). Pairs the home#228/#230 web.sock → admin.sock
flip in the same commit (per s112 hero_wallet precedent) — completes the
home#230 Phase 1 surface for this repo.

- service.toml at every binary crate root, all three list the same
  3-binary set and ship [[env]] PATH_ROOT default="~/hero" per s107
  lesson #17. CLI service.toml carries the canonical hero_proc dependency
  declaration; daemon service.tomls carry their per-binary socket
  descriptors (rpc.sock on the server, admin.sock on the admin).

- main.rs wired via herolib_core::service_base!() + validate_service_toml
  + handle_info_flag in all three; server + admin also call
  print_startup_banner + prepare_sockets. Old hand-rolled
  print_startup_info/print_info_json/print_help blocks deleted from all
  three (net -140 lines vs +234 inserts across the diff).

- web.sock → admin.sock rename paired with D-10 (s112 precedent):
  hero_matrixchat_sdk::ui_socket_path() → admin_socket_path() (only the
  function name and the trailing path segment change; no external
  consumers workspace-wide); CLI build_service_definition() ui_action
  threads hero_matrixchat/admin.sock into kill_other + health_check;
  admin/main.rs binds via hero_admin_lib::socket::bind_admin_socket
  against the canonical admin.sock path. Crate name was already _admin
  (post-s58); this commit completes the rename.

- Lesson #19 wired: CLI build_service_definition() threads
  PATH_ROOT/PATH_VAR/PATH_BUILD/PATH_CODE/HERO_SOCKET_DIR via
  forward_env_if_set into both spawned ActionSpecs. Under `lab service
  --start`, lab injects PATH_ROOT from the [[env]] block directly; the
  CLI path uses forward_env_if_set as the safety net for the
  `hero_matrixchat --start` invocation route (matches s109/s111/s112).
  Verified PATH_ROOT in /proc/$pid/environ for both daemons.

- cargo update absorbs the 5-package cascade picked up since s113:
  hero_proc_sdk ceaea08b→5abe6644, hero_rpc_derive/openrpc
  a167051f→8a8d66d8, herolib_core/derive 7a6258ef→d20792fd. Workspace
  pins remain on v0.6.0; no version bumps needed.

- Dep audit strips 12 zero-match entries: CLI drops tracing +
  tracing-core (HeroTracingLayer dropped from the short-lived CLI; daemons
  keep theirs); server drops futures + tower-http + http-body-util; admin
  drops http-body-util + hyper + hyper-util + tower + serde + serde_json
  + dirs (admin's lib.rs uses only axum + hero_admin_lib + std).

- HeroLogger lesson #21 N/A here: hero_matrixchat never depended on the
  deleted hero_proc_sdk::HeroLogger. Both daemons keep their existing
  herolib_core::logger::Logger + custom HeroTracingLayer wiring for
  structured-log shipping intact.

D-10 acceptance: 5/5 met.
1. 3 service.toml at canonical paths ✓
2. service_base!() + validate_service_toml + handle_info_flag triad on
   all 3 main.rs ✓
3. lab infocheck: 3 crate(s) clean, 0 findings ✓
4. Smoke 6/6 (server 4/4 on rpc.sock + admin 2/2 on admin.sock) ✓
5. cargo test --workspace --release: 0 passed / 0 failed (no tests
   in repo); cargo build --workspace --release: clean / 0 warnings ✓

Latent (out of D-10 scope, will track in #102#33220 follow-ups):
- OServer stop-timeout-but-exits pattern: lab service hero_matrixchat_*
  --stop reports 30s timeout, daemons DO exit, sockets ARE cleaned this
  time (cleaner than s110-s113). Same shape as s110-s114; out of D-10
  scope.

Signed-off-by: mik-tf
2026-05-18 14:52:05 -04:00
.forgejo/workflows ci: add release pipeline + reqwest→rustls (cluster E port) (#5) 2026-05-05 00:17:10 +00:00
.hero chore: update deps, add build artifacts, fix serde version pins 2026-05-10 14:02:37 +02:00
crates chore: D-10 closure — service.toml + service_base!() across 3 binaries 2026-05-18 14:52:05 -04:00
.gitignore Initial scaffold 2026-02-22 10:34:11 +03:00
Cargo.lock chore: D-10 closure — service.toml + service_base!() across 3 binaries 2026-05-18 14:52:05 -04:00
Cargo.toml chore: migrate to hero_admin_lib shared assets 2026-05-10 16:19:58 +02:00
Cargo.toml.hero_builder_backup chore: update deps, add build artifacts, fix serde version pins 2026-05-10 14:02:37 +02:00
PURPOSE.md refactor: rename hero_matrixchat_ui -> hero_matrixchat_admin (ui.sock -> admin.sock) 2026-05-07 16:57:43 -04:00
README.md refactor: rename hero_matrixchat_ui -> hero_matrixchat_admin (ui.sock -> admin.sock) 2026-05-07 16:57:43 -04:00

Hero MatrixChat

Admin toolkit for Matrix homeservers. Connect to one or more Matrix servers (Conduit, Synapse, Dendrite, etc.) through profile-based configuration and manage users, rooms, spaces, and messages from a single CLI, web dashboard, or JSON-RPC API.

What it does

  • Multi-profile — define any number of Matrix server connections in ~/hero/cfg/matrix/*.toml, switch between them from the CLI (--profile) or the UI dropdown
  • User management — list, create, delete users and reset passwords via the Matrix CS API
  • Room & space management — list public/joined rooms, create rooms and spaces, inspect state, manage members
  • Messaging — send and retrieve messages, typing notifications, sync
  • Server monitoring — health checks, server version, user/room counts per profile
  • Web dashboard — Bootstrap 5 dark-themed admin UI at http://127.0.0.1:3790 with live profile switching
  • JSON-RPC server — all operations available over a Unix socket for tool integration
  • Rhai scripting — automate any operation from Rhai scripts

Architecture

hero_matrixchat/
├── crates/
│   ├── hero_matrixchat_sdk/       # SDK: MatrixClient (CS API), ProfileManager, types
│   ├── hero_matrixchat_server/    # JSON-RPC daemon on Unix socket
│   ├── hero_matrixchat/           # CLI
│   ├── hero_matrixchat_admin/        # Axum web dashboard
│   └── hero_matrixchat_rhai/      # Rhai scripting bindings

~/hero/cfg/matrix/                 # Profile configs (one .toml per server)
~/hero/var/sockets/                # Unix sockets for server + UI

All four binaries depend only on the SDK crate:

hero_matrixchat_sdk
     ↑    ↑    ↑    ↑
  server  CLI  UI  rhai

The SDK talks directly to Matrix servers over HTTP using the Client-Server API — no custom protocol involved.

Quick start

# 1. Create a profile (assumes a Matrix server on localhost:6167)
mkdir ~/hero/cfg/matrix
"server_url = \"http://127.0.0.1:6167\"\nusername = \"@admin:localhost\"\npassword = \"admin_password\"\nregistration_token = \"conduit_dev_token\"\n" | save ~/hero/cfg/matrix/local.toml

# 2. Start (builds and installs automatically on first run)
service matrixchat start --update --reset

# 3. Stop / reset
service matrixchat stop
service matrixchat start --update --reset

If no profile files exist, an implicit local profile pointing to 127.0.0.1:6167 is created automatically.

CLI usage

hero_matrixchat health                     # check server connectivity
hero_matrixchat users list                 # list users on default profile
hero_matrixchat --profile work users list  # list users on "work" profile
hero_matrixchat users create --username alice --password secret
hero_matrixchat rooms list
hero_matrixchat send --room-id '!abc:example.com' --message "hello"
hero_matrixchat messages --room-id '!abc:example.com' --limit 20
hero_matrixchat stats
hero_matrixchat profiles list

Profile configuration

Each .toml file in ~/hero/cfg/matrix/ defines one Matrix server connection. The filename (without extension) becomes the profile name.

# ~/hero/cfg/matrix/work.toml
server_url = "https://matrix.example.com"
username = "@admin:example.com"
password = "secret"
registration_token = "optional_registration_token"
Field Required Description
server_url yes Base URL of the Matrix server
username yes Matrix user ID or local part
password yes Password for login
registration_token no Token for creating new users via the registration API

Ports and sockets

Component Socket Path
hero_matrixchat_server rpc.sock $HERO_SOCKET_DIR/hero_matrixchat/rpc.sock
hero_matrixchat_admin web.sock $HERO_SOCKET_DIR/hero_matrixchat/web.sock

JSON-RPC methods

All methods accept an optional profile parameter. When omitted, the first profile (alphabetically) is used.

Method Description
health Server version, reachability, server name
list_users Search the user directory
create_user Register a new user
delete_user Deactivate a user
reset_password Reset a user's password
list_rooms Public and joined rooms with member counts
send_message Send a text message to a room
get_messages Retrieve messages from a room
server_stats Aggregate stats (user count, room count, version)
list_profiles Available profile names
get_config Read server-level configuration
update_config Write server-level configuration

Service management (nushell — preferred)

service matrixchat start --update --reset   # build, install, and start
service matrixchat stop                      # stop all service processes
service matrixchat status                    # show running state

Make targets (legacy — kept for CI compatibility)

make help           Show all targets
make build          Build all crates (release)
make check          Fast workspace check (no build)
make test           Unit tests
make test-integration  SDK integration tests (needs running Matrix server)
make test-all       Full test suite
make fmt            Format code
make lint           Run clippy
make install        Build and install to ~/hero/bin

Testing

Integration tests talk directly to a Matrix server via the CS API — they register users, create rooms and spaces, send messages, and verify everything round-trips correctly.

# Requires a Matrix server on 127.0.0.1:6167 with registration enabled
make test-integration

# Unit tests only (no server required)
make test

# Everything
make test-all