@openclaw/matrix 2026.3.13 → 2026.5.9-beta.1

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 (206) hide show
  1. package/dist/account-config-D2W-V1eQ.js +96 -0
  2. package/dist/account-selection-BWwIruri.js +158 -0
  3. package/dist/accounts-Bm90Rzvp.js +130 -0
  4. package/dist/active-client-uhlxdhEy.js +20 -0
  5. package/dist/allowlist-sTzpCn5d.js +68 -0
  6. package/dist/api.js +12 -0
  7. package/dist/approval-handler.runtime-DWTQfd4m.js +370 -0
  8. package/dist/approval-ids-DoC2z7tR.js +7 -0
  9. package/dist/approval-reaction-auth-DbcA1gGd.js +27 -0
  10. package/dist/approval-reactions-o2_tuH8D.js +162 -0
  11. package/dist/async-lock-uQfhfQIY.js +19 -0
  12. package/dist/auth-presence.js +26 -0
  13. package/dist/backup-health-Cabu_WQC.js +60 -0
  14. package/dist/channel-DJNir3Rb.js +1116 -0
  15. package/dist/channel-plugin-api.js +2 -0
  16. package/dist/channel.runtime-BQu0hTih.js +246 -0
  17. package/dist/cli-BmfTmg7x.js +1340 -0
  18. package/dist/cli-metadata-B-PCEzrA.js +22 -0
  19. package/dist/cli-metadata.js +2 -0
  20. package/dist/client-DkcXnm0X.js +25 -0
  21. package/dist/client-_hckQNGW.js +31 -0
  22. package/dist/client-bootstrap-Rb8oHvhH.js +114 -0
  23. package/dist/config--5-S2Akv.js +452 -0
  24. package/dist/config-paths-nsVaysCu.js +19 -0
  25. package/dist/config-schema-nPLpEgHl.js +200 -0
  26. package/dist/config-secret-input.runtime-DiKFehsE.js +2 -0
  27. package/dist/config-update-wZX-HLMn.js +143 -0
  28. package/dist/contract-api.js +9 -0
  29. package/dist/create-client-DCnqDaqd.js +64 -0
  30. package/dist/credentials-DV6fWXhC.js +56 -0
  31. package/dist/credentials-read-cmHgousK.js +112 -0
  32. package/dist/credentials-write.runtime-zniTq-Gr.js +17 -0
  33. package/dist/crypto-node.runtime-pihzdpY7.js +12 -0
  34. package/dist/crypto-runtime-ZI0zAtn3.js +1214 -0
  35. package/dist/deps-C6WqKY7m.js +235 -0
  36. package/dist/device-health-UVYpbA_W.js +16 -0
  37. package/dist/direct-management-DMMMgtTB.js +249 -0
  38. package/dist/direct-room-XkutHjES.js +76 -0
  39. package/dist/directory-live-DmOtMhyr.js +150 -0
  40. package/dist/doctor-C4__7c-U.js +153 -0
  41. package/dist/doctor-contract-D4-64QuJ.js +246 -0
  42. package/dist/doctor-contract-api.js +2 -0
  43. package/dist/draft-stream-BE2QevQQ.js +144 -0
  44. package/dist/encryption-guidance-BPi3A_m3.js +15 -0
  45. package/dist/env-auth-BJqGI8M6.js +63 -0
  46. package/dist/env-vars-C7uQCTKn.js +63 -0
  47. package/dist/errors-CTcpEDq-.js +17 -0
  48. package/dist/exec-approval-resolver-Bza9Dhlm.js +15 -0
  49. package/dist/exec-approvals-Crnh543m.js +196 -0
  50. package/dist/helper-api.js +4 -0
  51. package/dist/http-client-C7AeVJay.js +319 -0
  52. package/dist/index.js +46 -0
  53. package/dist/legacy-crypto-inspector-poDWldgy.js +41 -0
  54. package/dist/legacy-crypto-restore-Biw-w2ng.js +85 -0
  55. package/dist/logger-CnZRVrux.js +78 -0
  56. package/dist/logging-DZHSPP5N.js +99 -0
  57. package/dist/matrix-migration.runtime-WY6ffcrf.js +525 -0
  58. package/dist/media-text-DU6nWZuj.js +146 -0
  59. package/dist/messages-BpihMh82.js +140 -0
  60. package/dist/migration-snapshot-backup-DaCHTp8C.js +69 -0
  61. package/dist/migration-snapshot.runtime-CKHE3xF9.js +2 -0
  62. package/dist/monitor-C_81r_Ck.js +4125 -0
  63. package/dist/plugin-entry.handlers.runtime.js +51 -0
  64. package/dist/probe.runtime-BvAzYAIe.js +3 -0
  65. package/dist/profile-BlHu0wDX.js +111 -0
  66. package/dist/profile-update-DjeBNgIV.js +69 -0
  67. package/dist/reaction-common-ejrL19w-.js +71 -0
  68. package/dist/reaction-events-CiARZfjk.js +121 -0
  69. package/dist/record-shared-CHWJCTWf.js +2 -0
  70. package/dist/recovery-key-store-BTJ6jz5v.js +294 -0
  71. package/dist/resolve-targets-YtJnw1Tb.js +140 -0
  72. package/dist/resolver.runtime-D9piiGEl.js +5 -0
  73. package/dist/rolldown-runtime-DUslC3ob.js +14 -0
  74. package/dist/route-D6rg-iXN.js +161 -0
  75. package/dist/runtime-C6X4h_SJ.js +6 -0
  76. package/dist/runtime-Dog86njy.js +8 -0
  77. package/dist/runtime-api-BXWBFIqm.js +25 -0
  78. package/dist/runtime-api.js +25 -0
  79. package/dist/runtime-heavy-api.js +3 -0
  80. package/dist/runtime-setter-api.js +2 -0
  81. package/dist/sdk-B2vZA27-.js +1416 -0
  82. package/dist/secret-contract-DcrJWCQI.js +120 -0
  83. package/dist/secret-contract-api.js +2 -0
  84. package/dist/send-Bo0DU1ca.js +1200 -0
  85. package/dist/session-store-metadata-DI5SCofx.js +77 -0
  86. package/dist/setup-bootstrap-ImenBsMt.js +62 -0
  87. package/dist/setup-core-CfZy05oW.js +116 -0
  88. package/dist/setup-dm-policy-2-r1FrQh.js +194 -0
  89. package/dist/setup-entry.js +19 -0
  90. package/dist/setup-plugin-api.js +44 -0
  91. package/dist/setup-surface-CqT_o61M.js +540 -0
  92. package/dist/shared-CpMoYKm1.js +195 -0
  93. package/dist/startup-abort-56edvmbM.js +32 -0
  94. package/dist/startup-verification-Demyp0bP.js +132 -0
  95. package/dist/storage-paths-BJLdnCjV.js +52 -0
  96. package/dist/storage-tC3ujLiW.js +281 -0
  97. package/dist/subagent-hooks-DQbyqq9V.js +149 -0
  98. package/dist/subagent-hooks-api.js +23 -0
  99. package/dist/sync-state-C_beeevA.js +12 -0
  100. package/dist/target-ids-80nQ2gql.js +77 -0
  101. package/dist/test-api.js +4 -0
  102. package/dist/thread-binding-api-Cq_E-E1K.js +17 -0
  103. package/dist/thread-binding-api.js +2 -0
  104. package/dist/thread-bindings-B9mesxXk.js +352 -0
  105. package/dist/thread-bindings-runtime.js +2 -0
  106. package/dist/thread-bindings-shared-DK-d-oYX.js +97 -0
  107. package/dist/timeout-abort-signal-CtaIaP1v.js +2 -0
  108. package/dist/tool-actions.runtime-BIH49vRr.js +532 -0
  109. package/dist/url-validation-DiK9j7jz.js +36 -0
  110. package/dist/verification-CZ2rDeHL.js +345 -0
  111. package/openclaw.plugin.json +788 -1
  112. package/package.json +82 -16
  113. package/CHANGELOG.md +0 -104
  114. package/index.ts +0 -22
  115. package/src/actions.ts +0 -195
  116. package/src/channel.directory.test.ts +0 -135
  117. package/src/channel.ts +0 -461
  118. package/src/config-schema.test.ts +0 -26
  119. package/src/config-schema.ts +0 -62
  120. package/src/directory-live.test.ts +0 -85
  121. package/src/directory-live.ts +0 -209
  122. package/src/group-mentions.ts +0 -52
  123. package/src/matrix/accounts.test.ts +0 -131
  124. package/src/matrix/accounts.ts +0 -114
  125. package/src/matrix/actions/client.ts +0 -47
  126. package/src/matrix/actions/limits.test.ts +0 -15
  127. package/src/matrix/actions/limits.ts +0 -6
  128. package/src/matrix/actions/messages.ts +0 -126
  129. package/src/matrix/actions/pins.test.ts +0 -74
  130. package/src/matrix/actions/pins.ts +0 -84
  131. package/src/matrix/actions/reactions.test.ts +0 -109
  132. package/src/matrix/actions/reactions.ts +0 -102
  133. package/src/matrix/actions/room.ts +0 -85
  134. package/src/matrix/actions/summary.ts +0 -75
  135. package/src/matrix/actions/types.ts +0 -85
  136. package/src/matrix/actions.ts +0 -15
  137. package/src/matrix/active-client.ts +0 -32
  138. package/src/matrix/client/config.ts +0 -245
  139. package/src/matrix/client/create-client.ts +0 -125
  140. package/src/matrix/client/logging.ts +0 -46
  141. package/src/matrix/client/runtime.ts +0 -4
  142. package/src/matrix/client/shared.test.ts +0 -85
  143. package/src/matrix/client/shared.ts +0 -210
  144. package/src/matrix/client/startup.test.ts +0 -49
  145. package/src/matrix/client/startup.ts +0 -29
  146. package/src/matrix/client/storage.ts +0 -131
  147. package/src/matrix/client/types.ts +0 -34
  148. package/src/matrix/client-bootstrap.ts +0 -47
  149. package/src/matrix/client.test.ts +0 -56
  150. package/src/matrix/client.ts +0 -14
  151. package/src/matrix/credentials.ts +0 -125
  152. package/src/matrix/deps.test.ts +0 -74
  153. package/src/matrix/deps.ts +0 -126
  154. package/src/matrix/format.test.ts +0 -33
  155. package/src/matrix/format.ts +0 -22
  156. package/src/matrix/index.ts +0 -11
  157. package/src/matrix/monitor/access-policy.ts +0 -126
  158. package/src/matrix/monitor/allowlist.test.ts +0 -45
  159. package/src/matrix/monitor/allowlist.ts +0 -94
  160. package/src/matrix/monitor/auto-join.ts +0 -72
  161. package/src/matrix/monitor/direct.test.ts +0 -396
  162. package/src/matrix/monitor/direct.ts +0 -152
  163. package/src/matrix/monitor/events.test.ts +0 -186
  164. package/src/matrix/monitor/events.ts +0 -168
  165. package/src/matrix/monitor/handler.body-for-agent.test.ts +0 -196
  166. package/src/matrix/monitor/handler.ts +0 -768
  167. package/src/matrix/monitor/inbound-body.test.ts +0 -73
  168. package/src/matrix/monitor/inbound-body.ts +0 -28
  169. package/src/matrix/monitor/index.test.ts +0 -18
  170. package/src/matrix/monitor/index.ts +0 -414
  171. package/src/matrix/monitor/location.ts +0 -100
  172. package/src/matrix/monitor/media.test.ts +0 -86
  173. package/src/matrix/monitor/media.ts +0 -118
  174. package/src/matrix/monitor/mentions.test.ts +0 -154
  175. package/src/matrix/monitor/mentions.ts +0 -62
  176. package/src/matrix/monitor/replies.test.ts +0 -184
  177. package/src/matrix/monitor/replies.ts +0 -124
  178. package/src/matrix/monitor/room-info.ts +0 -55
  179. package/src/matrix/monitor/rooms.test.ts +0 -124
  180. package/src/matrix/monitor/rooms.ts +0 -47
  181. package/src/matrix/monitor/threads.ts +0 -68
  182. package/src/matrix/monitor/types.ts +0 -39
  183. package/src/matrix/poll-types.test.ts +0 -21
  184. package/src/matrix/poll-types.ts +0 -167
  185. package/src/matrix/probe.ts +0 -69
  186. package/src/matrix/sdk-runtime.ts +0 -18
  187. package/src/matrix/send/client.ts +0 -99
  188. package/src/matrix/send/formatting.ts +0 -93
  189. package/src/matrix/send/media.ts +0 -230
  190. package/src/matrix/send/targets.test.ts +0 -98
  191. package/src/matrix/send/targets.ts +0 -150
  192. package/src/matrix/send/types.ts +0 -110
  193. package/src/matrix/send-queue.test.ts +0 -145
  194. package/src/matrix/send-queue.ts +0 -28
  195. package/src/matrix/send.test.ts +0 -319
  196. package/src/matrix/send.ts +0 -267
  197. package/src/onboarding.ts +0 -462
  198. package/src/outbound.test.ts +0 -159
  199. package/src/outbound.ts +0 -58
  200. package/src/resolve-targets.test.ts +0 -68
  201. package/src/resolve-targets.ts +0 -125
  202. package/src/runtime.ts +0 -6
  203. package/src/secret-input.ts +0 -13
  204. package/src/test-mocks.ts +0 -53
  205. package/src/tool-actions.ts +0 -164
  206. package/src/types.ts +0 -118
@@ -0,0 +1,200 @@
1
+ import { a as resolveMatrixAccountConfig } from "./account-config-D2W-V1eQ.js";
2
+ import { i as resolveMatrixAccount, r as resolveDefaultMatrixAccountId, t as listMatrixAccountIds } from "./accounts-Bm90Rzvp.js";
3
+ import { t as normalizeMatrixAllowList } from "./allowlist-sTzpCn5d.js";
4
+ import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1 } from "openclaw/plugin-sdk/account-id";
5
+ import { adaptScopedAccountAccessor, createScopedChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
6
+ import { buildChannelConfigSchema } from "openclaw/plugin-sdk/channel-config-primitives";
7
+ import { AllowFromListSchema, ContextVisibilityModeSchema, GroupPolicySchema, MarkdownConfigSchema, ToolPolicySchema, buildNestedDmConfigSchema } from "openclaw/plugin-sdk/channel-config-schema";
8
+ import { buildSecretInputSchema } from "openclaw/plugin-sdk/secret-input";
9
+ import { z } from "openclaw/plugin-sdk/zod";
10
+ //#region extensions/matrix/src/config-adapter.ts
11
+ const matrixConfigAdapter = createScopedChannelConfigAdapter({
12
+ sectionKey: "matrix",
13
+ listAccountIds: listMatrixAccountIds,
14
+ resolveAccount: adaptScopedAccountAccessor(resolveMatrixAccount),
15
+ resolveAccessorAccount: ({ cfg, accountId }) => resolveMatrixAccountConfig({
16
+ cfg,
17
+ accountId
18
+ }),
19
+ defaultAccountId: resolveDefaultMatrixAccountId,
20
+ clearBaseFields: [
21
+ "name",
22
+ "homeserver",
23
+ "network",
24
+ "proxy",
25
+ "userId",
26
+ "accessToken",
27
+ "password",
28
+ "deviceId",
29
+ "deviceName",
30
+ "avatarUrl",
31
+ "initialSyncLimit"
32
+ ],
33
+ resolveAllowFrom: (account) => account.dm?.allowFrom,
34
+ formatAllowFrom: (allowFrom) => normalizeMatrixAllowList(allowFrom)
35
+ });
36
+ //#endregion
37
+ //#region extensions/matrix/src/config-ui-hints.ts
38
+ const matrixChannelConfigUiHints = {
39
+ "streaming.progress.label": {
40
+ label: "Matrix Progress Label",
41
+ help: "Initial progress draft title. Use \"auto\" for built-in single-word labels, a custom string, or false to hide the title."
42
+ },
43
+ "streaming.progress.labels": {
44
+ label: "Matrix Progress Label Pool",
45
+ help: "Candidate labels for streaming.progress.label=\"auto\". Leave unset to use OpenClaw built-in progress labels."
46
+ },
47
+ "streaming.progress.maxLines": {
48
+ label: "Matrix Progress Max Lines",
49
+ help: "Maximum number of compact progress lines to keep below the draft label (default: 8)."
50
+ },
51
+ "streaming.progress.toolProgress": {
52
+ label: "Matrix Progress Tool Lines",
53
+ help: "Show compact tool/progress lines in progress draft mode (default: true). Set false to keep only the label until final delivery."
54
+ },
55
+ "streaming.progress.commandText": {
56
+ label: "Matrix Progress Command Text",
57
+ help: "Command/exec detail in progress draft lines: \"raw\" preserves released behavior; \"status\" shows only the tool label."
58
+ }
59
+ };
60
+ //#endregion
61
+ //#region extensions/matrix/src/config-schema.ts
62
+ const matrixActionSchema = z.object({
63
+ reactions: z.boolean().optional(),
64
+ messages: z.boolean().optional(),
65
+ pins: z.boolean().optional(),
66
+ profile: z.boolean().optional(),
67
+ memberInfo: z.boolean().optional(),
68
+ channelInfo: z.boolean().optional(),
69
+ verification: z.boolean().optional()
70
+ }).optional();
71
+ const matrixThreadBindingsSchema = z.object({
72
+ enabled: z.boolean().optional(),
73
+ idleHours: z.number().nonnegative().optional(),
74
+ maxAgeHours: z.number().nonnegative().optional(),
75
+ spawnSessions: z.boolean().optional(),
76
+ defaultSpawnContext: z.enum(["isolated", "fork"]).optional(),
77
+ spawnSubagentSessions: z.boolean().optional(),
78
+ spawnAcpSessions: z.boolean().optional()
79
+ }).optional();
80
+ const matrixExecApprovalsSchema = z.object({
81
+ enabled: z.boolean().optional(),
82
+ approvers: AllowFromListSchema,
83
+ agentFilter: z.array(z.string()).optional(),
84
+ sessionFilter: z.array(z.string()).optional(),
85
+ target: z.enum([
86
+ "dm",
87
+ "channel",
88
+ "both"
89
+ ]).optional()
90
+ }).optional();
91
+ const matrixRoomSchema = z.object({
92
+ account: z.string().optional(),
93
+ enabled: z.boolean().optional(),
94
+ requireMention: z.boolean().optional(),
95
+ allowBots: z.union([z.boolean(), z.literal("mentions")]).optional(),
96
+ tools: ToolPolicySchema,
97
+ autoReply: z.boolean().optional(),
98
+ users: AllowFromListSchema,
99
+ skills: z.array(z.string()).optional(),
100
+ systemPrompt: z.string().optional()
101
+ }).optional();
102
+ const matrixNetworkSchema = z.object({ dangerouslyAllowPrivateNetwork: z.boolean().optional() }).strict().optional();
103
+ const matrixStreamingSchema = z.object({
104
+ mode: z.enum([
105
+ "partial",
106
+ "quiet",
107
+ "progress",
108
+ "off"
109
+ ]).optional(),
110
+ progress: z.object({
111
+ label: z.union([z.string(), z.literal(false)]).optional(),
112
+ labels: z.array(z.string()).optional(),
113
+ maxLines: z.number().int().positive().optional(),
114
+ toolProgress: z.boolean().optional()
115
+ }).strict().optional(),
116
+ preview: z.object({ toolProgress: z.boolean().optional() }).strict().optional()
117
+ }).strict();
118
+ const MatrixChannelConfigSchema = buildChannelConfigSchema(z.object({
119
+ name: z.string().optional(),
120
+ enabled: z.boolean().optional(),
121
+ defaultAccount: z.string().optional(),
122
+ accounts: z.record(z.string(), z.unknown()).optional(),
123
+ markdown: MarkdownConfigSchema,
124
+ homeserver: z.string().optional(),
125
+ network: matrixNetworkSchema,
126
+ proxy: z.string().optional(),
127
+ userId: z.string().optional(),
128
+ accessToken: buildSecretInputSchema().optional(),
129
+ password: buildSecretInputSchema().optional(),
130
+ deviceId: z.string().optional(),
131
+ deviceName: z.string().optional(),
132
+ avatarUrl: z.string().optional(),
133
+ initialSyncLimit: z.number().optional(),
134
+ encryption: z.boolean().optional(),
135
+ allowlistOnly: z.boolean().optional(),
136
+ allowBots: z.union([z.boolean(), z.literal("mentions")]).optional(),
137
+ groupPolicy: GroupPolicySchema.optional(),
138
+ contextVisibility: ContextVisibilityModeSchema.optional(),
139
+ blockStreaming: z.boolean().optional(),
140
+ streaming: z.union([
141
+ z.enum([
142
+ "partial",
143
+ "quiet",
144
+ "progress",
145
+ "off"
146
+ ]),
147
+ z.boolean(),
148
+ matrixStreamingSchema
149
+ ]).optional(),
150
+ replyToMode: z.enum([
151
+ "off",
152
+ "first",
153
+ "all",
154
+ "batched"
155
+ ]).optional(),
156
+ threadReplies: z.enum([
157
+ "off",
158
+ "inbound",
159
+ "always"
160
+ ]).optional(),
161
+ textChunkLimit: z.number().optional(),
162
+ chunkMode: z.enum(["length", "newline"]).optional(),
163
+ responsePrefix: z.string().optional(),
164
+ ackReaction: z.string().optional(),
165
+ ackReactionScope: z.enum([
166
+ "group-mentions",
167
+ "group-all",
168
+ "direct",
169
+ "all",
170
+ "none",
171
+ "off"
172
+ ]).optional(),
173
+ reactionNotifications: z.enum(["off", "own"]).optional(),
174
+ threadBindings: matrixThreadBindingsSchema,
175
+ startupVerification: z.enum(["off", "if-unverified"]).optional(),
176
+ startupVerificationCooldownHours: z.number().optional(),
177
+ mediaMaxMb: z.number().optional(),
178
+ historyLimit: z.number().int().min(0).optional(),
179
+ autoJoin: z.enum([
180
+ "always",
181
+ "allowlist",
182
+ "off"
183
+ ]).optional(),
184
+ autoJoinAllowlist: AllowFromListSchema,
185
+ groupAllowFrom: AllowFromListSchema,
186
+ dm: buildNestedDmConfigSchema({
187
+ sessionScope: z.enum(["per-user", "per-room"]).optional(),
188
+ threadReplies: z.enum([
189
+ "off",
190
+ "inbound",
191
+ "always"
192
+ ]).optional()
193
+ }),
194
+ execApprovals: matrixExecApprovalsSchema,
195
+ groups: z.object({}).catchall(matrixRoomSchema).optional(),
196
+ rooms: z.object({}).catchall(matrixRoomSchema).optional(),
197
+ actions: matrixActionSchema
198
+ }), { uiHints: matrixChannelConfigUiHints });
199
+ //#endregion
200
+ export { DEFAULT_ACCOUNT_ID$1 as n, matrixConfigAdapter as r, MatrixChannelConfigSchema as t };
@@ -0,0 +1,2 @@
1
+ import { resolveConfiguredSecretInputString } from "openclaw/plugin-sdk/secret-input-runtime";
2
+ export { resolveConfiguredSecretInputString };
@@ -0,0 +1,143 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
2
+ import { t as findMatrixAccountConfig } from "./account-config-D2W-V1eQ.js";
3
+ import { n as resolveMatrixConfigPath$1, r as shouldStoreMatrixAccountAtTopLevel, t as resolveMatrixConfigFieldPath } from "./config-paths-nsVaysCu.js";
4
+ import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
5
+ import { normalizeSecretInputString } from "openclaw/plugin-sdk/setup";
6
+ import { coerceSecretRef } from "openclaw/plugin-sdk/secret-ref-runtime";
7
+ //#region extensions/matrix/src/matrix/config-update.ts
8
+ var config_update_exports = /* @__PURE__ */ __exportAll({
9
+ resolveMatrixConfigFieldPath: () => resolveMatrixConfigFieldPath,
10
+ resolveMatrixConfigPath: () => resolveMatrixConfigPath,
11
+ shouldStoreMatrixAccountAtTopLevel: () => shouldStoreMatrixAccountAtTopLevel,
12
+ updateMatrixAccountConfig: () => updateMatrixAccountConfig
13
+ });
14
+ const resolveMatrixConfigPath = resolveMatrixConfigPath$1;
15
+ function applyNullableStringField(target, key, value) {
16
+ if (value === void 0) return;
17
+ if (value === null) {
18
+ delete target[key];
19
+ return;
20
+ }
21
+ const trimmed = value.trim();
22
+ if (!trimmed) {
23
+ delete target[key];
24
+ return;
25
+ }
26
+ target[key] = trimmed;
27
+ }
28
+ function applyNullableSecretInputField(target, key, value, defaults) {
29
+ if (value === void 0) return;
30
+ if (value === null) {
31
+ delete target[key];
32
+ return;
33
+ }
34
+ if (typeof value === "string") {
35
+ const normalized = normalizeSecretInputString(value);
36
+ if (normalized) target[key] = normalized;
37
+ else delete target[key];
38
+ return;
39
+ }
40
+ const ref = coerceSecretRef(value, defaults);
41
+ if (!ref) throw new Error(`Invalid Matrix ${key} SecretInput.`);
42
+ target[key] = ref;
43
+ }
44
+ function cloneMatrixDmConfig(dm) {
45
+ if (!dm) return dm;
46
+ return {
47
+ ...dm,
48
+ ...dm.allowFrom ? { allowFrom: [...dm.allowFrom] } : {}
49
+ };
50
+ }
51
+ function cloneMatrixRoomMap(rooms) {
52
+ if (!rooms) return rooms;
53
+ return Object.fromEntries(Object.entries(rooms).map(([roomId, roomCfg]) => [roomId, roomCfg ? { ...roomCfg } : roomCfg]));
54
+ }
55
+ function applyNullableArrayField(target, key, value) {
56
+ if (value === void 0) return;
57
+ if (value === null) {
58
+ delete target[key];
59
+ return;
60
+ }
61
+ target[key] = [...value];
62
+ }
63
+ function updateMatrixAccountConfig(cfg, accountId, patch) {
64
+ const matrix = cfg.channels?.matrix ?? {};
65
+ const normalizedAccountId = normalizeAccountId(accountId);
66
+ const nextAccount = { ...findMatrixAccountConfig(cfg, normalizedAccountId) ?? (normalizedAccountId === DEFAULT_ACCOUNT_ID ? matrix : {}) };
67
+ if (patch.name !== void 0) if (patch.name === null) delete nextAccount.name;
68
+ else {
69
+ const trimmed = patch.name.trim();
70
+ if (trimmed) nextAccount.name = trimmed;
71
+ else delete nextAccount.name;
72
+ }
73
+ if (typeof patch.enabled === "boolean") nextAccount.enabled = patch.enabled;
74
+ else if (typeof nextAccount.enabled !== "boolean") nextAccount.enabled = true;
75
+ applyNullableStringField(nextAccount, "homeserver", patch.homeserver);
76
+ applyNullableStringField(nextAccount, "proxy", patch.proxy);
77
+ applyNullableStringField(nextAccount, "userId", patch.userId);
78
+ applyNullableSecretInputField(nextAccount, "accessToken", patch.accessToken, cfg.secrets?.defaults);
79
+ applyNullableSecretInputField(nextAccount, "password", patch.password, cfg.secrets?.defaults);
80
+ applyNullableStringField(nextAccount, "deviceId", patch.deviceId);
81
+ applyNullableStringField(nextAccount, "deviceName", patch.deviceName);
82
+ applyNullableStringField(nextAccount, "avatarUrl", patch.avatarUrl);
83
+ if (patch.allowPrivateNetwork !== void 0) {
84
+ const nextNetwork = nextAccount.network && typeof nextAccount.network === "object" ? { ...nextAccount.network } : {};
85
+ if (patch.allowPrivateNetwork === null) delete nextNetwork.dangerouslyAllowPrivateNetwork;
86
+ else nextNetwork.dangerouslyAllowPrivateNetwork = patch.allowPrivateNetwork;
87
+ if (Object.keys(nextNetwork).length > 0) nextAccount.network = nextNetwork;
88
+ else delete nextAccount.network;
89
+ }
90
+ if (patch.initialSyncLimit !== void 0) if (patch.initialSyncLimit === null) delete nextAccount.initialSyncLimit;
91
+ else nextAccount.initialSyncLimit = Math.max(0, Math.floor(patch.initialSyncLimit));
92
+ if (patch.encryption !== void 0) if (patch.encryption === null) delete nextAccount.encryption;
93
+ else nextAccount.encryption = patch.encryption;
94
+ if (patch.allowBots !== void 0) if (patch.allowBots === null) delete nextAccount.allowBots;
95
+ else nextAccount.allowBots = patch.allowBots;
96
+ if (patch.autoJoin !== void 0) if (patch.autoJoin === null) delete nextAccount.autoJoin;
97
+ else nextAccount.autoJoin = patch.autoJoin;
98
+ applyNullableArrayField(nextAccount, "autoJoinAllowlist", patch.autoJoinAllowlist);
99
+ if (patch.dm !== void 0) if (patch.dm === null) delete nextAccount.dm;
100
+ else nextAccount.dm = cloneMatrixDmConfig({
101
+ ...nextAccount.dm,
102
+ ...patch.dm
103
+ });
104
+ if (patch.groupPolicy !== void 0) if (patch.groupPolicy === null) delete nextAccount.groupPolicy;
105
+ else nextAccount.groupPolicy = patch.groupPolicy;
106
+ applyNullableArrayField(nextAccount, "groupAllowFrom", patch.groupAllowFrom);
107
+ if (patch.groups !== void 0) if (patch.groups === null) delete nextAccount.groups;
108
+ else nextAccount.groups = cloneMatrixRoomMap(patch.groups);
109
+ if (patch.rooms !== void 0) if (patch.rooms === null) delete nextAccount.rooms;
110
+ else nextAccount.rooms = cloneMatrixRoomMap(patch.rooms);
111
+ const nextAccounts = Object.fromEntries(Object.entries(matrix.accounts ?? {}).filter(([rawAccountId]) => rawAccountId === normalizedAccountId || normalizeAccountId(rawAccountId) !== normalizedAccountId));
112
+ if (shouldStoreMatrixAccountAtTopLevel(cfg, normalizedAccountId)) {
113
+ const { accounts: _ignoredAccounts, defaultAccount } = matrix;
114
+ const { accounts: _ignoredNextAccounts, defaultAccount: _ignoredNextDefaultAccount, ...topLevelAccount } = nextAccount;
115
+ return {
116
+ ...cfg,
117
+ channels: {
118
+ ...cfg.channels,
119
+ matrix: {
120
+ ...defaultAccount ? { defaultAccount } : {},
121
+ enabled: true,
122
+ ...topLevelAccount
123
+ }
124
+ }
125
+ };
126
+ }
127
+ return {
128
+ ...cfg,
129
+ channels: {
130
+ ...cfg.channels,
131
+ matrix: {
132
+ ...matrix,
133
+ enabled: true,
134
+ accounts: {
135
+ ...nextAccounts,
136
+ [normalizedAccountId]: nextAccount
137
+ }
138
+ }
139
+ }
140
+ };
141
+ }
142
+ //#endregion
143
+ export { resolveMatrixConfigPath as n, updateMatrixAccountConfig as r, config_update_exports as t };
@@ -0,0 +1,9 @@
1
+ import { s as resetMatrixThreadBindingsForTests } from "./thread-bindings-shared-DK-d-oYX.js";
2
+ import { r as setMatrixRuntime } from "./runtime-Dog86njy.js";
3
+ import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-D4-64QuJ.js";
4
+ import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-DcrJWCQI.js";
5
+ import { a as namedAccountPromotionKeys, o as resolveSingleAccountPromotionTarget, s as singleAccountKeysToMove } from "./setup-dm-policy-2-r1FrQh.js";
6
+ import { n as matrixSetupAdapter } from "./setup-core-CfZy05oW.js";
7
+ import { n as matrixOnboardingAdapter } from "./setup-surface-CqT_o61M.js";
8
+ import { t as createMatrixThreadBindingManager } from "./thread-bindings-B9mesxXk.js";
9
+ export { collectRuntimeConfigAssignments, createMatrixThreadBindingManager, legacyConfigRules, matrixSetupAdapter, matrixOnboardingAdapter as matrixSetupWizard, namedAccountPromotionKeys, normalizeCompatibilityConfig, resetMatrixThreadBindingsForTests, resolveSingleAccountPromotionTarget, secretTargetRegistryEntries, setMatrixRuntime, singleAccountKeysToMove };
@@ -0,0 +1,64 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
2
+ import { t as resolveValidatedMatrixHomeserverUrl } from "./url-validation-DiK9j7jz.js";
3
+ import { a as resolveMatrixStoragePaths, n as maybeMigrateLegacyStorage, o as writeStorageMeta } from "./storage-tC3ujLiW.js";
4
+ import "./config--5-S2Akv.js";
5
+ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
6
+ import fs from "node:fs";
7
+ import { ssrfPolicyFromDangerouslyAllowPrivateNetwork } from "openclaw/plugin-sdk/ssrf-runtime";
8
+ //#region extensions/matrix/src/matrix/client/create-client.ts
9
+ var create_client_exports = /* @__PURE__ */ __exportAll({ createMatrixClient: () => createMatrixClient });
10
+ let matrixCreateClientRuntimeDepsPromise;
11
+ async function loadMatrixCreateClientRuntimeDeps() {
12
+ matrixCreateClientRuntimeDepsPromise ??= Promise.all([import("./sdk-B2vZA27-.js").then((n) => n.n), import("./logging-DZHSPP5N.js").then((n) => n.n)]).then(([sdkModule, loggingModule]) => ({
13
+ MatrixClient: sdkModule.MatrixClient,
14
+ ensureMatrixSdkLoggingConfigured: loggingModule.ensureMatrixSdkLoggingConfigured
15
+ }));
16
+ return await matrixCreateClientRuntimeDepsPromise;
17
+ }
18
+ async function createMatrixClient(params) {
19
+ const { MatrixClient, ensureMatrixSdkLoggingConfigured } = await loadMatrixCreateClientRuntimeDeps();
20
+ ensureMatrixSdkLoggingConfigured();
21
+ const homeserver = await resolveValidatedMatrixHomeserverUrl(params.homeserver, { dangerouslyAllowPrivateNetwork: params.allowPrivateNetwork });
22
+ const matrixClientUserId = normalizeOptionalString(params.userId);
23
+ const userId = matrixClientUserId ?? "unknown";
24
+ const storagePaths = params.persistStorage !== false ? resolveMatrixStoragePaths({
25
+ homeserver,
26
+ userId,
27
+ accessToken: params.accessToken,
28
+ accountId: params.accountId,
29
+ deviceId: params.deviceId,
30
+ env: process.env
31
+ }) : null;
32
+ if (storagePaths) {
33
+ await maybeMigrateLegacyStorage({
34
+ storagePaths,
35
+ env: process.env
36
+ });
37
+ fs.mkdirSync(storagePaths.rootDir, { recursive: true });
38
+ writeStorageMeta({
39
+ storagePaths,
40
+ homeserver,
41
+ userId,
42
+ accountId: params.accountId,
43
+ deviceId: params.deviceId
44
+ });
45
+ }
46
+ const cryptoDatabasePrefix = storagePaths ? `openclaw-matrix-${storagePaths.accountKey}-${storagePaths.tokenHash}` : void 0;
47
+ return new MatrixClient(homeserver, params.accessToken, {
48
+ userId: matrixClientUserId,
49
+ password: params.password,
50
+ deviceId: params.deviceId,
51
+ encryption: params.encryption,
52
+ localTimeoutMs: params.localTimeoutMs,
53
+ initialSyncLimit: params.initialSyncLimit,
54
+ storagePath: storagePaths?.storagePath,
55
+ recoveryKeyPath: storagePaths?.recoveryKeyPath,
56
+ idbSnapshotPath: storagePaths?.idbSnapshotPath,
57
+ cryptoDatabasePrefix,
58
+ autoBootstrapCrypto: params.autoBootstrapCrypto,
59
+ ssrfPolicy: params.ssrfPolicy ?? ssrfPolicyFromDangerouslyAllowPrivateNetwork(params.allowPrivateNetwork),
60
+ dispatcherPolicy: params.dispatcherPolicy
61
+ });
62
+ }
63
+ //#endregion
64
+ export { create_client_exports as n, createMatrixClient as t };
@@ -0,0 +1,56 @@
1
+ import { a as resolveMatrixCredentialsDir, i as loadMatrixCredentials, n as credentialsMatchConfig, o as resolveMatrixCredentialsPath, t as clearMatrixCredentials } from "./credentials-read-cmHgousK.js";
2
+ import { t as createAsyncLock } from "./async-lock-uQfhfQIY.js";
3
+ import { writeJsonFileAtomically } from "openclaw/plugin-sdk/json-store";
4
+ //#region extensions/matrix/src/matrix/credentials.ts
5
+ const credentialWriteLocks = /* @__PURE__ */ new Map();
6
+ function withCredentialWriteLock(credPath, fn) {
7
+ let withLock = credentialWriteLocks.get(credPath);
8
+ if (!withLock) {
9
+ withLock = createAsyncLock();
10
+ credentialWriteLocks.set(credPath, withLock);
11
+ }
12
+ return withLock(fn);
13
+ }
14
+ async function writeMatrixCredentialsUnlocked(params) {
15
+ const now = (/* @__PURE__ */ new Date()).toISOString();
16
+ const toSave = {
17
+ ...params.credentials,
18
+ createdAt: params.existing?.createdAt ?? now,
19
+ lastUsedAt: now
20
+ };
21
+ await writeJsonFileAtomically(params.credPath, toSave);
22
+ }
23
+ async function saveMatrixCredentials(credentials, env = process.env, accountId) {
24
+ const credPath = resolveMatrixCredentialsPath(env, accountId);
25
+ await withCredentialWriteLock(credPath, async () => {
26
+ await writeMatrixCredentialsUnlocked({
27
+ credPath,
28
+ credentials,
29
+ existing: loadMatrixCredentials(env, accountId)
30
+ });
31
+ });
32
+ }
33
+ async function saveBackfilledMatrixDeviceId(credentials, env = process.env, accountId) {
34
+ const credPath = resolveMatrixCredentialsPath(env, accountId);
35
+ return await withCredentialWriteLock(credPath, async () => {
36
+ const existing = loadMatrixCredentials(env, accountId);
37
+ if (existing && (existing.homeserver !== credentials.homeserver || existing.userId !== credentials.userId || existing.accessToken !== credentials.accessToken)) return "skipped";
38
+ await writeMatrixCredentialsUnlocked({
39
+ credPath,
40
+ credentials,
41
+ existing
42
+ });
43
+ return "saved";
44
+ });
45
+ }
46
+ async function touchMatrixCredentials(env = process.env, accountId) {
47
+ const credPath = resolveMatrixCredentialsPath(env, accountId);
48
+ await withCredentialWriteLock(credPath, async () => {
49
+ const existing = loadMatrixCredentials(env, accountId);
50
+ if (!existing) return;
51
+ existing.lastUsedAt = (/* @__PURE__ */ new Date()).toISOString();
52
+ await writeJsonFileAtomically(credPath, existing);
53
+ });
54
+ }
55
+ //#endregion
56
+ export { clearMatrixCredentials, credentialsMatchConfig, loadMatrixCredentials, resolveMatrixCredentialsDir, resolveMatrixCredentialsPath, saveBackfilledMatrixDeviceId, saveMatrixCredentials, touchMatrixCredentials };
@@ -0,0 +1,112 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
2
+ import { a as resolveMatrixDefaultOrOnlyAccountId, n as requiresExplicitMatrixDefaultAccount } from "./account-selection-BWwIruri.js";
3
+ import { t as getMatrixRuntime } from "./runtime-Dog86njy.js";
4
+ import { a as resolveMatrixCredentialsPath$1, r as resolveMatrixCredentialsDir$1 } from "./storage-paths-BJLdnCjV.js";
5
+ import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
6
+ import fs from "node:fs";
7
+ import os from "node:os";
8
+ import path from "node:path";
9
+ //#region extensions/matrix/src/matrix/credentials-read.ts
10
+ var credentials_read_exports = /* @__PURE__ */ __exportAll({
11
+ clearMatrixCredentials: () => clearMatrixCredentials,
12
+ credentialsMatchConfig: () => credentialsMatchConfig,
13
+ loadMatrixCredentials: () => loadMatrixCredentials,
14
+ resolveMatrixCredentialsDir: () => resolveMatrixCredentialsDir,
15
+ resolveMatrixCredentialsPath: () => resolveMatrixCredentialsPath
16
+ });
17
+ function resolveStateDir(env) {
18
+ try {
19
+ return getMatrixRuntime().state.resolveStateDir(env, os.homedir);
20
+ } catch {
21
+ const override = env.OPENCLAW_STATE_DIR?.trim();
22
+ if (override) return path.resolve(override);
23
+ const homeDir = env.OPENCLAW_HOME?.trim() || env.HOME?.trim() || os.homedir();
24
+ return path.join(homeDir, ".openclaw");
25
+ }
26
+ }
27
+ function resolveLegacyMatrixCredentialsPath(env) {
28
+ return path.join(resolveMatrixCredentialsDir(env), "credentials.json");
29
+ }
30
+ function shouldReadLegacyCredentialsForAccount(accountId) {
31
+ const normalizedAccountId = normalizeAccountId(accountId);
32
+ const cfg = getMatrixRuntime().config.current();
33
+ if (!cfg.channels?.matrix || typeof cfg.channels.matrix !== "object") return normalizedAccountId === DEFAULT_ACCOUNT_ID;
34
+ if (requiresExplicitMatrixDefaultAccount(cfg)) return false;
35
+ return normalizeAccountId(resolveMatrixDefaultOrOnlyAccountId(cfg)) === normalizedAccountId;
36
+ }
37
+ function resolveLegacyMigrationSourcePath(env, accountId) {
38
+ if (!shouldReadLegacyCredentialsForAccount(accountId)) return null;
39
+ const legacyPath = resolveLegacyMatrixCredentialsPath(env);
40
+ return legacyPath === resolveMatrixCredentialsPath(env, accountId) ? null : legacyPath;
41
+ }
42
+ function parseMatrixCredentialsFile(filePath) {
43
+ const raw = fs.readFileSync(filePath, "utf-8");
44
+ const parsed = JSON.parse(raw);
45
+ if (typeof parsed.homeserver !== "string" || typeof parsed.userId !== "string" || typeof parsed.accessToken !== "string") return null;
46
+ return parsed;
47
+ }
48
+ function loadMatrixCredentialsFile(filePath, source) {
49
+ try {
50
+ return {
51
+ kind: "loaded",
52
+ source,
53
+ credentials: parseMatrixCredentialsFile(filePath)
54
+ };
55
+ } catch (error) {
56
+ if (error?.code === "ENOENT") return { kind: "missing" };
57
+ throw error;
58
+ }
59
+ }
60
+ function loadLegacyMatrixCredentialsWithCurrentFallback(params) {
61
+ const legacy = loadMatrixCredentialsFile(params.legacyPath, "legacy");
62
+ if (legacy.kind === "loaded") return legacy;
63
+ return loadMatrixCredentialsFile(params.currentPath, "current");
64
+ }
65
+ function resolveMatrixCredentialsDir(env = process.env, stateDir) {
66
+ return resolveMatrixCredentialsDir$1(stateDir ?? resolveStateDir(env));
67
+ }
68
+ function resolveMatrixCredentialsPath(env = process.env, accountId) {
69
+ return resolveMatrixCredentialsPath$1({
70
+ stateDir: resolveStateDir(env),
71
+ accountId
72
+ });
73
+ }
74
+ function loadMatrixCredentials(env = process.env, accountId) {
75
+ const currentPath = resolveMatrixCredentialsPath(env, accountId);
76
+ try {
77
+ const current = loadMatrixCredentialsFile(currentPath, "current");
78
+ if (current.kind === "loaded") return current.credentials;
79
+ const legacyPath = resolveLegacyMigrationSourcePath(env, accountId);
80
+ if (!legacyPath) return null;
81
+ const loaded = loadLegacyMatrixCredentialsWithCurrentFallback({
82
+ legacyPath,
83
+ currentPath
84
+ });
85
+ if (loaded.kind !== "loaded" || !loaded.credentials) return null;
86
+ if (loaded.source === "legacy") try {
87
+ fs.mkdirSync(path.dirname(currentPath), { recursive: true });
88
+ fs.renameSync(legacyPath, currentPath);
89
+ } catch {}
90
+ return loaded.credentials;
91
+ } catch {
92
+ return null;
93
+ }
94
+ }
95
+ function clearMatrixCredentials(env = process.env, accountId) {
96
+ const paths = [resolveMatrixCredentialsPath(env, accountId), resolveLegacyMigrationSourcePath(env, accountId)];
97
+ for (const filePath of paths) {
98
+ if (!filePath) continue;
99
+ try {
100
+ fs.unlinkSync(filePath);
101
+ } catch {}
102
+ }
103
+ }
104
+ function credentialsMatchConfig(stored, config) {
105
+ if (!config.userId) {
106
+ if (!config.accessToken) return false;
107
+ return stored.homeserver === config.homeserver && stored.accessToken === config.accessToken;
108
+ }
109
+ return stored.homeserver === config.homeserver && stored.userId === config.userId;
110
+ }
111
+ //#endregion
112
+ export { resolveMatrixCredentialsDir as a, loadMatrixCredentials as i, credentialsMatchConfig as n, resolveMatrixCredentialsPath as o, credentials_read_exports as r, clearMatrixCredentials as t };
@@ -0,0 +1,17 @@
1
+ //#region extensions/matrix/src/matrix/credentials-write.runtime.ts
2
+ let matrixCredentialsRuntimePromise;
3
+ function loadMatrixCredentialsRuntime() {
4
+ matrixCredentialsRuntimePromise ??= import("./credentials-DV6fWXhC.js");
5
+ return matrixCredentialsRuntimePromise;
6
+ }
7
+ async function saveMatrixCredentials(...args) {
8
+ return (await loadMatrixCredentialsRuntime()).saveMatrixCredentials(...args);
9
+ }
10
+ async function saveBackfilledMatrixDeviceId(...args) {
11
+ return (await loadMatrixCredentialsRuntime()).saveBackfilledMatrixDeviceId(...args);
12
+ }
13
+ async function touchMatrixCredentials(...args) {
14
+ return (await loadMatrixCredentialsRuntime()).touchMatrixCredentials(...args);
15
+ }
16
+ //#endregion
17
+ export { saveBackfilledMatrixDeviceId, saveMatrixCredentials, touchMatrixCredentials };
@@ -0,0 +1,12 @@
1
+ import { createRequire } from "node:module";
2
+ //#region extensions/matrix/src/matrix/sdk/crypto-node.runtime.ts
3
+ const require = createRequire(import.meta.url);
4
+ function loadMatrixCryptoNodeBindings() {
5
+ const { Attachment, EncryptedAttachment } = require("@matrix-org/matrix-sdk-crypto-nodejs");
6
+ return {
7
+ Attachment,
8
+ EncryptedAttachment
9
+ };
10
+ }
11
+ //#endregion
12
+ export { loadMatrixCryptoNodeBindings };