Matrix Server Management
Overview
This skill allows you to manage the Tuwunel Matrix Homeserver. Tuwunel is a conduwuit fork running at http://127.0.0.1:6167. Access the server directly (not through the Higress gateway).
Environment Variables
These environment variables are pre-configured in the Manager container:
CODEBLOCK0
No need to set defaults - these are always available in the container environment.
User Registration
Tuwunel uses single-step registration with a registration token (no UIAA flow).
Register a New User
CODEBLOCK1
Response includes user_id and access_token.
Login (Get Access Token)
CODEBLOCK2
Response: INLINECODE3
Room Management
Create a Room (3-party: Human + Manager + Worker)
When creating a Worker, always create a Room with the human admin, Manager, and Worker. Use trusted_private_chat preset so all invited members are auto-joined (no invite acceptance needed), and override power levels so Admin + Manager get 100 (admin) while Workers get 0 (regular user):
CODEBLOCK3
Response: INLINECODE5
Power levels: trusted_private_chat auto-joins all invited members (no invite acceptance needed). power_level_content_override ensures Admin (100) and Manager (100) have admin rights while Workers are explicitly set to 0 (regular user).
Send a Message in a Room
Simple message (no mention):
CODEBLOCK4
Send a Message with @Mention (Critical for Workers)
IMPORTANT: When sending messages to Workers in group rooms, you MUST include the m.mentions field for them to receive the message. Workers have requireMention: true enabled, meaning they only process messages that properly @mention them.
CODEBLOCK5
CODEBLOCK6
Rules for @mentions:
- - The
user_ids array in m.mentions MUST contain the full Matrix user ID (e.g., @alice:matrix-local.hiclaw.io:8080) - The user ID in the body text and in
m.mentions.user_ids must match exactly - Without
m.mentions, Workers will receive the message but will NOT process it (it will be ignored) - This follows Matrix MSC3952 (Intentional Mentions) specification
Upload a File (Media Upload)
Use this to send files to the admin — task output artifacts, generated reports, config exports, log files, etc.
CODEBLOCK7
Response: INLINECODE15
After uploading, send the mxc:// URI to the admin as a Matrix message using the m.file (or m.image / m.text) msgtype:
CODEBLOCK8
Then reply in the conversation with:
CODEBLOCK9
Notes:
- - Use
Content-Type: text/plain for plain text files, application/octet-stream as a safe fallback for any binary - The
mxc:// URI is permanent and accessible to all room members via the Matrix client (Element Web)
List Joined Rooms
CODEBLOCK10
Get Room Messages
CODEBLOCK11
Important Notes
- - Environment prefix: Tuwunel uses
CONDUWUIT_ environment variable prefix (NOT TUWUNEL_) - Server name: Set in
CONDUWUIT_SERVER_NAME, usually INLINECODE26 - User ID format: INLINECODE27
- Registration token: Stored in
HICLAW_REGISTRATION_TOKEN env var - Direct access: Use
http://127.0.0.1:6167 for server management (not through Higress Gateway port 8080)
Matrix 服务器管理
概述
本技能允许您管理 Tuwunel Matrix 家庭服务器。Tuwunel 是一个 conduwuit 分支,运行在 http://127.0.0.1:6167。直接访问服务器(不通过 Higress 网关)。
环境变量
以下环境变量已预配置在 Manager 容器中:
bash
核心配置(由 hiclaw-install.sh 设置)
HICLAW
MATRIXDOMAIN # Matrix 服务器域名(例如 matrix-local.hiclaw.io:8080)
HICLAW
ADMINUSER # 管理员用户名
HICLAW
REGISTRATIONTOKEN # 用于注册新 Matrix 用户的令牌
HICLAW
MANAGERPASSWORD # Manager 的 Matrix 密码(用于登录)
无需设置默认值——这些变量始终在容器环境中可用。
用户注册
Tuwunel 使用单步注册,需要注册令牌(无 UIAA 流程)。
注册新用户
bash
curl -X POST http://127.0.0.1:6167/_matrix/client/v3/register \
-H Content-Type: application/json \
-d {
username: <用户名>,
password: <密码>,
auth: {
type: m.login.registration_token,
token: ${HICLAWREGISTRATIONTOKEN}
}
}
响应包含 userid 和 accesstoken。
登录(获取访问令牌)
bash
curl -X POST http://127.0.0.1:6167/_matrix/client/v3/login \
-H Content-Type: application/json \
-d {
type: m.login.password,
identifier: {type: m.id.user, user: <用户名>},
password: <密码>
}
响应:{accesstoken: ..., userid: @<用户名>:<域名>, ...}
房间管理
创建房间(三方:人类 + Manager + Worker)
创建 Worker 时,始终创建一个包含人类管理员、Manager 和 Worker 的房间。使用 trustedprivatechat 预设,使所有被邀请的成员自动加入(无需接受邀请),并覆盖权限级别,使 Admin 和 Manager 获得 100(管理员权限),而 Worker 获得 0(普通用户):
bash
MANAGERTOKEN=access_token>
curl -X POST http://127.0.0.1:6167/_matrix/client/v3/createRoom \
-H Authorization: Bearer ${MANAGER_TOKEN} \
-H Content-Type: application/json \
-d {
name: Worker: ,
topic: 的通信频道,
invite: [
@${HICLAWADMINUSER}:${HICLAWMATRIXDOMAIN},
@NAME>:${HICLAWMATRIX_DOMAIN}
],
preset: trustedprivatechat,
powerlevelcontent_override: {
users: {
@manager:${HICLAWMATRIXDOMAIN}: 100,
@${HICLAWADMINUSER}:${HICLAWMATRIXDOMAIN}: 100,
@NAME>:${HICLAWMATRIX_DOMAIN}: 0
}
}
}
响应:{room_id: !:<域名>}
权限级别: trustedprivatechat 预设使所有被邀请的成员自动加入(无需接受邀请)。powerlevelcontent_override 确保 Admin(100)和 Manager(100)拥有管理员权限,而 Worker 明确设置为 0(普通用户)。
在房间中发送消息
简单消息(无提及):
bash
curl -X PUT http://127.0.0.1:6167/_matrix/client/v3/rooms/<房间ID>/send/m.room.message/$(date +%s) \
-H Authorization: Bearer ${MANAGER_TOKEN} \
-H Content-Type: application/json \
-d {
msgtype: m.text,
body: 您好,这是一条通用公告...
}
发送带 @提及 的消息(对 Worker 至关重要)
重要提示:在群组房间中向 Worker 发送消息时,必须包含 m.mentions 字段,否则 Worker 无法收到消息。Worker 已启用 requireMention: true,这意味着它们只处理正确 @提及 它们的消息。
bash
提及单个用户
curl -X PUT http://127.0.0.1:6167/_matrix/client/v3/rooms/<房间ID>/send/m.room.message/$(date +%s) \
-H Authorization: Bearer ${MANAGER_TOKEN} \
-H Content-Type: application/json \
-d {
msgtype: m.text,
body: @
NAME>:${HICLAWMATRIX_DOMAIN} 您的任务分配:...,
m.mentions: {
userids: [@NAME>:${HICLAWMATRIXDOMAIN}]
}
}
bash
提及多个用户
curl -X PUT http://127.0.0.1:6167/_matrix/client/v3/rooms/<房间ID>/send/m.room.message/$(date +%s) \
-H Authorization: Bearer ${MANAGER_TOKEN} \
-H Content-Type: application/json \
-d {
msgtype: m.text,
body: @alice:${HICLAWMATRIXDOMAIN} 和 @bob:${HICLAWMATRIXDOMAIN} 请协调完成此任务...,
m.mentions: {
user_ids: [
@alice:${HICLAWMATRIXDOMAIN},
@bob:${HICLAWMATRIXDOMAIN}
]
}
}
@提及 规则:
- - m.mentions 中的 userids 数组必须包含完整的 Matrix 用户 ID(例如 @alice:matrix-local.hiclaw.io:8080)
- 正文文本中的用户 ID 和 m.mentions.user
ids 中的用户 ID 必须完全匹配如果没有 m.mentions,Worker 会收到消息但不会处理(将被忽略)这遵循 Matrix MSC3952(意向性提及)规范
上传文件(媒体上传)
用于向管理员发送文件——任务输出工件、生成的报告、配置导出、日志文件等。
bash
curl -X POST http://127.0.0.1:6167/_matrix/media/v3/upload?filename=<文件名> \
-H Authorization: Bearer ${MANAGER_TOKEN} \
-H Content-Type: application/octet-stream \
--data-binary @/path/to/file
响应:{content_uri: mxc://<服务器>/<媒体ID>}
上传后,使用 m.file(或 m.image / m.text)消息类型将 mxc:// URI 作为 Matrix 消息发送给管理员:
bash
curl -X PUT http://127.0.0.1:6167/_matrix/client/v3/rooms/<房间ID>/send/m.room.message/$(date +%s) \
-H Authorization: Bearer ${MANAGER_TOKEN} \
-H Content-Type: application/json \
-d {
msgtype: m.file,
body: <文件名>,
url: mxc://<服务器>/<媒体ID>
}
然后在对话中回复:
MEDIA: mxc://<服务器>/<媒体ID>
注意:
- - 纯文本文件使用 Content-Type: text/plain,任何二进制文件使用 application/octet-stream 作为安全后备
- mxc:// URI 是永久性的,所有房间成员可通过 Matrix 客户端(Element Web)访问
列出已加入的房间
bash
curl -s http://127.0.0.1:6167/matrix/client/v3/joinedrooms \
-H Authorization: Bearer ${MANAGER_TOKEN} | jq
获取房间消息
bash
curl -s http://127.0.0.1:6167/_matrix/client