Matrix (plugin)
Matrix is the Matrix channel plugin for Pllan. It uses the officialmatrix-js-sdk and supports DMs, rooms, threads, media, reactions, polls, location, and E2EE.
Plugin required
Matrix is a plugin and is not bundled with core Pllan. Install from npm:Setup
- Install the plugin.
- Create a Matrix account on your homeserver.
- Configure
channels.matrixwith either:homeserver+accessToken, orhomeserver+userId+password.
- Restart the gateway.
- Start a DM with the bot or invite it to a room.
- homeserver URL
- auth method: access token or password
- user ID only when you choose password auth
- optional device name
- whether to enable E2EE
- whether to configure Matrix room access now
- If Matrix auth env vars already exist for the selected account, and that account does not already have auth saved in config, the wizard offers an env shortcut and only writes
enabled: truefor that account. - When you add another Matrix account interactively, the entered account name is normalized into the account ID used in config and env vars. For example,
Ops Botbecomesops-bot. - DM allowlist prompts accept full
@user:servervalues immediately. Display names only work when live directory lookup finds one exact match; otherwise the wizard asks you to retry with a full Matrix ID. - Room allowlist prompts accept room IDs and aliases directly. They can also resolve joined-room names live, but unresolved names are only kept as typed during setup and are ignored later by runtime allowlist resolution. Prefer
!room:serveror#alias:server. - Runtime room/session identity uses the stable Matrix room ID. Room-declared aliases are only used as lookup inputs, not as the long-term session key or stable group identity.
- To resolve room names before saving them, use
pllan channels resolve --channel matrix "Project Room".
~/.pllan/credentials/matrix/.
The default account uses credentials.json; named accounts use credentials-<account>.json.
Environment variable equivalents (used when the config key is not set):
MATRIX_HOMESERVERMATRIX_ACCESS_TOKENMATRIX_USER_IDMATRIX_PASSWORDMATRIX_DEVICE_IDMATRIX_DEVICE_NAME
MATRIX_<ACCOUNT_ID>_HOMESERVERMATRIX_<ACCOUNT_ID>_ACCESS_TOKENMATRIX_<ACCOUNT_ID>_USER_IDMATRIX_<ACCOUNT_ID>_PASSWORDMATRIX_<ACCOUNT_ID>_DEVICE_IDMATRIX_<ACCOUNT_ID>_DEVICE_NAME
ops:
MATRIX_OPS_HOMESERVERMATRIX_OPS_ACCESS_TOKEN
ops-bot, use:
MATRIX_OPS_BOT_HOMESERVERMATRIX_OPS_BOT_ACCESS_TOKEN
Configuration example
This is a practical baseline config with DM pairing, room allowlist, and E2EE enabled:E2EE setup
Bot to bot rooms
By default, Matrix messages from other configured Pllan Matrix accounts are ignored. UseallowBots when you intentionally want inter-agent Matrix traffic:
allowBots: trueaccepts messages from other configured Matrix bot accounts in allowed rooms and DMs.allowBots: "mentions"accepts those messages only when they visibly mention this bot in rooms. DMs are still allowed.groups.<room>.allowBotsoverrides the account-level setting for one room.- Pllan still ignores messages from the same Matrix user ID to avoid self-reply loops.
- Matrix does not expose a native bot flag here; Pllan treats “bot-authored” as “sent by another configured Matrix account on this Pllan gateway”.
channels.matrix.accounts with per-account credentials and optional name. See Configuration reference for the shared pattern.
Verbose bootstrap diagnostics:
verify commands are concise by default (including quiet internal SDK logging) and show detailed diagnostics only with --verbose.
Use --json for full machine-readable output when scripting.
In multi-account setups, Matrix CLI commands use the implicit Matrix default account unless you pass --account <id>.
If you configure multiple named accounts, set channels.matrix.defaultAccount first or those implicit CLI operations will stop and ask you to choose an account explicitly.
Use --account whenever you want verification or device operations to target a named account explicitly:
channels.matrix.accounts.assistant.encryption.
What “verified” means
Pllan treats this Matrix device as verified only when it is verified by your own cross-signing identity. In practice,pllan matrix verify status --verbose exposes three trust signals:
Locally trusted: this device is trusted by the current client onlyCross-signing verified: the SDK reports the device as verified through cross-signingSigned by owner: the device is signed by your own self-signing key
Verified by owner becomes yes only when cross-signing verification or owner-signing is present.
Local trust by itself is not enough for Pllan to treat the device as fully verified.
What bootstrap does
pllan matrix verify bootstrap is the repair and setup command for encrypted Matrix accounts.
It does all of the following in order:
- bootstraps secret storage, reusing an existing recovery key when possible
- bootstraps cross-signing and uploads missing public cross-signing keys
- attempts to mark and cross-sign the current device
- creates a new server-side room-key backup if one does not already exist
m.login.dummy, then with m.login.password when channels.matrix.password is configured.
Use --force-reset-cross-signing only when you intentionally want to discard the current cross-signing identity and create a new one.
If you intentionally want to discard the current room-key backup and start a new backup baseline for future messages, use pllan matrix verify backup reset --yes.
Do this only when you accept that unrecoverable old encrypted history will stay unavailable.
Fresh backup baseline
If you want to keep future encrypted messages working and accept losing unrecoverable old history, run these commands in order:--account <id> to each command when you want to target a named Matrix account explicitly.
Startup behavior
Whenencryption: true, Matrix defaults startupVerification to "if-unverified".
On startup, if this device is still unverified, Matrix will request self-verification in another Matrix client,
skip duplicate requests while one is already pending, and apply a local cooldown before retrying after restarts.
Failed request attempts retry sooner than successful request creation by default.
Set startupVerification: "off" to disable automatic startup requests, or tune startupVerificationCooldownHours
if you want a shorter or longer retry window.
Startup also performs a conservative crypto bootstrap pass automatically.
That pass tries to reuse the current secret storage and cross-signing identity first, and avoids resetting cross-signing unless you run an explicit bootstrap repair flow.
If startup finds broken bootstrap state and channels.matrix.password is configured, Pllan can attempt a stricter repair path.
If the current device is already owner-signed, Pllan preserves that identity instead of resetting it automatically.
Upgrading from the previous public Matrix plugin:
- Pllan automatically reuses the same Matrix account, access token, and device identity when possible.
- Before any actionable Matrix migration changes run, Pllan creates or reuses a recovery snapshot under
~/Backups/pllan-migrations/. - If you use multiple Matrix accounts, set
channels.matrix.defaultAccountbefore upgrading from the old flat-store layout so Pllan knows which account should receive that shared legacy state. - If the previous plugin stored a Matrix room-key backup decryption key locally, startup or
pllan doctor --fixwill import it into the new recovery-key flow automatically. - If the Matrix access token changed after migration was prepared, startup now scans sibling token-hash storage roots for pending legacy restore state before giving up on the automatic backup restore.
- If the Matrix access token changes later for the same account, homeserver, and user, Pllan now prefers reusing the most complete existing token-hash storage root instead of starting from an empty Matrix state directory.
- On the next gateway start, backed-up room keys are restored automatically into the new crypto store.
- If the old plugin had local-only room keys that were never backed up, Pllan will warn clearly. Those keys cannot be exported automatically from the previous rust crypto store, so some old encrypted history may remain unavailable until recovered manually.
- See Matrix migration for the full upgrade flow, limits, recovery commands, and common migration messages.
~/.pllan/matrix/accounts/<account>/<homeserver>__<user>/<token-hash>/.
That directory contains the sync store (bot-storage.json), crypto store (crypto/),
recovery key file (recovery-key.json), IndexedDB snapshot (crypto-idb-snapshot.json),
thread bindings (thread-bindings.json), and startup verification state (startup-verification.json)
when those features are in use.
When the token changes but the account identity stays the same, Pllan reuses the best existing
root for that account/homeserver/user tuple so prior sync state, crypto state, thread bindings,
and startup verification state remain visible.
Node crypto store model
Matrix E2EE in this plugin uses the officialmatrix-js-sdk Rust crypto path in Node.
That path expects IndexedDB-backed persistence when you want crypto state to survive restarts.
Pllan currently provides that in Node by:
- using
fake-indexeddbas the IndexedDB API shim expected by the SDK - restoring the Rust crypto IndexedDB contents from
crypto-idb-snapshot.jsonbeforeinitRustCrypto - persisting the updated IndexedDB contents back to
crypto-idb-snapshot.jsonafter init and during runtime
- add SecretRef support for persistent Matrix key material so recovery keys and related store-encryption secrets can be sourced from Pllan secrets providers instead of only local files
Automatic verification notices
Matrix now posts verification lifecycle notices directly into the strict DM verification room asm.notice messages.
That includes:
- verification request notices
- verification ready notices (with explicit “Verify by emoji” guidance)
- verification start and completion notices
- SAS details (emoji and decimal) when available
NO_REPLY.
Device hygiene
Old Pllan-managed Matrix devices can accumulate on the account and make encrypted-room trust harder to reason about. List them with:Direct Room Repair
If direct-message state gets out of sync, Pllan can end up with stalem.direct mappings that point at old solo rooms instead of the live DM. Inspect the current mapping for a peer with:
- it prefers a strict 1:1 DM that is already mapped in
m.direct - otherwise it falls back to any currently joined strict 1:1 DM with that user
- if no healthy DM exists, it creates a fresh direct room and rewrites
m.directto point at it
Threads
Matrix supports native Matrix threads for both automatic replies and message-tool sends.threadReplies: "off"keeps replies top-level.threadReplies: "inbound"replies inside a thread only when the inbound message was already in that thread.threadReplies: "always"keeps room replies in a thread rooted at the triggering message.- Inbound threaded messages include the thread root message as extra agent context.
- Message-tool sends now auto-inherit the current Matrix thread when the target is the same room, or the same DM user target, unless an explicit
threadIdis provided. - Runtime thread bindings are supported for Matrix.
/focus,/unfocus,/agents,/session idle,/session max-age, and thread-bound/acp spawnnow work in Matrix rooms and DMs. - Top-level Matrix room/DM
/focuscreates a new Matrix thread and binds it to the target session whenthreadBindings.spawnSubagentSessions=true. - Running
/focusor/acp spawn --thread hereinside an existing Matrix thread binds that current thread instead.
Thread Binding Config
Matrix inherits global defaults fromsession.threadBindings, and also supports per-channel overrides:
threadBindings.enabledthreadBindings.idleHoursthreadBindings.maxAgeHoursthreadBindings.spawnSubagentSessionsthreadBindings.spawnAcpSessions
- Set
threadBindings.spawnSubagentSessions: trueto allow top-level/focusto create and bind new Matrix threads. - Set
threadBindings.spawnAcpSessions: trueto allow/acp spawn --thread auto|hereto bind ACP sessions to Matrix threads.
Reactions
Matrix supports outbound reaction actions, inbound reaction notifications, and inbound ack reactions.- Outbound reaction tooling is gated by
channels["matrix"].actions.reactions. reactadds a reaction to a specific Matrix event.reactionslists the current reaction summary for a specific Matrix event.emoji=""removes the bot account’s own reactions on that event.remove: trueremoves only the specified emoji reaction from the bot account.
channels["matrix"].accounts.<accountId>.ackReactionchannels["matrix"].ackReactionmessages.ackReaction- agent identity emoji fallback
channels["matrix"].accounts.<accountId>.ackReactionScopechannels["matrix"].ackReactionScopemessages.ackReactionScope
channels["matrix"].accounts.<accountId>.reactionNotificationschannels["matrix"].reactionNotifications- default:
own
reactionNotifications: "own"forwards addedm.reactionevents when they target bot-authored Matrix messages.reactionNotifications: "off"disables reaction system events.- Reaction removals are still not synthesized into system events because Matrix surfaces those as redactions, not as standalone
m.reactionremovals.
DM and room policy example
Multi-account example
channels.matrix values act as defaults for named accounts unless an account overrides them.
Set defaultAccount when you want Pllan to prefer one named Matrix account for implicit routing, probing, and CLI operations.
If you configure multiple named accounts, set defaultAccount or pass --account <id> for CLI commands that rely on implicit account selection.
Pass --account <id> to pllan matrix verify ... and pllan matrix devices ... when you want to override that implicit selection for one command.
Private/LAN homeservers
By default, Pllan blocks private/internal Matrix homeservers for SSRF protection unless you explicitly opt in per account. If your homeserver runs on localhost, a LAN/Tailscale IP, or an internal hostname, enableallowPrivateNetwork for that Matrix account:
http://matrix.example.org:8008 remain blocked. Prefer https:// whenever possible.
Target resolution
Matrix accepts these target forms anywhere Pllan asks you for a room or user target:- Users:
@user:server,user:@user:server, ormatrix:user:@user:server - Rooms:
!room:server,room:!room:server, ormatrix:room:!room:server - Aliases:
#alias:server,channel:#alias:server, ormatrix:channel:#alias:server
- User lookups query the Matrix user directory on that homeserver.
- Room lookups accept explicit room IDs and aliases directly, then fall back to searching joined room names for that account.
- Joined-room name lookup is best-effort. If a room name cannot be resolved to an ID or alias, it is ignored by runtime allowlist resolution.
Configuration reference
enabled: enable or disable the channel.name: optional label for the account.defaultAccount: preferred account ID when multiple Matrix accounts are configured.homeserver: homeserver URL, for examplehttps://matrix.example.org.allowPrivateNetwork: allow this Matrix account to connect to private/internal homeservers. Enable this when the homeserver resolves tolocalhost, a LAN/Tailscale IP, or an internal host such asmatrix-synapse.userId: full Matrix user ID, for example@bot:example.org.accessToken: access token for token-based auth.password: password for password-based login.deviceId: explicit Matrix device ID.deviceName: device display name for password login.avatarUrl: stored self-avatar URL for profile sync andset-profileupdates.initialSyncLimit: startup sync event limit.encryption: enable E2EE.allowlistOnly: force allowlist-only behavior for DMs and rooms.groupPolicy:open,allowlist, ordisabled.groupAllowFrom: allowlist of user IDs for room traffic.groupAllowFromentries should be full Matrix user IDs. Unresolved names are ignored at runtime.replyToMode:off,first, orall.threadReplies:off,inbound, oralways.threadBindings: per-channel overrides for thread-bound session routing and lifecycle.startupVerification: automatic self-verification request mode on startup (if-unverified,off).startupVerificationCooldownHours: cooldown before retrying automatic startup verification requests.textChunkLimit: outbound message chunk size.chunkMode:lengthornewline.responsePrefix: optional message prefix for outbound replies.ackReaction: optional ack reaction override for this channel/account.ackReactionScope: optional ack reaction scope override (group-mentions,group-all,direct,all,none,off).reactionNotifications: inbound reaction notification mode (own,off).mediaMaxMb: outbound media size cap in MB.autoJoin: invite auto-join policy (always,allowlist,off). Default:off.autoJoinAllowlist: rooms/aliases allowed whenautoJoinisallowlist. Alias entries are resolved to room IDs during invite handling; Pllan does not trust alias state claimed by the invited room.dm: DM policy block (enabled,policy,allowFrom).dm.allowFromentries should be full Matrix user IDs unless you already resolved them through live directory lookup.accounts: named per-account overrides. Top-levelchannels.matrixvalues act as defaults for these entries.groups: per-room policy map. Prefer room IDs or aliases; unresolved room names are ignored at runtime. Session/group identity uses the stable room ID after resolution, while human-readable labels still come from room names.rooms: legacy alias forgroups.actions: per-action tool gating (messages,reactions,pins,profile,memberInfo,channelInfo,verification).