@gakr-gakr/matrix 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/CHANGELOG.md +285 -0
  2. package/SPEC-SUPPORT.md +116 -0
  3. package/api.ts +38 -0
  4. package/auth-presence.ts +56 -0
  5. package/autobot.plugin.json +28 -0
  6. package/channel-plugin-api.ts +3 -0
  7. package/cli-metadata.ts +11 -0
  8. package/contract-api.ts +17 -0
  9. package/doctor-contract-api.ts +1 -0
  10. package/helper-api.ts +3 -0
  11. package/index.ts +55 -0
  12. package/package.json +101 -0
  13. package/plugin-entry.handlers.runtime.ts +1 -0
  14. package/runtime-api.ts +72 -0
  15. package/runtime-heavy-api.ts +1 -0
  16. package/runtime-setter-api.ts +3 -0
  17. package/secret-contract-api.ts +5 -0
  18. package/setup-entry.ts +17 -0
  19. package/setup-plugin-api.ts +3 -0
  20. package/src/account-selection.ts +223 -0
  21. package/src/actions.ts +346 -0
  22. package/src/approval-auth.ts +25 -0
  23. package/src/approval-handler.runtime.ts +595 -0
  24. package/src/approval-ids.ts +6 -0
  25. package/src/approval-native.ts +348 -0
  26. package/src/approval-reaction-auth.ts +45 -0
  27. package/src/approval-reactions.ts +313 -0
  28. package/src/auth-precedence.ts +61 -0
  29. package/src/channel-account-paths.ts +97 -0
  30. package/src/channel.runtime.ts +17 -0
  31. package/src/channel.setup.ts +48 -0
  32. package/src/channel.ts +667 -0
  33. package/src/cli-metadata.ts +19 -0
  34. package/src/cli.ts +2298 -0
  35. package/src/config-adapter.ts +41 -0
  36. package/src/config-schema.ts +159 -0
  37. package/src/config-ui-hints.ts +56 -0
  38. package/src/directory-live.ts +238 -0
  39. package/src/doctor-contract.ts +287 -0
  40. package/src/doctor.ts +262 -0
  41. package/src/env-vars.ts +92 -0
  42. package/src/exec-approval-resolver.ts +23 -0
  43. package/src/exec-approvals.ts +293 -0
  44. package/src/group-mentions.ts +41 -0
  45. package/src/legacy-crypto-inspector-availability.ts +60 -0
  46. package/src/legacy-crypto.ts +531 -0
  47. package/src/legacy-state.ts +156 -0
  48. package/src/matrix/account-config.ts +175 -0
  49. package/src/matrix/accounts.ts +194 -0
  50. package/src/matrix/actions/client.ts +31 -0
  51. package/src/matrix/actions/devices.ts +34 -0
  52. package/src/matrix/actions/limits.ts +6 -0
  53. package/src/matrix/actions/messages.ts +129 -0
  54. package/src/matrix/actions/pins.ts +63 -0
  55. package/src/matrix/actions/polls.ts +109 -0
  56. package/src/matrix/actions/profile.ts +37 -0
  57. package/src/matrix/actions/reactions.ts +59 -0
  58. package/src/matrix/actions/room.ts +71 -0
  59. package/src/matrix/actions/summary.ts +88 -0
  60. package/src/matrix/actions/types.ts +63 -0
  61. package/src/matrix/actions/verification.ts +589 -0
  62. package/src/matrix/actions.ts +37 -0
  63. package/src/matrix/active-client.ts +26 -0
  64. package/src/matrix/async-lock.ts +18 -0
  65. package/src/matrix/backup-health.ts +124 -0
  66. package/src/matrix/client/config-runtime-api.ts +9 -0
  67. package/src/matrix/client/config-secret-input.runtime.ts +1 -0
  68. package/src/matrix/client/config.ts +853 -0
  69. package/src/matrix/client/create-client.ts +105 -0
  70. package/src/matrix/client/env-auth.ts +95 -0
  71. package/src/matrix/client/file-sync-store.ts +289 -0
  72. package/src/matrix/client/logging.ts +140 -0
  73. package/src/matrix/client/migration-snapshot.runtime.ts +1 -0
  74. package/src/matrix/client/private-network-host.ts +1 -0
  75. package/src/matrix/client/runtime.ts +4 -0
  76. package/src/matrix/client/shared.ts +316 -0
  77. package/src/matrix/client/storage.ts +543 -0
  78. package/src/matrix/client/types.ts +50 -0
  79. package/src/matrix/client/url-validation.ts +76 -0
  80. package/src/matrix/client-bootstrap.ts +173 -0
  81. package/src/matrix/client.ts +23 -0
  82. package/src/matrix/config-paths.ts +31 -0
  83. package/src/matrix/config-update.ts +292 -0
  84. package/src/matrix/credentials-read.ts +207 -0
  85. package/src/matrix/credentials-write.runtime.ts +35 -0
  86. package/src/matrix/credentials.ts +95 -0
  87. package/src/matrix/deps.ts +309 -0
  88. package/src/matrix/device-health.ts +31 -0
  89. package/src/matrix/direct-management.ts +349 -0
  90. package/src/matrix/direct-room.ts +128 -0
  91. package/src/matrix/draft-stream.ts +225 -0
  92. package/src/matrix/encryption-guidance.ts +24 -0
  93. package/src/matrix/errors.ts +21 -0
  94. package/src/matrix/format.ts +426 -0
  95. package/src/matrix/legacy-crypto-inspector.ts +95 -0
  96. package/src/matrix/media-errors.ts +20 -0
  97. package/src/matrix/media-text.ts +162 -0
  98. package/src/matrix/monitor/access-state.ts +145 -0
  99. package/src/matrix/monitor/ack-config.ts +27 -0
  100. package/src/matrix/monitor/allowlist.ts +92 -0
  101. package/src/matrix/monitor/auto-join.ts +86 -0
  102. package/src/matrix/monitor/config.ts +569 -0
  103. package/src/matrix/monitor/context-summary.ts +43 -0
  104. package/src/matrix/monitor/direct.ts +296 -0
  105. package/src/matrix/monitor/events.ts +397 -0
  106. package/src/matrix/monitor/handler.ts +2271 -0
  107. package/src/matrix/monitor/inbound-dedupe.ts +267 -0
  108. package/src/matrix/monitor/index.ts +540 -0
  109. package/src/matrix/monitor/legacy-crypto-restore.ts +139 -0
  110. package/src/matrix/monitor/location.ts +108 -0
  111. package/src/matrix/monitor/media.ts +119 -0
  112. package/src/matrix/monitor/mentions.ts +256 -0
  113. package/src/matrix/monitor/reaction-events.ts +197 -0
  114. package/src/matrix/monitor/recent-invite.ts +30 -0
  115. package/src/matrix/monitor/replies.ts +136 -0
  116. package/src/matrix/monitor/reply-context.ts +92 -0
  117. package/src/matrix/monitor/room-history.ts +301 -0
  118. package/src/matrix/monitor/room-info.ts +126 -0
  119. package/src/matrix/monitor/rooms.ts +52 -0
  120. package/src/matrix/monitor/route.ts +179 -0
  121. package/src/matrix/monitor/runtime-api.ts +28 -0
  122. package/src/matrix/monitor/startup-verification.ts +237 -0
  123. package/src/matrix/monitor/startup.ts +218 -0
  124. package/src/matrix/monitor/status.ts +120 -0
  125. package/src/matrix/monitor/sync-lifecycle.ts +91 -0
  126. package/src/matrix/monitor/task-runner.ts +38 -0
  127. package/src/matrix/monitor/test-events.ts +21 -0
  128. package/src/matrix/monitor/thread-context.ts +108 -0
  129. package/src/matrix/monitor/threads.ts +85 -0
  130. package/src/matrix/monitor/types.ts +30 -0
  131. package/src/matrix/monitor/verification-events.ts +643 -0
  132. package/src/matrix/monitor/verification-utils.ts +46 -0
  133. package/src/matrix/outbound-media-runtime.ts +1 -0
  134. package/src/matrix/poll-summary.ts +110 -0
  135. package/src/matrix/poll-types.ts +429 -0
  136. package/src/matrix/probe.runtime.ts +4 -0
  137. package/src/matrix/probe.ts +97 -0
  138. package/src/matrix/profile.ts +184 -0
  139. package/src/matrix/reaction-common.ts +147 -0
  140. package/src/matrix/sdk/crypto-bootstrap.ts +438 -0
  141. package/src/matrix/sdk/crypto-facade.ts +242 -0
  142. package/src/matrix/sdk/crypto-node.runtime.ts +17 -0
  143. package/src/matrix/sdk/crypto-runtime.ts +14 -0
  144. package/src/matrix/sdk/decrypt-bridge.ts +410 -0
  145. package/src/matrix/sdk/event-helpers.ts +83 -0
  146. package/src/matrix/sdk/http-client.ts +87 -0
  147. package/src/matrix/sdk/idb-persistence-lock.ts +51 -0
  148. package/src/matrix/sdk/idb-persistence.ts +286 -0
  149. package/src/matrix/sdk/logger.ts +108 -0
  150. package/src/matrix/sdk/read-response-with-limit.ts +19 -0
  151. package/src/matrix/sdk/recovery-key-store.ts +453 -0
  152. package/src/matrix/sdk/timeout-abort-signal.ts +1 -0
  153. package/src/matrix/sdk/transport-runtime-api.ts +18 -0
  154. package/src/matrix/sdk/transport.ts +352 -0
  155. package/src/matrix/sdk/types.ts +245 -0
  156. package/src/matrix/sdk/verification-manager.ts +795 -0
  157. package/src/matrix/sdk/verification-status.ts +23 -0
  158. package/src/matrix/sdk.ts +2152 -0
  159. package/src/matrix/send/client.ts +93 -0
  160. package/src/matrix/send/formatting.ts +189 -0
  161. package/src/matrix/send/media.ts +244 -0
  162. package/src/matrix/send/targets.ts +104 -0
  163. package/src/matrix/send/types.ts +131 -0
  164. package/src/matrix/send.ts +660 -0
  165. package/src/matrix/session-store-metadata.ts +108 -0
  166. package/src/matrix/startup-abort.ts +44 -0
  167. package/src/matrix/subagent-hooks.ts +308 -0
  168. package/src/matrix/sync-state.ts +27 -0
  169. package/src/matrix/target-ids.ts +79 -0
  170. package/src/matrix/thread-bindings-shared.ts +206 -0
  171. package/src/matrix/thread-bindings.ts +580 -0
  172. package/src/matrix-migration.runtime.ts +9 -0
  173. package/src/migration-config.ts +243 -0
  174. package/src/migration-snapshot-backup.ts +116 -0
  175. package/src/migration-snapshot.ts +53 -0
  176. package/src/onboarding.ts +775 -0
  177. package/src/outbound.ts +248 -0
  178. package/src/plugin-entry.runtime.js +115 -0
  179. package/src/plugin-entry.runtime.ts +70 -0
  180. package/src/profile-update.ts +71 -0
  181. package/src/record-shared.ts +3 -0
  182. package/src/resolve-targets.ts +175 -0
  183. package/src/resolver.runtime.ts +5 -0
  184. package/src/resolver.ts +21 -0
  185. package/src/runtime-api.ts +106 -0
  186. package/src/runtime.ts +13 -0
  187. package/src/secret-contract.ts +174 -0
  188. package/src/session-route.ts +126 -0
  189. package/src/setup-bootstrap.ts +102 -0
  190. package/src/setup-config.ts +222 -0
  191. package/src/setup-contract.ts +90 -0
  192. package/src/setup-core.ts +146 -0
  193. package/src/setup-dm-policy.ts +15 -0
  194. package/src/setup-surface.ts +4 -0
  195. package/src/startup-maintenance.ts +114 -0
  196. package/src/storage-paths.ts +92 -0
  197. package/src/thread-binding-api.ts +23 -0
  198. package/src/tool-actions.runtime.ts +1 -0
  199. package/src/tool-actions.ts +498 -0
  200. package/src/types.ts +257 -0
  201. package/subagent-hooks-api.ts +31 -0
  202. package/test-api.ts +21 -0
  203. package/thread-binding-api.ts +4 -0
  204. package/thread-bindings-runtime.ts +4 -0
  205. package/tsconfig.json +16 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,285 @@
1
+ # Changelog
2
+
3
+ ## 2026.5.19
4
+
5
+ ### Changes
6
+
7
+ - Version alignment with core AutoBot release numbers.
8
+
9
+ ## 2026.5.17
10
+
11
+ ### Changes
12
+
13
+ - Version alignment with core AutoBot release numbers.
14
+
15
+ ### Fixes
16
+
17
+ - Matrix/E2EE: stop requesting MSC4222 `state_after` sync responses so homeservers with incomplete state-after data do not leave fresh encrypted rooms without outbound room encryptors. Fixes #82515. Thanks @nickdecooman.
18
+
19
+ ## 2026.5.16
20
+
21
+ ### Changes
22
+
23
+ - Version alignment with core AutoBot release numbers.
24
+
25
+ ## 2026.5.14
26
+
27
+ ### Changes
28
+
29
+ - Version alignment with core AutoBot release numbers.
30
+
31
+ ## 2026.5.12
32
+
33
+ ### Changes
34
+
35
+ - Version alignment with core AutoBot release numbers.
36
+
37
+ ## 2026.5.10
38
+
39
+ ### Changes
40
+
41
+ - Version alignment with core AutoBot release numbers.
42
+
43
+ ## 2026.5.8
44
+
45
+ ### Changes
46
+
47
+ - Version alignment with core AutoBot release numbers.
48
+
49
+ ## 2026.5.6
50
+
51
+ ### Changes
52
+
53
+ - Version alignment with core AutoBot release numbers.
54
+
55
+ ## 2026.5.4
56
+
57
+ ### Changes
58
+
59
+ - Version alignment with core AutoBot release numbers.
60
+
61
+ ## 2026.5.3
62
+
63
+ ### Changes
64
+
65
+ - Version alignment with core AutoBot release numbers.
66
+
67
+ ## 2026.5.2
68
+
69
+ ### Changes
70
+
71
+ - Version alignment with core AutoBot release numbers.
72
+
73
+ ## Unreleased
74
+
75
+ ### Changes
76
+
77
+ - Matrix/E2EE: add `autobot matrix encryption setup` to enable Matrix encryption, bootstrap recovery, and print verification status from one setup flow. Thanks @gumadeiras.
78
+
79
+ ### Fixes
80
+
81
+ - Matrix/E2EE: close the owner-side device verification loop when SAS lands via the CLI. `verify confirm-sas` now (1) awaits the rust-crypto verifier promise so the done-exchange and any cross-signing uploads triggered by `crossSignDevice` settle before the verb returns, (2) cross-signs the bot device on the auto-confirmed inbound SAS path (previously skipped), and (3) calls `trustOwnIdentityAfterSelfVerification` from the standalone `confirmMatrixVerificationSas` action so the operator's Element X clears the "Verify" prompt without waiting for a passive sync tick [AI-assisted]. Thanks @nklock.
82
+ - Matrix/E2EE: stabilize recovery and broken-device QA flows while avoiding device-cleanup sync races that could leave shutdown-time crypto work running. Thanks @gumadeiras.
83
+
84
+ ## 2026.4.25
85
+
86
+ ### Changes
87
+
88
+ - Version alignment with core AutoBot release numbers.
89
+
90
+ ## 2026.4.20
91
+
92
+ ### Changes
93
+
94
+ - Version alignment with core AutoBot release numbers.
95
+
96
+ ## 2026.4.19-beta.1
97
+
98
+ ### Changes
99
+
100
+ - Version alignment with core AutoBot release numbers.
101
+
102
+ This file tracks Matrix-related release notes for the local `@gakr-gakr/matrix`
103
+ plugin since the `matrix-js-sdk` migration. Source release notes live in
104
+ `../../changelog.md`; exact repeated entries inside the same version are
105
+ collapsed here.
106
+
107
+ ## 2026.4.15-beta.2
108
+
109
+ ### Fixes
110
+
111
+ - Matrix/pairing: block DM pairing-store entries from authorizing room control commands [AI-assisted]. (#67294) Thanks @pgondhi987.
112
+ - Docker/build: verify `@matrix-org/matrix-sdk-crypto-nodejs` native bindings with `find` under `node_modules` instead of a hardcoded `.pnpm/...` path so pnpm v10+ virtual-store layouts no longer fail the image build. (#67143) thanks @ly85206559.
113
+ - Matrix/E2EE: keep startup bootstrap conservative for passwordless token-auth bots, still attempt the guarded repair pass without requiring `channels.matrix.password`, and document the remaining password-UIA limitation. (#66228) Thanks @SARAMALI15792.
114
+ - Matrix/commands: skip DM pairing-store reads on room traffic now that room control-command authorization ignores pairing-store entries, keeping the room path narrower without changing room auth behavior. (#67325) Thanks @gumadeiras.
115
+
116
+ ## 2026.4.15-beta.1
117
+
118
+ ### Changes
119
+
120
+ - QA/Matrix: split Matrix live QA into a source-linked `qa-matrix` runner and keep repo-private `qa-*` surfaces out of packaged and published builds. (#66723) Thanks @gumadeiras.
121
+
122
+ ### Fixes
123
+
124
+ - Matrix/security: normalize sandboxed profile avatar params, preserve `mxc://` avatar URLs, and surface gmail watcher stop failures during reload. (#64701) Thanks @slepybear.
125
+ - Docker/build: verify `@matrix-org/matrix-sdk-crypto-nodejs` native bindings with `find` under `node_modules` instead of a hardcoded `.pnpm/...` path so pnpm v10+ virtual-store layouts no longer fail the image build. (#67143) Thanks @ly85206559.
126
+ - Matrix/E2EE: keep startup bootstrap conservative for passwordless token-auth bots, still attempt the guarded repair pass without requiring `channels.matrix.password`, and document the remaining password-UIA limitation. (#66228) Thanks @SARAMALI15792.
127
+ - Matrix/commands: skip DM pairing-store reads on room traffic now that room control-command authorization ignores pairing-store entries, keeping the room path narrower without changing room auth behavior. (#67325) Thanks @gumadeiras.
128
+ - Matrix/security: block DM pairing-store entries from authorizing room control commands. (#67294) Thanks @pgondhi987.
129
+
130
+ ## 2026.4.12
131
+
132
+ ### Changes
133
+
134
+ - Matrix/partial streaming: add MSC4357 live markers to draft preview sends and edits so supporting Matrix clients can render a live/typewriter animation and stop it when the final edit lands. (#63513) Thanks @TigerInYourDream.
135
+
136
+ ### Fixes
137
+
138
+ - Matrix/mentions: keep room mention gating strict while accepting visible `@displayName` Matrix URI labels, so `requireMention` works for non-AutoBot Matrix clients again. (#64796) Thanks @hclsys.
139
+ - Channels/replay dedupe: standardize replay claims, retryable-failure release, and post-success commit behavior across Telegram, Discord, Slack, Mattermost, WhatsApp, Matrix, LINE, Feishu, Zalo, Nextcloud Talk, TLON, Nostr, Voice Call, and shared plugin interactive callbacks so duplicate deliveries stay reply-once after success but retry cleanly after pre-delivery failures. Thanks @vincentkoc.
140
+
141
+ ## 2026.4.10
142
+
143
+ ### Changes
144
+
145
+ - QA/Matrix: add a live `autobot qa matrix` lane backed by a disposable Matrix homeserver, shared live-transport seams, and Matrix-specific transport coverage for threading, reactions, restart, and allowlist behavior. (#64489) Thanks @gumadeiras.
146
+ - Matrix/partial streaming: add MSC4357 live markers to draft preview sends and edits so supporting Matrix clients can render a live/typewriter animation and stop it when the final edit lands. (#63513) Thanks @TigerInYourDream.
147
+
148
+ ### Fixes
149
+
150
+ - Gateway/thread routing: preserve Slack, Telegram, Mattermost, Matrix, ACP, restart-sentinel, and agent announce delivery targets so subagent, cron, stream-relay, session fallback, and restart messages land back in the originating thread, topic, or room casing. (#54840, #57056, #63143, #63228, #63506, #64343, #64391)
151
+ - Matrix: keep multi-account room scoping consistent, keep packaged crypto migrations warning-only when appropriate, preserve ordered block streaming, add explicit Matrix block-streaming opt-in, and resolve verification/bootstrap from the packaged runtime entry. (#58449, #59249, #59266, #64373) Thanks @gumadeiras.
152
+ - Matrix/migration: keep packaged warning-only crypto migrations from being misclassified as actionable when only helper chunks are present, so startup and doctor stay on the warning-only path instead of creating unnecessary migration snapshots. (#64373) Thanks @gumadeiras.
153
+ - Matrix/ACP thread bindings: preserve canonical room casing and parent conversation routing during ACP session spawn so mixed-case room ids bind correctly from top-level rooms and existing Matrix threads. (#64343) Thanks @gumadeiras.
154
+
155
+ ## 2026.4.9
156
+
157
+ ### Fixes
158
+
159
+ - Matrix/gateway: wait for Matrix sync readiness before marking startup successful, keep Matrix background handler failures contained, and route fatal Matrix sync stops through channel-level restart handling instead of crashing the whole gateway. (#62779) Thanks @gumadeiras.
160
+ - Matrix/doctor: migrate legacy `channels.matrix.dm.policy: "trusted"` configs back to compatible DM policies during `autobot doctor --fix`, preserving explicit `allowFrom` boundaries as `allowlist` and defaulting empty legacy configs to `pairing`. (#62942) Thanks @lukeboyett.
161
+
162
+ ## 2026.4.8
163
+
164
+ ### Fixes
165
+
166
+ - Bundled channels/setup: load shared secret contracts through packaged top-level sidecars across Feishu, Google Chat, IRC, Matrix, Mattermost, Microsoft Teams, Nextcloud Talk, Slack, and Zalo so installed npm builds no longer rely on missing `dist/extensions/*/src/*` files during gateway startup.
167
+
168
+ ## 2026.4.7
169
+
170
+ ### Fixes
171
+
172
+ - Matrix/onboarding: add an invite auto-join setup step with explicit off warnings and strict stable-target validation so new Matrix accounts stop silently ignoring invited rooms and fresh DM-style invites unless operators opt in. (#62168) Thanks @gumadeiras.
173
+ - Matrix/formatting: preserve multi-paragraph and loose-list rendering in Element so numbered and bulleted Markdown keeps their content attached to the correct list item. (#60997) Thanks @gucasbrg.
174
+ - Matrix/agents: hide owner-only `set-profile` from embedded agent channel-action discovery so non-owner runs stop advertising profile updates they cannot execute. (#62662) Thanks @eleqtrizit.
175
+
176
+ ## 2026.4.5
177
+
178
+ ### Changes
179
+
180
+ - Matrix/exec approvals: add Matrix-native exec approval prompts with account-scoped approvers, channel-or-DM delivery, and room-thread aware resolution handling. (#58635) Thanks @gumadeiras.
181
+ - Matrix/exec approvals: clarify unavailable-approval replies so Matrix no longer claims chat approvals are unsupported when native exec approvals are merely unconfigured. (#61424) Thanks @gumadeiras.
182
+
183
+ ### Fixes
184
+
185
+ - Matrix/exec approvals: anchor seeded approval reactions to the primary Matrix prompt event, resolve them from event metadata instead of prompt text, and clean up chunked approval prompts correctly. (#60931) Thanks @gumadeiras.
186
+ - Matrix: recover more reliably when secret storage or recovery keys are missing by recreating secret storage during repair and backup reset, hold crypto snapshot locks during persistence, and surface explicit too-large attachment markers. (#59846, #59851, #60599, #60289) Thanks @al3mart, @emonty, and @efe-arv.
187
+ - Matrix/DM sessions: add `channels.matrix.dm.sessionScope`, shared-session collision notices, and aligned outbound session reuse so separate Matrix DM rooms can keep distinct context when configured. (#61373) Thanks @gumadeiras.
188
+ - Matrix: move legacy top-level `avatarUrl` into the default account during multi-account promotion and keep env-backed account setup avatar config persisted. (#61437) Thanks @gumadeiras.
189
+ - Matrix/streaming: add a quiet preview mode for streamed Matrix replies, keep legacy `partial` preview-first behavior, and finalize quiet media captions correctly so previews stop notifying early without dropping final text semantics. (#61450) Thanks @gumadeiras.
190
+ - Matrix: keep direct transport requests on the pinned dispatcher by routing them through undici runtime fetch, so Matrix clients resume syncing on newer runtimes without dropping the validated address binding. (#61595) Thanks @gumadeiras.
191
+ - Matrix: avoid failing startup when token auth already knows the user ID but still needs optional device metadata, retry transient auth bootstrap requests, and backfill missing device IDs after startup while keeping unknown-device storage reuse conservative until metadata is repaired. (#61383) Thanks @gumadeiras.
192
+ - Matrix: pass configured `deviceId` through health probes and keep probe-only client setup out of durable Matrix storage, so health checks preserve the correct device identity without rewriting `storage-meta.json` or related probe state on disk. (#61581) Thanks @MoerAI.
193
+ - Matrix/plugin loading: ship and source-load the crypto bootstrap runtime sidecar correctly so current `main` stops warning about failed Matrix bootstrap loads and `matrix/index` plugin-id mismatches on every invocation. (#53298) thanks @keithce.
194
+ - Plugins/Matrix: mirror the Matrix crypto WASM runtime dependency into the root packaged install and enforce root/plugin dependency parity so bundled Matrix E2EE crypto resolves correctly in shipped builds. (#57163) Thanks @gumadeiras.
195
+ - Plugins/CLI: add descriptor-backed lazy plugin CLI registration so Matrix can keep its CLI module lazy-loaded without dropping `autobot matrix ...` from parse-time command registration. (#57165) Thanks @gumadeiras.
196
+ - Matrix/delivery recovery: treat Synapse `User not in room` replay failures as permanent during startup recovery so poisoned queued messages move to `failed/` instead of crash-looping Matrix after restart. (#57426) thanks @dlardo.
197
+ - Doctor/plugins: skip false Matrix legacy-helper warnings when no migration plans exist, and keep bundled `enabledByDefault` plugins in the gateway startup set. (#57931) Thanks @dinakars777.
198
+ - Matrix/CLI send: start one-off Matrix send clients before outbound delivery so `autobot message send --channel matrix` restores E2EE in encrypted rooms instead of sending plain events. (#57936) Thanks @gumadeiras.
199
+ - Matrix/direct rooms: stop trusting remote `is_direct`, honor explicit local `is_direct: false` for discovered DM candidates, and avoid extra member-state lookups for shared rooms so DM routing and repair stay aligned. (#57124) Thanks @w-sss.
200
+ - Matrix/direct rooms: recover fresh auto-joined 1:1 DMs without eagerly persisting invite-only `m.direct` mappings, while keeping named, aliased, and explicitly configured rooms on the room path. (#58024) Thanks @gumadeiras.
201
+
202
+ ## 2026.4.2
203
+
204
+ ### Changes
205
+
206
+ - Matrix/plugin: emit spec-compliant `m.mentions` metadata across text sends, media captions, edits, poll fallback text, and action-driven edits so Matrix mentions notify reliably in clients like Element. (#59323) Thanks @gumadeiras.
207
+
208
+ ## 2026.4.1-beta.1
209
+
210
+ ### Notes
211
+
212
+ - Matrix/onboarding: restore guided setup in `autobot channels add` and `autobot configure --section channels`, while keeping custom plugin wizards on the shared `setupWizard` seam. (#59462) Thanks @gumadeiras.
213
+ - Matrix/streaming: keep live partial previews for the current assistant block while preserving completed block updates as separate messages when `channels.matrix.blockStreaming` is enabled. (#59384) Thanks @gumadeiras.
214
+
215
+ ## 2026.3.31
216
+
217
+ ### Changes
218
+
219
+ - Matrix/history: add optional room history context for Matrix group triggers via `channels.matrix.historyLimit`, with per-agent watermarks and retry-safe snapshots so failed trigger retries do not drift into newer room messages. (#57022) thanks @chain710.
220
+ - Matrix/network: add explicit `channels.matrix.proxy` config for routing Matrix traffic through an HTTP(S) proxy, including account-level overrides and matching probe/runtime behavior. (#56931) thanks @patrick-yingxi-pan.
221
+ - Matrix/streaming: add draft streaming so partial Matrix replies update the same message in place instead of sending a new message for each chunk. (#56387) Thanks @jrusz.
222
+ - Matrix/threads: add per-DM `threadReplies` overrides and keep thread session isolation aligned with the effective room or DM thread policy from the triggering message onward. (#57995) thanks @teconomix.
223
+
224
+ ### Fixes
225
+
226
+ - Doctor/plugins: skip false Matrix legacy-helper warnings when no migration plans exist, and keep bundled `enabledByDefault` plugins in the gateway startup set. (#57931) Thanks @dinakars777.
227
+
228
+ ## 2026.3.31-beta.1
229
+
230
+ ### Fixes
231
+
232
+ - Matrix/CLI send: start one-off Matrix send clients before outbound delivery so `autobot message send --channel matrix` restores E2EE in encrypted rooms instead of sending plain events. (#57936) Thanks @gumadeiras.
233
+ - Matrix/context: filter fetched room context by sender allowlists so reply and thread context lookup no longer pulls non-allowlisted messages into agent context. (#58376) Thanks @jacobtomlinson.
234
+ - Matrix/delivery recovery: treat Synapse `User not in room` replay failures as permanent during startup recovery so poisoned queued messages move to `failed/` instead of crash-looping Matrix after restart. (#57426) thanks @dlardo.
235
+ - Matrix/direct rooms: recover fresh auto-joined 1:1 DMs without eagerly persisting invite-only `m.direct` mappings, while keeping named, aliased, and explicitly configured rooms on the room path. (#58024) Thanks @gumadeiras.
236
+ - Matrix/direct rooms: stop trusting remote `is_direct`, honor explicit local `is_direct: false` for discovered DM candidates, and avoid extra member-state lookups for shared rooms so DM routing and repair stay aligned. (#57124) Thanks @w-sss.
237
+ - Matrix/DM threads: keep strict unnamed fresh-invite rooms promotable even when Matrix omits the optional direct hint, preserve repair-failed local DM promotions while still revalidating later room metadata, and keep both bound and thread-isolated Matrix sessions reporting the correct route policy. (#58099) Thanks @gumadeiras.
238
+ - Matrix/plugin loading: ship and source-load the crypto bootstrap runtime sidecar correctly so current `main` stops warning about failed Matrix bootstrap loads and `matrix/index` plugin-id mismatches on every invocation. (#53298) thanks @keithce.
239
+ - Plugins/CLI: add descriptor-backed lazy plugin CLI registration so Matrix can keep its CLI module lazy-loaded without dropping `autobot matrix ...` from parse-time command registration. (#57165) Thanks @gumadeiras.
240
+ - Plugins/Matrix: mirror the Matrix crypto WASM runtime dependency into the root packaged install and enforce root/plugin dependency parity so bundled Matrix E2EE crypto resolves correctly in shipped builds. (#57163) Thanks @gumadeiras.
241
+
242
+ ## 2026.3.28
243
+
244
+ ### Changes
245
+
246
+ - Plugins/Matrix TTS: send auto-TTS replies as native Matrix voice bubbles instead of generic audio attachments. (#37080) thanks @Matthew19990919.
247
+
248
+ ### Fixes
249
+
250
+ - Matrix/replies: include quoted poll question/options in inbound reply context so the agent sees the original poll content when users reply to Matrix poll messages. (#55056) Thanks @alberthild.
251
+ - Matrix/plugins: keep plugin bootstrap from crashing when built runtime mixes bare and deep `matrix-js-sdk` entrypoints, so unrelated channels do not get taken down during plugin load. (#56273) Thanks @aquaright1.
252
+ - Matrix: keep separate 2-person rooms out of DM routing after `m.direct` seeds successfully, while still honoring explicit `is_direct` state and startup fallback recovery. (#54890) thanks @private-peter
253
+ - Plugins/Matrix: preserve sender filenames for inbound media by forwarding `originalFilename` to `saveMediaBuffer`. (#55692) thanks @esrehmki.
254
+ - Matrix/mentions: recognize `matrix.to` mentions whose visible label uses the bot's room display name, so `requireMention: true` rooms respond correctly in modern Matrix clients. (#55393) thanks @nickludlam.
255
+ - Plugins/Matrix: prefer explicit DM signals when choosing outbound direct rooms and routing unmapped verification summaries, so strict 2-person fallback rooms do not outrank the real DM. (#56076) thanks @gumadeiras
256
+ - Plugins/Matrix: resolve env-backed `accessToken` and `password` SecretRefs against the active Matrix config env path during startup, and officially accept SecretRef `accessToken` config values. (#54980) thanks @kakahu2015.
257
+ - Plugins/Matrix: load bundled `@matrix-org/matrix-sdk-crypto-nodejs` through `createRequire(...)` so E2EE media send and receive keep the package-local native binding lookup working in packaged ESM builds. (#54566) thanks @joelnishanth.
258
+ - Plugins/Matrix: encrypt E2EE image thumbnails with `thumbnail_file` while keeping unencrypted-room previews on `thumbnail_url`, so encrypted Matrix image events keep thumbnail metadata without leaking plaintext previews. (#54711) thanks @frischeDaten.
259
+
260
+ ## 2026.3.23
261
+
262
+ ### Fixes
263
+
264
+ - Plugins/bundled runtimes: ship bundled plugin runtime sidecars like WhatsApp `light-runtime-api.js`, Matrix `runtime-api.js`, and other plugin runtime entry files in the npm package again, so global installs stop failing on missing bundled plugin runtime surfaces.
265
+ - Plugins/Matrix: avoid duplicate `resolveMatrixAccountStringValues` runtime-api exports under source loaders so bundled Matrix installs no longer crash at startup with `Cannot redefine property: resolveMatrixAccountStringValues`. Fixes #52909 and #52891. Thanks @vincentkoc.
266
+
267
+ ## 2026.3.22
268
+
269
+ ### Breaking
270
+
271
+ - Plugins/Matrix: add a new Matrix plugin backed by the official `matrix-js-sdk`. If you are upgrading from the previous public Matrix plugin, follow the migration guide: https://docs.openclaw.ai/install/migrating-matrix Thanks @gumadeiras.
272
+ - Plugins/Matrix: stop mention-gated or otherwise dropped room chatter from refreshing focused thread bindings before the message is actually routed, so idle ACP and session bindings can still expire normally in mention-required rooms. Thanks @vincentkoc, @dinakars777 and @mvanhorn.
273
+ - Plugins/Matrix: durably dedupe inbound room events across gateway restarts so previously handled Matrix messages are not replayed as new, while preserving clean-restart backlog delivery for unseen events. (#50922) thanks @gumadeiras
274
+
275
+ ### Changes
276
+
277
+ - Plugins/Matrix: add `allowBots` room policy so configured Matrix bot accounts can talk to each other, with optional mention-only gating. Thanks @gumadeiras.
278
+ - Plugins/Matrix: add per-account `allowPrivateNetwork` opt-in for private/internal homeservers, while keeping public cleartext homeservers blocked. Thanks @gumadeiras.
279
+
280
+ ### Fixes
281
+
282
+ - Plugins/Matrix: move bundled plugin `KeyedAsyncQueue` imports onto the stable `plugin-sdk/core` surface so Matrix Docker/runtime builds do not depend on the brittle keyed-async-queue subpath. Thanks @ecohash-co and @vincentkoc.
283
+ - Doctor/extensions: keep Matrix DM `allowFrom` repairs on the canonical `dm.allowFrom` path and stop treating Zalouser group sender gating as if it fell back to `allowFrom`, so doctor warnings and `--fix` stay aligned with runtime access control. Thanks @vincentkoc.
284
+ - Matrix: make onboarding status runtime-safe (#49995) Thanks @joshavant.
285
+ - Plugins/Matrix: accept shared send-tool media aliases (`mediaUrl`, `filePath`, `path`) and preserve `asVoice` / `audioAsVoice` through Matrix action dispatch so media-only sends and voice-message intents reach the plugin send layer correctly. Thanks @psacc and @vincentkoc.
@@ -0,0 +1,116 @@
1
+ # Matrix Spec Support
2
+
3
+ Current Matrix spec/event support tracked for the bundled Matrix plugin.
4
+
5
+ Scope:
6
+
7
+ - code-backed today-state only
8
+ - plugin behavior only; not a claim of full Matrix spec coverage
9
+ - update this file when adding or removing Matrix event/spec support
10
+
11
+ Legend:
12
+
13
+ - `in`: inbound handling
14
+ - `out`: outbound send/edit/emit
15
+ - `tools`: CLI/action/runtime tooling built on that surface
16
+
17
+ ## Support Matrix
18
+
19
+ | Surface | Spec / event ids | Support | Notes | Evidence |
20
+ | ------------------------ | -------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------- |
21
+ | Core messages | `m.room.message` | in/out/tools | base text/media message surface | `src/matrix/send/types.ts`, `src/matrix/actions/messages.ts` |
22
+ | Rich text | `org.matrix.custom.html` | out | Markdown rendered to Matrix HTML | `src/matrix/send/formatting.ts` |
23
+ | Replies | `m.in_reply_to` | in/out | reply relation support | `src/matrix/send/formatting.ts` |
24
+ | Edits | `m.replace` | in/out/tools | Matrix edit flow; edit body uses `* <text>` fallback format | `src/matrix/send/types.ts`, `src/matrix/draft-stream.test.ts` |
25
+ | Threads | `m.thread` | in/out/tools | thread send, routing, session/thread policy | `src/matrix/send/types.ts`, `src/matrix/monitor/types.ts`, `src/matrix/monitor/threads.test.ts` |
26
+ | Direct rooms | `m.direct` | in/out/tools | DM routing, cache, repair, outbound target selection | `src/matrix/send/types.ts`, `src/matrix/sdk.ts`, `src/matrix/send/targets.test.ts`, `src/matrix/direct-management.test.ts` |
27
+ | Reactions | `m.reaction`, `m.annotation` | in/out/tools | send, summarize, inbound reaction routing | `src/matrix/reaction-common.ts`, `src/matrix/monitor/reaction-events.test.ts` |
28
+ | Read receipts | `m.read` | out | sent on inbound message receipt | `src/matrix/sdk.ts`, `src/matrix/monitor/handler.ts` |
29
+ | Typing | typing API | out | typing keepalive while reply runs | `src/matrix/sdk.ts`, `src/matrix/send.ts`, `src/matrix/monitor/handler.ts` |
30
+ | Mentions | `m.mentions` | in/out/tools | stable mention metadata on sends/edits/media captions/poll fallback text | `src/matrix/send/formatting.ts`, `src/matrix/monitor/mentions.ts`, `src/matrix/send.test.ts` |
31
+ | Mention link compat | `https://matrix.to/#/...` | in/out | emit + validate visible-label mentions in formatted HTML | `src/matrix/format.ts`, `src/matrix/monitor/mentions.ts` |
32
+ | Polls | `m.poll.start`, `m.poll.response`, `m.poll.end` | in/out/tools | stable poll create/read/vote/summary flow | `src/matrix/poll-types.ts`, `src/matrix/actions/polls.ts`, `src/matrix/poll-summary.ts` |
33
+ | Poll compat | `org.matrix.msc3381.poll.start`, `org.matrix.msc3381.poll.response`, `org.matrix.msc3381.poll.end` | in/out | unstable poll compat still emitted/parsed where needed | `src/matrix/poll-types.ts`, `src/matrix/send.test.ts` |
34
+ | Poll relations | `m.reference` | in/out/tools | poll votes/results linked to root poll event | `src/matrix/poll-types.ts`, `src/matrix/actions/polls.ts`, `src/matrix/poll-summary.ts` |
35
+ | Extensible text fallback | `org.matrix.msc1767.text` | in/out | poll text fallback/compat | `src/matrix/poll-types.ts` |
36
+ | Voice messages | `org.matrix.msc3245.voice` | out | voice-bubble marker on compatible audio sends | `src/matrix/send/media.ts`, `src/matrix/send/types.ts` |
37
+ | Voice audio metadata | `org.matrix.msc1767.audio` | out | duration metadata for voice sends | `src/matrix/send/media.ts`, `src/matrix/send/types.ts` |
38
+ | Location | `m.location`, `geo:` | in | inbound parse to text/context; no outbound location send tracked here | `src/matrix/monitor/types.ts`, `src/matrix/monitor/location.ts`, `src/matrix/monitor/handler.ts` |
39
+ | E2EE room events | `m.room.encrypted` | in/out/tools | encrypted event hydration, decrypt, encrypted media send | `src/matrix/monitor/types.ts`, `src/matrix/sdk.ts`, `docs/channels/matrix.md` |
40
+ | Encrypted media previews | `file`, `thumbnail_file` | out | encrypted thumbnails for encrypted image events | `src/matrix/send/media.ts`, `docs/channels/matrix.md` |
41
+ | Device verification | `m.key.verification.*`, `m.key.verification.request` | in/tools | request/ready/start/SAS/done/cancel notices and CLI flows | `src/matrix/monitor/verification-utils.ts`, `src/matrix/monitor/events.test.ts`, `docs/channels/matrix.md` |
42
+ | Streaming/live markers | `org.matrix.msc4357.live` | out | live draft/edit markers for partial streaming | `src/matrix/send/types.ts`, `src/matrix/send.ts`, `src/matrix/draft-stream.ts` |
43
+
44
+ ## Explicit MSCs In Use
45
+
46
+ These MSCs are explicitly referenced in the plugin today:
47
+
48
+ - `MSC3381`: polls
49
+ - `MSC1767`: extensible-events fallback fields used for polls and voice metadata
50
+ - `MSC3245`: voice message marker
51
+ - `MSC4357`: live streaming marker
52
+
53
+ Evidence:
54
+
55
+ - `src/matrix/poll-types.ts`
56
+ - `src/matrix/send/media.ts`
57
+ - `src/matrix/send/types.ts`
58
+ - `src/matrix/draft-stream.ts`
59
+
60
+ ## Non-goals
61
+
62
+ This file does not claim:
63
+
64
+ - full client-server API coverage
65
+ - full room-state/event coverage inherited from `matrix-js-sdk`
66
+ - outbound support for any surface not listed above
67
+
68
+ If a new Matrix feature lands, add a row with:
69
+
70
+ 1. exact event/spec id
71
+ 2. support shape (`in`, `out`, `tools`)
72
+ 3. at least one code path proving it
73
+
74
+ ## Missing / Candidate Specs
75
+
76
+ Recommended next additions, prioritized by user-visible value and closeness to current code:
77
+
78
+ | Priority | Surface | Spec / event ids | Why add it | Current gap |
79
+ | -------- | ----------------------------- | --------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
80
+ | high | Sticker messages | `m.sticker` | stable spec; common client surface; we already classify sticker attachments on read paths | no explicit inbound `m.sticker` event handling and no outbound sticker send path |
81
+ | high | Outbound location messages | `m.location`, `geo_uri` | stable spec; docs already say Matrix supports location, but current implementation is inbound-only | no outbound location send/action API |
82
+ | medium | Private + richer read markers | `m.read.private`, `m.fully_read` | stable spec; better privacy and cleaner read-state behavior than public-only `m.read` | current code only sends public `m.read` receipts |
83
+ | medium | Thread-aware receipts | `m.read` with `thread_id` | stable spec; better alignment with Matrix thread UX | current receipt send path has no `thread_id` support |
84
+ | medium | Unread markers | `m.marked_unread` | stable spec; useful for operator workflows and room triage tooling | no room account-data support for unread markers |
85
+ | low | Emote messages | `m.emote` | stable spec; easy parity win for bots/action tools | no explicit send/action support |
86
+ | low | Poll close parity | `m.poll.end`, `org.matrix.msc3381.poll.end` | completes the poll lifecycle on a surface we already parse | plugin parses poll-end events but does not expose an outbound close flow |
87
+ | low | Animated media metadata | `info.is_animated` on `m.image` / `m.sticker` | newer stable metadata; helps clients decide whether to fetch/render animated originals | media info builders do not populate animation metadata |
88
+
89
+ ### Why these are listed
90
+
91
+ - `m.sticker` is a stable spec surface in the latest Matrix Client-Server API, and the plugin already has partial sticker awareness in message summarization.
92
+ - `m.location` is a stable spec surface in the latest Matrix Client-Server API. The plugin currently parses inbound location events from `geo_uri`, but does not send them.
93
+ - `m.read.private`, `m.fully_read`, and threaded receipts are stable read-marker/read-receipt surfaces in the latest Matrix Client-Server API. The plugin currently posts plain `m.read` receipts only.
94
+ - `m.marked_unread` is a stable room account-data surface in the latest Matrix Client-Server API and would be useful if Matrix actions grow more operator/client-like room triage controls.
95
+ - `m.emote` is a stable message type and a relatively small addition compared with the items above.
96
+ - `m.poll.end` is already represented in local poll types, so exposing a close-poll send/tool flow is a contained follow-up.
97
+ - `info.is_animated` is a smaller metadata-parity item, but easy to miss once sticker support exists.
98
+
99
+ ### Probably not worth prioritizing here
100
+
101
+ - VoIP / `m.call.*`: valid Matrix spec area and a plausible future direction here, just not a near-term priority relative to messaging, receipt, and room-state gaps.
102
+
103
+ ### Gap Evidence
104
+
105
+ - sticker partial only: `src/matrix/media-text.ts`
106
+ - location inbound only: `src/matrix/monitor/location.ts`, `src/matrix/monitor/handler.ts`
107
+ - public receipt only: `src/matrix/sdk.ts`, `src/matrix/send.ts`, `src/matrix/monitor/handler.ts`
108
+ - poll-end constants only: `src/matrix/poll-types.ts`
109
+ - no animation metadata emit: `src/matrix/send/media.ts`
110
+
111
+ ### External Spec References
112
+
113
+ - latest Matrix Client-Server API: <https://spec.matrix.org/latest/client-server-api/index.html>
114
+ - `m.sticker`: <https://spec.matrix.org/latest/client-server-api/#msticker>
115
+ - `m.location`: <https://spec.matrix.org/latest/client-server-api/#mlocation>
116
+ - receipts and read markers (`m.read.private`, `m.fully_read`, `m.marked_unread`): <https://spec.matrix.org/latest/client-server-api/#receipts>
package/api.ts ADDED
@@ -0,0 +1,38 @@
1
+ export { matrixPlugin } from "./src/channel.js";
2
+ export { createMatrixSetupWizardProxy, matrixSetupAdapter } from "./src/setup-core.js";
3
+ export { matrixOnboardingAdapter } from "./src/setup-surface.js";
4
+ export {
5
+ findMatrixAccountEntry,
6
+ requiresExplicitMatrixDefaultAccount,
7
+ resolveConfiguredMatrixAccountIds,
8
+ resolveMatrixChannelConfig,
9
+ resolveMatrixDefaultOrOnlyAccountId,
10
+ } from "./src/account-selection.js";
11
+ export {
12
+ getMatrixScopedEnvVarNames,
13
+ listMatrixEnvAccountIds,
14
+ resolveMatrixEnvAccountToken,
15
+ } from "./src/env-vars.js";
16
+ export {
17
+ hashMatrixAccessToken,
18
+ resolveMatrixAccountStorageRoot,
19
+ resolveMatrixCredentialsDir,
20
+ resolveMatrixCredentialsFilename,
21
+ resolveMatrixCredentialsPath,
22
+ resolveMatrixHomeserverKey,
23
+ resolveMatrixLegacyFlatStoragePaths,
24
+ resolveMatrixLegacyFlatStoreRoot,
25
+ sanitizeMatrixPathSegment,
26
+ } from "./src/storage-paths.js";
27
+ export {
28
+ createMatrixThreadBindingManager,
29
+ getMatrixThreadBindingManager,
30
+ resetMatrixThreadBindingsForTests,
31
+ } from "./src/matrix/thread-bindings.js";
32
+ export {
33
+ setMatrixThreadBindingIdleTimeoutBySessionKey,
34
+ setMatrixThreadBindingMaxAgeBySessionKey,
35
+ } from "./src/matrix/thread-bindings-shared.js";
36
+ export { matrixOnboardingAdapter as matrixSetupWizard } from "./src/onboarding.js";
37
+
38
+ export const matrixSessionBindingAdapterChannels = ["matrix"] as const;
@@ -0,0 +1,56 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import type { AutoBotConfig } from "autobot/plugin-sdk/config-contracts";
5
+ import { resolveStateDir } from "autobot/plugin-sdk/state-paths";
6
+ import {
7
+ resolveMatrixCredentialsDir,
8
+ resolveMatrixCredentialsFilename,
9
+ } from "./src/storage-paths.js";
10
+
11
+ type MatrixAuthPresenceParams =
12
+ | {
13
+ cfg: AutoBotConfig;
14
+ env?: NodeJS.ProcessEnv;
15
+ }
16
+ | AutoBotConfig;
17
+
18
+ function listMatrixCredentialPaths(
19
+ _cfg: AutoBotConfig,
20
+ env: NodeJS.ProcessEnv = process.env,
21
+ ): readonly string[] {
22
+ const credentialsDir = resolveMatrixCredentialsDir(resolveStateDir(env, os.homedir));
23
+ const paths = new Set<string>([
24
+ resolveMatrixCredentialsFilename(),
25
+ resolveMatrixCredentialsFilename("default"),
26
+ ]);
27
+
28
+ try {
29
+ const entries = fs.readdirSync(credentialsDir, { withFileTypes: true });
30
+ for (const entry of entries) {
31
+ if (entry.isFile() && /^credentials(?:-[a-z0-9._-]+)?\.json$/i.test(entry.name)) {
32
+ paths.add(entry.name);
33
+ }
34
+ }
35
+ } catch {
36
+ // Missing credentials directories mean no persisted Matrix auth state.
37
+ }
38
+
39
+ return [...paths].map((filename) => path.join(credentialsDir, filename));
40
+ }
41
+
42
+ export function hasAnyMatrixAuth(
43
+ params: MatrixAuthPresenceParams,
44
+ env: NodeJS.ProcessEnv = process.env,
45
+ ): boolean {
46
+ const cfg = params && typeof params === "object" && "cfg" in params ? params.cfg : params;
47
+ const resolvedEnv =
48
+ params && typeof params === "object" && "cfg" in params ? (params.env ?? env) : env;
49
+ return listMatrixCredentialPaths(cfg, resolvedEnv).some((filePath) => {
50
+ try {
51
+ return fs.existsSync(filePath);
52
+ } catch {
53
+ return false;
54
+ }
55
+ });
56
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "id": "matrix",
3
+ "commandAliases": [{ "name": "matrix" }],
4
+ "activation": {
5
+ "onStartup": false,
6
+ "onCommands": ["matrix"]
7
+ },
8
+ "channels": ["matrix"],
9
+ "channelEnvVars": {
10
+ "matrix": [
11
+ "MATRIX_HOMESERVER",
12
+ "MATRIX_USER_ID",
13
+ "MATRIX_ACCESS_TOKEN",
14
+ "MATRIX_PASSWORD",
15
+ "MATRIX_DEVICE_ID",
16
+ "MATRIX_DEVICE_NAME",
17
+ "MATRIX_OPS_HOMESERVER",
18
+ "MATRIX_OPS_ACCESS_TOKEN",
19
+ "MATRIX_OPS_DEVICE_ID",
20
+ "MATRIX_OPS_DEVICE_NAME"
21
+ ]
22
+ },
23
+ "configSchema": {
24
+ "type": "object",
25
+ "additionalProperties": false,
26
+ "properties": {}
27
+ }
28
+ }
@@ -0,0 +1,3 @@
1
+ // Keep bundled channel entry imports narrow so bootstrap/discovery paths do
2
+ // not pull the broad Matrix API barrel into lightweight plugin loads.
3
+ export { matrixPlugin } from "./src/channel.js";
@@ -0,0 +1,11 @@
1
+ import { definePluginEntry } from "autobot/plugin-sdk/plugin-entry";
2
+ import { registerMatrixCliMetadata } from "./src/cli-metadata.js";
3
+
4
+ export { registerMatrixCliMetadata } from "./src/cli-metadata.js";
5
+
6
+ export default definePluginEntry({
7
+ id: "matrix",
8
+ name: "Matrix",
9
+ description: "Matrix channel plugin (matrix-js-sdk)",
10
+ register: registerMatrixCliMetadata,
11
+ });
@@ -0,0 +1,17 @@
1
+ export {
2
+ createMatrixThreadBindingManager,
3
+ resetMatrixThreadBindingsForTests,
4
+ } from "./src/matrix/thread-bindings.js";
5
+ export { setMatrixRuntime } from "./src/runtime.js";
6
+ export { normalizeCompatibilityConfig, legacyConfigRules } from "./src/doctor-contract.js";
7
+ export {
8
+ namedAccountPromotionKeys,
9
+ resolveSingleAccountPromotionTarget,
10
+ singleAccountKeysToMove,
11
+ } from "./src/setup-contract.js";
12
+ export {
13
+ collectRuntimeConfigAssignments,
14
+ secretTargetRegistryEntries,
15
+ } from "./src/secret-contract.js";
16
+ export { matrixSetupAdapter } from "./src/setup-core.js";
17
+ export { matrixSetupWizard } from "./src/setup-surface.js";
@@ -0,0 +1 @@
1
+ export { normalizeCompatibilityConfig, legacyConfigRules } from "./src/doctor-contract.js";
package/helper-api.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./src/account-selection.js";
2
+ export * from "./src/env-vars.js";
3
+ export * from "./src/storage-paths.js";
package/index.ts ADDED
@@ -0,0 +1,55 @@
1
+ import {
2
+ defineBundledChannelEntry,
3
+ type AutoBotPluginApi,
4
+ } from "autobot/plugin-sdk/channel-entry-contract";
5
+ import { registerMatrixCliMetadata } from "./cli-metadata.js";
6
+ import { registerMatrixSubagentHooks } from "./subagent-hooks-api.js";
7
+
8
+ type MatrixHandlersRuntimeModule = typeof import("./plugin-entry.handlers.runtime.js");
9
+
10
+ let matrixHandlersRuntimePromise: Promise<MatrixHandlersRuntimeModule> | null = null;
11
+
12
+ function loadMatrixHandlersRuntimeModule() {
13
+ matrixHandlersRuntimePromise ??= import("./plugin-entry.handlers.runtime.js");
14
+ return matrixHandlersRuntimePromise;
15
+ }
16
+
17
+ export function registerMatrixFullRuntime(api: AutoBotPluginApi): void {
18
+ api.registerGatewayMethod("matrix.verify.recoveryKey", async (ctx) => {
19
+ const { handleVerifyRecoveryKey } = await loadMatrixHandlersRuntimeModule();
20
+ await handleVerifyRecoveryKey(ctx);
21
+ });
22
+
23
+ api.registerGatewayMethod("matrix.verify.bootstrap", async (ctx) => {
24
+ const { handleVerificationBootstrap } = await loadMatrixHandlersRuntimeModule();
25
+ await handleVerificationBootstrap(ctx);
26
+ });
27
+
28
+ api.registerGatewayMethod("matrix.verify.status", async (ctx) => {
29
+ const { handleVerificationStatus } = await loadMatrixHandlersRuntimeModule();
30
+ await handleVerificationStatus(ctx);
31
+ });
32
+
33
+ registerMatrixSubagentHooks(api);
34
+ }
35
+
36
+ export default defineBundledChannelEntry({
37
+ id: "matrix",
38
+ name: "Matrix",
39
+ description: "Matrix channel plugin (matrix-js-sdk)",
40
+ importMetaUrl: import.meta.url,
41
+ plugin: {
42
+ specifier: "./channel-plugin-api.js",
43
+ exportName: "matrixPlugin",
44
+ },
45
+ secrets: {
46
+ specifier: "./secret-contract-api.js",
47
+ exportName: "channelSecrets",
48
+ },
49
+ runtime: {
50
+ specifier: "./runtime-setter-api.js",
51
+ exportName: "setMatrixRuntime",
52
+ },
53
+ registerCliMetadata: registerMatrixCliMetadata,
54
+ registerFull: registerMatrixFullRuntime,
55
+ });