@openclaw/matrix 2026.8.1 → 2026.8.2

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 (74) hide show
  1. package/dist/{account-selection-C8nnBTxi.js → account-selection-DA-jfx22.js} +11 -9
  2. package/dist/{accounts-fC57n-Jo.js → accounts-DR1c4xF_.js} +2 -2
  3. package/dist/api.js +5 -5
  4. package/dist/{approval-handler.runtime-BBjFZw1t.js → approval-handler.runtime-xcVrZw9o.js} +5 -5
  5. package/dist/{approval-ids-DTIdXV-m.js → approval-ids-hmvhDNBj.js} +1 -1
  6. package/dist/{approval-reaction-auth-BDONXxnF.js → approval-reaction-auth-DziFGHSk.js} +2 -2
  7. package/dist/{approval-reactions-tXh9KYrW.js → approval-reactions-1fwEhoK9.js} +1 -1
  8. package/dist/{channel-BkEcVUs_.js → channel-D6-ajB_u.js} +51 -53
  9. package/dist/channel-plugin-api.js +1 -1
  10. package/dist/{channel.runtime-CTLSBFsP.js → channel.runtime-BMA0dG2k.js} +16 -12
  11. package/dist/{channel.setup-CSacbORr.js → channel.setup-OIEzCzSs.js} +21 -19
  12. package/dist/{cli-DRVtgrq5.js → cli-B6HF7Hmn.js} +38 -29
  13. package/dist/{cli-metadata-Ddx_y4Os.js → cli-metadata-Mtzu5-AY.js} +1 -1
  14. package/dist/cli-metadata.js +1 -1
  15. package/dist/{client-CZ_JvrO0.js → client-B0yMDho1.js} +2 -2
  16. package/dist/{client-kSi51NKp.js → client-DFsRJEgB.js} +69 -16
  17. package/dist/{client-bootstrap-D8irSL2i.js → client-bootstrap-DjXCKEtg.js} +1 -1
  18. package/dist/{config-update-DC0fWBxc.js → config-update-BnX26jCO.js} +46 -28
  19. package/dist/contract-api.js +2 -2
  20. package/dist/{credentials-BdAaWuiR.js → credentials-DJj2xs3q.js} +4 -8
  21. package/dist/{credentials-read-B37cQknZ.js → credentials-read-mexhw-Ur.js} +7 -5
  22. package/dist/{credentials-write.runtime-nAV2-5uR.js → credentials-write.runtime-DQt-kgJq.js} +1 -1
  23. package/dist/{crypto-runtime-C4WDYxlP.js → crypto-runtime-QvlgyCkj.js} +6 -6
  24. package/dist/{deps-CcVJfvRM.js → deps-mtxF2mHI.js} +1 -1
  25. package/dist/{directory-live-DKr0w35b.js → directory-live-Drh343TW.js} +8 -6
  26. package/dist/{doctor-EWf9CDso.js → doctor-CJE8wO6y.js} +1 -1
  27. package/dist/{doctor-contract-DEt4O4Zt.js → doctor-contract-HyWFZQVG.js} +5 -4
  28. package/dist/doctor-contract-api.js +7 -7
  29. package/dist/{draft-stream-0CEpNrBk.js → draft-stream-DhGHVdO4.js} +1 -1
  30. package/dist/{encryption-guidance-D4ZdAqzM.js → encryption-guidance-BNcZNQZI.js} +3 -2
  31. package/dist/helper-api.js +1 -1
  32. package/dist/{http-client-D8o8b9u6.js → http-client-DOmFvKvB.js} +10 -7
  33. package/dist/{idb-persistence-DfgW720p.js → idb-persistence-D4NGNQxt.js} +2 -2
  34. package/dist/{idb-persistence-lock-DAJ49nZX.js → idb-persistence-lock-B3fZXyF_.js} +1 -1
  35. package/dist/{inbound-dedupe-RvSLqdsz.js → inbound-dedupe-Ch33GU06.js} +1 -1
  36. package/dist/index.js +1 -1
  37. package/dist/{messages-DaGRt-tu.js → messages-DlMQaC02.js} +2 -2
  38. package/dist/{monitor-CLPbPcR9.js → monitor-U2LcVtHt.js} +49 -74
  39. package/dist/plugin-entry.handlers.runtime.js +1 -1
  40. package/dist/probe.runtime-CNo-5_iz.js +2 -0
  41. package/dist/{profile-update-zXVCMg7y.js → profile-update-CsyKA9jI.js} +5 -4
  42. package/dist/{profile-D-Wubo0A.js → profile-vmjsmhh4.js} +1 -1
  43. package/dist/{reaction-events-CjVUiqcY.js → reaction-events-lwNc5I1X.js} +8 -6
  44. package/dist/{resolve-targets-qG6gceps.js → resolve-targets-D3Eakgzs.js} +1 -1
  45. package/dist/{resolver.runtime-zX3TR3TN.js → resolver.runtime-DJQxR35r.js} +1 -1
  46. package/dist/{room-info-yheP1mod.js → room-info-DIU67XLP.js} +3 -3
  47. package/dist/runtime-api.js +2 -2
  48. package/dist/{sdk-TZYyo0XQ.js → sdk-Jl2CgAbJ.js} +518 -23
  49. package/dist/{send-BL_iH5Ox.js → send-DfS5ciUL.js} +13 -9
  50. package/dist/session-binding-contract-api.js +1 -1
  51. package/dist/{setup-bootstrap-D8M7FmcO.js → setup-bootstrap-CWoIWudw.js} +2 -2
  52. package/dist/{setup-core-r6L0nno-.js → setup-core-CZM496H-.js} +7 -6
  53. package/dist/setup-plugin-api.js +1 -1
  54. package/dist/{setup-surface-g174ElFO.js → setup-surface-DSZtOsWK.js} +83 -77
  55. package/dist/{startup-verification-Cs08ca8u.js → startup-verification-1Ney1mmI.js} +2 -2
  56. package/dist/{storage-BsGuHngK.js → storage-BVf4uucD.js} +5 -4
  57. package/dist/{subagent-hooks-CMoZaARG.js → subagent-hooks-DeICLbU5.js} +5 -1
  58. package/dist/subagent-hooks-api.js +1 -1
  59. package/dist/sync-cache-state-d-A_OhbU.js +234 -0
  60. package/dist/{thread-bindings-ERWNousC.js → thread-bindings-2HN2AyLu.js} +2 -2
  61. package/dist/{tool-actions.runtime-DcBCSwY4.js → tool-actions.runtime-CFZZPG5g.js} +225 -163
  62. package/dist/{verification-4vsW_WSn.js → verification-CD7k5vE9.js} +2 -2
  63. package/node_modules/matrix-js-sdk/lib/client.d.ts +2 -1
  64. package/node_modules/matrix-js-sdk/lib/client.js +6 -2
  65. package/node_modules/matrix-js-sdk/lib/sync.js +8 -8
  66. package/node_modules/matrix-js-sdk/src/client.ts +7 -3
  67. package/node_modules/matrix-js-sdk/src/sync.ts +8 -8
  68. package/node_modules/typebox/build/format/email.mjs +1 -1
  69. package/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
  70. package/node_modules/typebox/package.json +1 -1
  71. package/package.json +5 -5
  72. package/dist/file-sync-store-DjskBX2o.js +0 -436
  73. package/dist/probe.runtime-Bxpr1FFy.js +0 -2
  74. package/dist/recovery-key-store-CognuDys.js +0 -276
@@ -1,6 +1,6 @@
1
1
  import { a as resolveMatrixAccountConfig, n as hasExplicitMatrixAccountConfig } from "./account-config-CRsKoMqJ.js";
2
- import "./accounts-fC57n-Jo.js";
3
- import { n as bootstrapMatrixVerification } from "./verification-4vsW_WSn.js";
2
+ import "./accounts-DR1c4xF_.js";
3
+ import { n as bootstrapMatrixVerification } from "./verification-CD7k5vE9.js";
4
4
  import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
5
5
  //#region extensions/matrix/src/setup-bootstrap.ts
6
6
  async function maybeBootstrapNewEncryptedMatrixAccount(params) {
@@ -1,9 +1,9 @@
1
- import { s as resolveMatrixEnvAuthReadiness } from "./account-selection-C8nnBTxi.js";
1
+ import { s as resolveMatrixEnvAuthReadiness } from "./account-selection-DA-jfx22.js";
2
2
  import { a as resolveMatrixAccountConfig } from "./account-config-CRsKoMqJ.js";
3
- import { r as resolveDefaultMatrixAccountId } from "./accounts-fC57n-Jo.js";
3
+ import { r as resolveDefaultMatrixAccountId } from "./accounts-DR1c4xF_.js";
4
4
  import { t as resolveMatrixConfigFieldPath } from "./config-paths-CnREYb1Y.js";
5
- import { r as updateMatrixAccountConfig } from "./config-update-DC0fWBxc.js";
6
- import { t as isSupportedMatrixAvatarSource } from "./profile-D-Wubo0A.js";
5
+ import { r as updateMatrixAccountConfig } from "./config-update-BnX26jCO.js";
6
+ import { t as isSupportedMatrixAvatarSource } from "./profile-vmjsmhh4.js";
7
7
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
8
8
  import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
9
9
  import { DEFAULT_ACCOUNT_ID, addWildcardAllowFrom, applyAccountNameToChannelSection, normalizeAccountId, normalizeAllowFromEntries, normalizeSecretInputString, prepareScopedSetupConfig } from "openclaw/plugin-sdk/setup";
@@ -164,8 +164,9 @@ function validateMatrixSetupInput(params) {
164
164
  function applyMatrixSetupAccountConfig(params) {
165
165
  const input = params.input;
166
166
  const normalizedAccountId = normalizeAccountId(params.accountId);
167
+ const migratedCfg = normalizedAccountId !== DEFAULT_ACCOUNT_ID ? moveSingleMatrixAccountConfigToNamedAccount(params.cfg) : params.cfg;
167
168
  const next = applyAccountNameToChannelSection({
168
- cfg: normalizedAccountId !== DEFAULT_ACCOUNT_ID ? moveSingleMatrixAccountConfigToNamedAccount(params.cfg) : params.cfg,
169
+ cfg: migratedCfg,
169
170
  channelKey: channel$1,
170
171
  accountId: normalizedAccountId,
171
172
  name: input.name
@@ -310,7 +311,7 @@ const matrixSetupAdapter = {
310
311
  input
311
312
  }),
312
313
  afterAccountConfigWritten: async ({ previousCfg, cfg, accountId, runtime }) => {
313
- const { runMatrixSetupBootstrapAfterConfigWrite } = await import("./setup-bootstrap-D8M7FmcO.js");
314
+ const { runMatrixSetupBootstrapAfterConfigWrite } = await import("./setup-bootstrap-CWoIWudw.js");
314
315
  await runMatrixSetupBootstrapAfterConfigWrite({
315
316
  previousCfg,
316
317
  cfg,
@@ -1,2 +1,2 @@
1
- import { n as matrixSetupPlugin } from "./channel.setup-CSacbORr.js";
1
+ import { n as matrixSetupPlugin } from "./channel.setup-OIEzCzSs.js";
2
2
  export { matrixSetupPlugin };
@@ -1,12 +1,12 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { n as requiresExplicitMatrixDefaultAccount, s as resolveMatrixEnvAuthReadiness } from "./account-selection-C8nnBTxi.js";
2
+ import { n as requiresExplicitMatrixDefaultAccount, s as resolveMatrixEnvAuthReadiness } from "./account-selection-DA-jfx22.js";
3
3
  import { a as resolveMatrixAccountConfig } from "./account-config-CRsKoMqJ.js";
4
- import { i as resolveMatrixAccount, r as resolveDefaultMatrixAccountId, t as listMatrixAccountIds } from "./accounts-fC57n-Jo.js";
4
+ import { i as resolveMatrixAccount, r as resolveDefaultMatrixAccountId, t as listMatrixAccountIds } from "./accounts-DR1c4xF_.js";
5
5
  import { n as isMatrixRoomId } from "./target-ids-Nwx7cMVE.js";
6
- import { r as updateMatrixAccountConfig } from "./config-update-DC0fWBxc.js";
7
- import { a as moveSingleMatrixAccountConfigToNamedAccount, i as createMatrixSetupDmPolicy } from "./setup-core-r6L0nno-.js";
6
+ import { r as updateMatrixAccountConfig } from "./config-update-BnX26jCO.js";
7
+ import { a as moveSingleMatrixAccountConfigToNamedAccount, i as createMatrixSetupDmPolicy } from "./setup-core-CZM496H-.js";
8
8
  import { n as validateMatrixHomeserverUrl, r as isPrivateOrLoopbackHost, t as resolveValidatedMatrixHomeserverUrl } from "./url-validation-GRHde6lq.js";
9
- import { n as ensureMatrixSdkInstalled, r as isMatrixSdkAvailable } from "./deps-CcVJfvRM.js";
9
+ import { n as ensureMatrixSdkInstalled, r as isMatrixSdkAvailable } from "./deps-mtxF2mHI.js";
10
10
  import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeStringifiedOptionalString, normalizeUniqueStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
11
11
  import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
12
12
  import { formatDocsLink, hasConfiguredSecretInput, mergeAllowFromEntries, normalizeAccountId as normalizeAccountId$1, promptAccountId, promptChannelAccessConfig, splitSetupEntries } from "openclaw/plugin-sdk/setup";
@@ -68,12 +68,13 @@ async function promptMatrixAllowFrom(params) {
68
68
  }).configured;
69
69
  const isFullUserId = (value) => value.startsWith("@") && value.includes(":");
70
70
  while (true) {
71
- const parts = splitSetupEntries(await prompter.text({
71
+ const entry = await prompter.text({
72
72
  message: "Matrix allowFrom (full @user:server; display name only if unique)",
73
73
  placeholder: "@user:server",
74
74
  initialValue: existingAllowFrom[0] ? String(existingAllowFrom[0]) : void 0,
75
75
  validate: (value) => normalizeOptionalString(value) ? void 0 : "Required"
76
- }));
76
+ });
77
+ const parts = splitSetupEntries(entry);
77
78
  const resolvedIds = [];
78
79
  const pending = [];
79
80
  const unresolved = [];
@@ -90,7 +91,7 @@ async function promptMatrixAllowFrom(params) {
90
91
  pending.push(part);
91
92
  }
92
93
  if (pending.length > 0) {
93
- const { resolveMatrixTargets } = await import("./resolve-targets-qG6gceps.js").then((n) => n.n);
94
+ const { resolveMatrixTargets } = await import("./resolve-targets-D3Eakgzs.js").then((n) => n.n);
94
95
  const results = await resolveMatrixTargets({
95
96
  cfg,
96
97
  accountId,
@@ -158,14 +159,15 @@ async function configureMatrixInviteAutoJoin(params) {
158
159
  }
159
160
  if (policy === "always") return setMatrixAutoJoin(params.cfg, policy, [], accountId);
160
161
  while (true) {
161
- const allowlist = normalizeUniqueStringEntries(splitSetupEntries(await params.prompter.text({
162
+ const rawAllowlist = await params.prompter.text({
162
163
  message: "Matrix invite auto-join allowlist (comma-separated)",
163
164
  placeholder: "!roomId:server, !roomId, #alias:server, *",
164
165
  initialValue: currentAllowlist[0] ? currentAllowlist.join(", ") : void 0,
165
166
  validate: (value) => {
166
167
  return splitSetupEntries(value).length > 0 ? void 0 : "Required";
167
168
  }
168
- })));
169
+ });
170
+ const allowlist = normalizeUniqueStringEntries(splitSetupEntries(rawAllowlist));
169
171
  const invalidEntries = allowlist.filter((entry) => !isMatrixInviteAutoJoinTarget(entry));
170
172
  if (allowlist.length === 0 || invalidEntries.length > 0) {
171
173
  await params.prompter.note(["Use only stable Matrix invite targets for auto-join: !roomId:server (or the suffixless !roomId form on room version 12+), #alias:server, or *.", invalidEntries.length > 0 ? `Invalid: ${invalidEntries.join(", ")}` : void 0].filter(Boolean).join("\n"), "Matrix invite auto-join");
@@ -194,41 +196,43 @@ async function configureMatrixAccessPrompts(params) {
194
196
  placeholder: "!roomId:server, !roomId, #alias:server, Project Room",
195
197
  updatePrompt: Boolean(existingGroups)
196
198
  });
197
- if (accessConfig) if (accessConfig.policy !== "allowlist") next = updateMatrixAccountConfig(next, params.accountId, { groupPolicy: accessConfig.policy });
198
- else {
199
- let roomKeys = accessConfig.entries;
200
- if (accessConfig.entries.length > 0) try {
201
- const resolvedIds = [];
202
- const unresolved = [];
203
- for (const entry of accessConfig.entries) {
204
- const trimmed = normalizeOptionalString(entry) ?? "";
205
- if (!trimmed) continue;
206
- const cleaned = trimmed.replace(/^(room|channel):/i, "").trim();
207
- if (isMatrixRoomId(cleaned)) {
208
- resolvedIds.push(cleaned);
209
- continue;
199
+ if (accessConfig) {
200
+ if (accessConfig.policy !== "allowlist") next = updateMatrixAccountConfig(next, params.accountId, { groupPolicy: accessConfig.policy });
201
+ else {
202
+ let roomKeys = accessConfig.entries;
203
+ if (accessConfig.entries.length > 0) try {
204
+ const resolvedIds = [];
205
+ const unresolved = [];
206
+ for (const entry of accessConfig.entries) {
207
+ const trimmed = normalizeOptionalString(entry) ?? "";
208
+ if (!trimmed) continue;
209
+ const cleaned = trimmed.replace(/^(room|channel):/i, "").trim();
210
+ if (isMatrixRoomId(cleaned)) {
211
+ resolvedIds.push(cleaned);
212
+ continue;
213
+ }
214
+ const { listMatrixDirectoryGroupsLive } = await import("./directory-live-Drh343TW.js").then((n) => n.t);
215
+ const matches = await listMatrixDirectoryGroupsLive({
216
+ cfg: next,
217
+ accountId: params.accountId,
218
+ query: trimmed,
219
+ limit: 10
220
+ });
221
+ const best = matches.find((match) => normalizeLowercaseStringOrEmpty(match.name) === normalizeLowercaseStringOrEmpty(trimmed)) ?? matches[0];
222
+ if (best?.id) resolvedIds.push(best.id);
223
+ else unresolved.push(entry);
210
224
  }
211
- const { listMatrixDirectoryGroupsLive } = await import("./directory-live-DKr0w35b.js").then((n) => n.t);
212
- const matches = await listMatrixDirectoryGroupsLive({
213
- cfg: next,
214
- accountId: params.accountId,
215
- query: trimmed,
216
- limit: 10
217
- });
218
- const best = matches.find((match) => normalizeLowercaseStringOrEmpty(match.name) === normalizeLowercaseStringOrEmpty(trimmed)) ?? matches[0];
219
- if (best?.id) resolvedIds.push(best.id);
220
- else unresolved.push(entry);
225
+ roomKeys = [...resolvedIds, ...unresolved.map((entry) => normalizeOptionalString(entry)).filter((entry) => Boolean(entry))];
226
+ if (resolvedIds.length > 0 || unresolved.length > 0) await params.prompter.note([resolvedIds.length > 0 ? `Resolved: ${resolvedIds.join(", ")}` : void 0, unresolved.length > 0 ? `Unresolved (kept as typed): ${unresolved.join(", ")}` : void 0].filter(Boolean).join("\n"), "Matrix rooms");
227
+ } catch (err) {
228
+ await params.prompter.note(`Room lookup failed; keeping entries as typed. ${String(err)}`, "Matrix rooms");
221
229
  }
222
- roomKeys = [...resolvedIds, ...unresolved.map((entry) => normalizeOptionalString(entry)).filter((entry) => Boolean(entry))];
223
- if (resolvedIds.length > 0 || unresolved.length > 0) await params.prompter.note([resolvedIds.length > 0 ? `Resolved: ${resolvedIds.join(", ")}` : void 0, unresolved.length > 0 ? `Unresolved (kept as typed): ${unresolved.join(", ")}` : void 0].filter(Boolean).join("\n"), "Matrix rooms");
224
- } catch (err) {
225
- await params.prompter.note(`Room lookup failed; keeping entries as typed. ${String(err)}`, "Matrix rooms");
230
+ next = updateMatrixAccountConfig(next, params.accountId, {
231
+ groupPolicy: "allowlist",
232
+ groups: Object.fromEntries(roomKeys.map((key) => [key, { enabled: true }])),
233
+ rooms: null
234
+ });
226
235
  }
227
- next = updateMatrixAccountConfig(next, params.accountId, {
228
- groupPolicy: "allowlist",
229
- groups: Object.fromEntries(roomKeys.map((key) => [key, { enabled: true }])),
230
- rooms: null
231
- });
232
236
  }
233
237
  return await configureMatrixInviteAutoJoin({
234
238
  cfg: next,
@@ -335,40 +339,42 @@ async function runMatrixConfigure(params) {
335
339
  userId = "";
336
340
  }
337
341
  }
338
- if (!hasConfiguredSecretInput(accessToken) && !hasConfiguredSecretInput(password)) if (await params.prompter.select({
339
- message: "Matrix auth method",
340
- options: [{
341
- value: "token",
342
- label: "Access token (user ID fetched automatically)"
343
- }, {
344
- value: "password",
345
- label: "Password (requires user ID)"
346
- }]
347
- }) === "token") {
348
- accessToken = normalizeStringifiedOptionalString(await params.prompter.text({
349
- message: "Matrix access token",
350
- sensitive: true,
351
- validate: (value) => normalizeOptionalString(value) ? void 0 : "Required"
352
- })) ?? "";
353
- password = void 0;
354
- userId = "";
355
- } else {
356
- userId = normalizeStringifiedOptionalString(await params.prompter.text({
357
- message: "Matrix user ID",
358
- initialValue: existing.userId ?? envUserId,
359
- validate: (value) => {
360
- const raw = normalizeOptionalString(value) ?? "";
361
- if (!raw) return "Required";
362
- if (!raw.startsWith("@")) return "Matrix user IDs should start with @";
363
- if (!raw.includes(":")) return "Matrix user IDs should include a server (:server)";
364
- }
365
- })) ?? "";
366
- password = normalizeStringifiedOptionalString(await params.prompter.text({
367
- message: "Matrix password",
368
- sensitive: true,
369
- validate: (value) => normalizeOptionalString(value) ? void 0 : "Required"
370
- })) ?? "";
371
- accessToken = void 0;
342
+ if (!hasConfiguredSecretInput(accessToken) && !hasConfiguredSecretInput(password)) {
343
+ if (await params.prompter.select({
344
+ message: "Matrix auth method",
345
+ options: [{
346
+ value: "token",
347
+ label: "Access token (user ID fetched automatically)"
348
+ }, {
349
+ value: "password",
350
+ label: "Password (requires user ID)"
351
+ }]
352
+ }) === "token") {
353
+ accessToken = normalizeStringifiedOptionalString(await params.prompter.text({
354
+ message: "Matrix access token",
355
+ sensitive: true,
356
+ validate: (value) => normalizeOptionalString(value) ? void 0 : "Required"
357
+ })) ?? "";
358
+ password = void 0;
359
+ userId = "";
360
+ } else {
361
+ userId = normalizeStringifiedOptionalString(await params.prompter.text({
362
+ message: "Matrix user ID",
363
+ initialValue: existing.userId ?? envUserId,
364
+ validate: (value) => {
365
+ const raw = normalizeOptionalString(value) ?? "";
366
+ if (!raw) return "Required";
367
+ if (!raw.startsWith("@")) return "Matrix user IDs should start with @";
368
+ if (!raw.includes(":")) return "Matrix user IDs should include a server (:server)";
369
+ }
370
+ })) ?? "";
371
+ password = normalizeStringifiedOptionalString(await params.prompter.text({
372
+ message: "Matrix password",
373
+ sensitive: true,
374
+ validate: (value) => normalizeOptionalString(value) ? void 0 : "Required"
375
+ })) ?? "";
376
+ accessToken = void 0;
377
+ }
372
378
  }
373
379
  const deviceName = normalizeStringifiedOptionalString(await params.prompter.text({
374
380
  message: "Matrix device name (optional)",
@@ -458,7 +464,7 @@ const matrixOnboardingAdapter = {
458
464
  });
459
465
  },
460
466
  afterConfigWritten: async ({ previousCfg, cfg, accountId, runtime }) => {
461
- const { runMatrixSetupBootstrapAfterConfigWrite } = await import("./setup-bootstrap-D8M7FmcO.js");
467
+ const { runMatrixSetupBootstrapAfterConfigWrite } = await import("./setup-bootstrap-CWoIWudw.js");
462
468
  await runMatrixSetupBootstrapAfterConfigWrite({
463
469
  previousCfg,
464
470
  cfg,
@@ -1,5 +1,5 @@
1
1
  import { t as getMatrixRuntime } from "./runtime-6S3DNFNv.js";
2
- import { M as resolveMatrixSqliteStateEnv, l as resolveMatrixStoragePaths, o as recordCurrentStorageMetaDeviceId } from "./storage-BsGuHngK.js";
2
+ import { M as resolveMatrixSqliteStateEnv, l as resolveMatrixStoragePaths, o as recordCurrentStorageMetaDeviceId } from "./storage-BVf4uucD.js";
3
3
  import { createHash } from "node:crypto";
4
4
  import path from "node:path";
5
5
  import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
@@ -13,7 +13,7 @@ const STARTUP_VERIFICATION_MIGRATIONS_NAMESPACE = "startup-verification-migratio
13
13
  const STARTUP_VERIFICATION_MAX_ENTRIES = 1e3;
14
14
  const DEFAULT_STARTUP_VERIFICATION_MODE = "if-unverified";
15
15
  const DEFAULT_STARTUP_VERIFICATION_COOLDOWN_HOURS = 24;
16
- const DEFAULT_STARTUP_VERIFICATION_FAILURE_COOLDOWN_MS = 3600 * 1e3;
16
+ const DEFAULT_STARTUP_VERIFICATION_FAILURE_COOLDOWN_MS = 36e5;
17
17
  function normalizeCooldownHours(value) {
18
18
  if (typeof value !== "number" || !Number.isFinite(value)) return DEFAULT_STARTUP_VERIFICATION_COOLDOWN_HOURS;
19
19
  return Math.max(0, value);
@@ -33,7 +33,7 @@ const LEGACY_CRYPTO_MIGRATION_NAMESPACE = "legacy-crypto-migration";
33
33
  const IDB_SNAPSHOT_NAMESPACE = "idb-snapshot";
34
34
  const SMALL_STATE_MAX_ENTRIES = 10;
35
35
  const IDB_SNAPSHOT_MAX_ENTRIES = 2e4;
36
- const IDB_SNAPSHOT_MAX_CHUNKS = Math.floor((IDB_SNAPSHOT_MAX_ENTRIES - 1) / 2);
36
+ const IDB_SNAPSHOT_MAX_CHUNKS = Math.floor(19999 / 2);
37
37
  const IDB_SNAPSHOT_CHUNK_BYTES = 24e3;
38
38
  const MATRIX_RECOVERY_KEY_FILENAME = "recovery-key.json";
39
39
  const MATRIX_LEGACY_CRYPTO_MIGRATION_FILENAME = "legacy-crypto-migration.json";
@@ -487,8 +487,9 @@ function resolvePreferredMatrixStorageRoot(params) {
487
487
  }
488
488
  function resolveMatrixStoragePaths(params) {
489
489
  const env = params.env ?? process.env;
490
+ const stateDir = params.stateDir ?? getMatrixRuntime().state.resolveStateDir(env, os.homedir);
490
491
  const canonical = resolveMatrixAccountStorageRoot({
491
- stateDir: params.stateDir ?? getMatrixRuntime().state.resolveStateDir(env, os.homedir),
492
+ stateDir,
492
493
  homeserver: params.homeserver,
493
494
  userId: params.userId,
494
495
  accessToken: params.accessToken,
@@ -526,7 +527,7 @@ function resolveMatrixStateFilePath(params) {
526
527
  }
527
528
  async function maybeMigrateLegacyStorage(params) {
528
529
  const hasAccountScopedLegacyStorageFile = fs.existsSync(params.storagePaths.storagePath);
529
- const syncCache = hasAccountScopedLegacyStorageFile ? await import("./file-sync-store-DjskBX2o.js").then((n) => n.n) : null;
530
+ const syncCache = hasAccountScopedLegacyStorageFile ? await import("./sync-cache-state-d-A_OhbU.js").then((n) => n.s) : null;
530
531
  const hasAccountScopedLegacyStorage = hasAccountScopedLegacyStorageFile && await syncCache?.readLegacyMatrixSyncCacheState(params.storagePaths.rootDir) !== null;
531
532
  const hasAccountScopedRecoveryKey = fs.existsSync(params.storagePaths.recoveryKeyPath);
532
533
  const hasAccountScopedLegacyCryptoMigration = fs.existsSync(path.join(params.storagePaths.rootDir, MATRIX_LEGACY_CRYPTO_MIGRATION_FILENAME));
@@ -573,7 +574,7 @@ async function maybeMigrateLegacyStorage(params) {
573
574
  if (skippedExistingTargets.length > 0) logger.warn?.(`matrix: legacy client storage files were left in place because their migrated targets already existed.\n${skippedExistingTargets.join("\n")}`);
574
575
  }
575
576
  async function migrateLegacySyncCacheToSqlite(params) {
576
- const syncCache = await import("./file-sync-store-DjskBX2o.js").then((n) => n.n);
577
+ const syncCache = await import("./sync-cache-state-d-A_OhbU.js").then((n) => n.s);
577
578
  const persisted = await syncCache.readLegacyMatrixSyncCacheState(params.sourceRootDir);
578
579
  if (!persisted) return;
579
580
  const store = getMatrixRuntime().state.openKeyedStore(syncCache.openMatrixSyncCacheStoreOptions(params.targetRootDir));
@@ -13,7 +13,11 @@ async function handleMatrixSubagentEnded(event) {
13
13
  const bindingId = resolveBindingKey(binding);
14
14
  if ((await bindingService.unbind({
15
15
  bindingId,
16
- reason
16
+ reason,
17
+ scope: {
18
+ channel: "matrix",
19
+ accountId: binding.accountId
20
+ }
17
21
  })).some((entry) => entry.bindingId === bindingId)) removedBindingKeys.add(bindingId);
18
22
  }
19
23
  }
@@ -1,6 +1,6 @@
1
1
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
2
2
  //#region extensions/matrix/subagent-hooks-api.ts
3
- const loadMatrixSubagentHooksModule = createLazyRuntimeModule(() => import("./subagent-hooks-CMoZaARG.js"));
3
+ const loadMatrixSubagentHooksModule = createLazyRuntimeModule(() => import("./subagent-hooks-DeICLbU5.js"));
4
4
  function registerMatrixSubagentHooks(api) {
5
5
  api.on("subagent_ended", async (event) => {
6
6
  const { handleMatrixSubagentEnded } = await loadMatrixSubagentHooksModule();
@@ -0,0 +1,234 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
+ import { M as resolveMatrixSqliteStateEnv } from "./storage-BVf4uucD.js";
3
+ import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
4
+ import { createHash, randomUUID } from "node:crypto";
5
+ import path from "node:path";
6
+ import fs from "node:fs/promises";
7
+ //#region extensions/matrix/src/matrix/client/sync-cache-state.ts
8
+ var sync_cache_state_exports = /* @__PURE__ */ __exportAll({
9
+ MATRIX_SYNC_CACHE_VERSION: () => 1,
10
+ deleteMatrixSyncCacheStateFromSyncStore: () => deleteMatrixSyncCacheStateFromSyncStore,
11
+ hasMatrixSyncCacheStateInStore: () => hasMatrixSyncCacheStateInStore,
12
+ openMatrixSyncCacheStoreOptions: () => openMatrixSyncCacheStoreOptions,
13
+ readLegacyMatrixSyncCacheState: () => readLegacyMatrixSyncCacheState,
14
+ readPersistedStoreFromSyncStore: () => readPersistedStoreFromSyncStore,
15
+ writeMatrixSyncCacheStateToStore: () => writeMatrixSyncCacheStateToStore,
16
+ writeMatrixSyncCacheStateToSyncStore: () => writeMatrixSyncCacheStateToSyncStore
17
+ });
18
+ const MATRIX_SYNC_CACHE_VERSION = 1;
19
+ const SYNC_CACHE_NAMESPACE = "sync-cache";
20
+ const SYNC_CACHE_MAX_ENTRIES = 2e4;
21
+ const SYNC_CACHE_MAX_CHUNKS = Math.floor(19999 / 2);
22
+ const SYNC_CACHE_STATE_KEY = "current";
23
+ const SYNC_CACHE_CHUNK_BYTES = 24e3;
24
+ function normalizeRoomsData(value) {
25
+ if (!isRecord(value)) return null;
26
+ return {
27
+ join: isRecord(value.join) ? value.join : {},
28
+ invite: isRecord(value.invite) ? value.invite : {},
29
+ leave: isRecord(value.leave) ? value.leave : {},
30
+ knock: isRecord(value.knock) ? value.knock : {}
31
+ };
32
+ }
33
+ function toPersistedSyncData(value) {
34
+ if (!isRecord(value)) return null;
35
+ if (typeof value.nextBatch === "string" && value.nextBatch.trim()) {
36
+ const roomsData = normalizeRoomsData(value.roomsData);
37
+ if (!Array.isArray(value.accountData) || !roomsData) return null;
38
+ return {
39
+ nextBatch: value.nextBatch,
40
+ accountData: value.accountData,
41
+ roomsData
42
+ };
43
+ }
44
+ if (typeof value.next_batch === "string" && value.next_batch.trim()) {
45
+ const roomsData = normalizeRoomsData(value.rooms);
46
+ if (!roomsData) return null;
47
+ return {
48
+ nextBatch: value.next_batch,
49
+ accountData: isRecord(value.account_data) && Array.isArray(value.account_data.events) ? value.account_data.events : [],
50
+ roomsData
51
+ };
52
+ }
53
+ return null;
54
+ }
55
+ function normalizePersistedStore(value) {
56
+ if (!isRecord(value) || value.version !== 1) return null;
57
+ return {
58
+ version: 1,
59
+ savedSync: toPersistedSyncData(value.savedSync),
60
+ clientOptions: isRecord(value.clientOptions) ? value.clientOptions : void 0,
61
+ cleanShutdown: value.cleanShutdown === true
62
+ };
63
+ }
64
+ function normalizeLegacyPersistedStore(value) {
65
+ const persisted = normalizePersistedStore(value);
66
+ if (persisted) return persisted;
67
+ return {
68
+ version: 1,
69
+ savedSync: toPersistedSyncData(value),
70
+ cleanShutdown: false
71
+ };
72
+ }
73
+ function readPersistedStoreFromSyncStore(store) {
74
+ const stateKey = SYNC_CACHE_STATE_KEY;
75
+ const meta = store.lookup(metaKey(stateKey));
76
+ if (!isSyncCacheMeta(meta)) return null;
77
+ const chunks = [];
78
+ for (let index = 0; index < meta.chunkCount; index += 1) {
79
+ const chunk = store.lookup(chunkKey(stateKey, meta.generation, index));
80
+ if (!isSyncCacheChunk(chunk) || chunk.index !== index) return normalizePersistedStore({
81
+ version: 1,
82
+ savedSync: null,
83
+ clientOptions: meta.clientOptions,
84
+ cleanShutdown: false
85
+ });
86
+ chunks.push(chunk.data);
87
+ }
88
+ let savedSync = null;
89
+ if (chunks.length > 0) {
90
+ const syncJson = chunks.join("");
91
+ if (meta.syncDigest !== digestText(syncJson)) return normalizePersistedStore({
92
+ version: 1,
93
+ savedSync: null,
94
+ clientOptions: meta.clientOptions,
95
+ cleanShutdown: false
96
+ });
97
+ try {
98
+ savedSync = toPersistedSyncData(JSON.parse(syncJson));
99
+ } catch {
100
+ savedSync = null;
101
+ }
102
+ }
103
+ return normalizePersistedStore({
104
+ version: 1,
105
+ savedSync,
106
+ clientOptions: meta.clientOptions,
107
+ cleanShutdown: meta.cleanShutdown
108
+ });
109
+ }
110
+ function metaKey(stateKey) {
111
+ return `${stateKey}:meta`;
112
+ }
113
+ function chunkKeyPrefix(stateKey) {
114
+ return `${stateKey}:sync:`;
115
+ }
116
+ function chunkKey(stateKey, generation, index) {
117
+ return `${chunkKeyPrefix(stateKey)}${generation}:${index}`;
118
+ }
119
+ function resolveLegacySyncCachePath(storageRootDir) {
120
+ return path.join(storageRootDir, "bot-storage.json");
121
+ }
122
+ function digestText(value) {
123
+ return createHash("sha256").update(value, "utf8").digest("hex");
124
+ }
125
+ function isSyncCacheMeta(value) {
126
+ return isRecord(value) && value.kind === "meta" && value.version === 1 && typeof value.generation === "string" && value.generation.trim() !== "" && typeof value.chunkCount === "number" && Number.isSafeInteger(value.chunkCount) && value.chunkCount >= 0 && value.chunkCount <= SYNC_CACHE_MAX_CHUNKS;
127
+ }
128
+ function isSyncCacheChunk(value) {
129
+ return isRecord(value) && value.kind === "sync-chunk" && typeof value.index === "number" && Number.isSafeInteger(value.index) && value.index >= 0 && typeof value.data === "string";
130
+ }
131
+ function chunkSyncCacheJson(value) {
132
+ const chunks = [];
133
+ const pushChunk = (chunk) => {
134
+ if (chunks.length >= SYNC_CACHE_MAX_CHUNKS) throw new Error("Matrix sync cache exceeds SQLite chunk limit");
135
+ chunks.push(chunk);
136
+ };
137
+ let current = "";
138
+ let currentBytes = 0;
139
+ for (const char of value) {
140
+ const charBytes = Buffer.byteLength(char, "utf8");
141
+ if (current && currentBytes + charBytes > SYNC_CACHE_CHUNK_BYTES) {
142
+ pushChunk(current);
143
+ current = "";
144
+ currentBytes = 0;
145
+ }
146
+ current += char;
147
+ currentBytes += charBytes;
148
+ }
149
+ if (current) pushChunk(current);
150
+ return chunks;
151
+ }
152
+ function buildSyncCacheRows(stateKey, payload) {
153
+ const generation = randomUUID().replaceAll("-", "");
154
+ const syncJson = payload.savedSync ? JSON.stringify(payload.savedSync) : "";
155
+ const chunks = (syncJson ? chunkSyncCacheJson(syncJson) : []).map((data, index) => ({
156
+ key: chunkKey(stateKey, generation, index),
157
+ value: {
158
+ kind: "sync-chunk",
159
+ index,
160
+ data
161
+ }
162
+ }));
163
+ return {
164
+ chunks,
165
+ nextChunkKeys: new Set(chunks.map((chunk) => chunk.key)),
166
+ meta: {
167
+ key: metaKey(stateKey),
168
+ value: {
169
+ kind: "meta",
170
+ version: 1,
171
+ generation,
172
+ chunkCount: chunks.length,
173
+ ...syncJson ? { syncDigest: digestText(syncJson) } : {},
174
+ ...payload.clientOptions ? { clientOptions: payload.clientOptions } : {},
175
+ cleanShutdown: payload.cleanShutdown === true
176
+ }
177
+ }
178
+ };
179
+ }
180
+ async function readLegacyMatrixSyncCacheState(storageRootDir) {
181
+ try {
182
+ const raw = await fs.readFile(resolveLegacySyncCachePath(storageRootDir), "utf8");
183
+ const persisted = normalizeLegacyPersistedStore(JSON.parse(raw));
184
+ if (!persisted?.savedSync && !persisted?.clientOptions) return null;
185
+ return persisted;
186
+ } catch {
187
+ return null;
188
+ }
189
+ }
190
+ async function hasMatrixSyncCacheStateInStore(params) {
191
+ const stateKey = SYNC_CACHE_STATE_KEY;
192
+ const meta = await params.store.lookup(metaKey(stateKey));
193
+ if (!isSyncCacheMeta(meta) || meta.chunkCount <= 0) return false;
194
+ const chunks = [];
195
+ for (let index = 0; index < meta.chunkCount; index += 1) {
196
+ const chunk = await params.store.lookup(chunkKey(stateKey, meta.generation, index));
197
+ if (!isSyncCacheChunk(chunk) || chunk.index !== index) return false;
198
+ chunks.push(chunk.data);
199
+ }
200
+ const syncJson = chunks.join("");
201
+ if (meta.syncDigest !== digestText(syncJson)) return false;
202
+ try {
203
+ return toPersistedSyncData(JSON.parse(syncJson)) !== null;
204
+ } catch {
205
+ return false;
206
+ }
207
+ }
208
+ async function writeMatrixSyncCacheStateToStore(params) {
209
+ const stateKey = SYNC_CACHE_STATE_KEY;
210
+ const rows = buildSyncCacheRows(stateKey, params.payload);
211
+ for (const row of rows.chunks) await params.store.register(row.key, row.value);
212
+ await params.store.register(rows.meta.key, rows.meta.value);
213
+ for (const row of await params.store.entries()) if (row.key.startsWith(chunkKeyPrefix(stateKey)) && !rows.nextChunkKeys.has(row.key)) await params.store.delete(row.key);
214
+ }
215
+ function openMatrixSyncCacheStoreOptions(storageRootDir) {
216
+ return {
217
+ namespace: SYNC_CACHE_NAMESPACE,
218
+ maxEntries: SYNC_CACHE_MAX_ENTRIES,
219
+ env: resolveMatrixSqliteStateEnv({ stateDir: storageRootDir })
220
+ };
221
+ }
222
+ function writeMatrixSyncCacheStateToSyncStore(params) {
223
+ const rows = buildSyncCacheRows(SYNC_CACHE_STATE_KEY, params.payload);
224
+ for (const row of rows.chunks) params.store.register(row.key, row.value);
225
+ params.store.register(rows.meta.key, rows.meta.value);
226
+ for (const row of params.store.entries()) if (row.key.startsWith(chunkKeyPrefix(SYNC_CACHE_STATE_KEY)) && !rows.nextChunkKeys.has(row.key)) params.store.delete(row.key);
227
+ }
228
+ async function deleteMatrixSyncCacheStateFromSyncStore(params) {
229
+ params.store.delete(metaKey(SYNC_CACHE_STATE_KEY));
230
+ for (const row of params.store.entries()) if (row.key.startsWith(chunkKeyPrefix(SYNC_CACHE_STATE_KEY))) params.store.delete(row.key);
231
+ await fs.rm(resolveLegacySyncCachePath(params.storageRootDir), { force: true }).catch(() => void 0);
232
+ }
233
+ //#endregion
234
+ export { readLegacyMatrixSyncCacheState as a, writeMatrixSyncCacheStateToStore as c, openMatrixSyncCacheStoreOptions as i, writeMatrixSyncCacheStateToSyncStore as l, deleteMatrixSyncCacheStateFromSyncStore as n, readPersistedStoreFromSyncStore as o, hasMatrixSyncCacheStateInStore as r, sync_cache_state_exports as s, MATRIX_SYNC_CACHE_VERSION as t };
@@ -1,7 +1,7 @@
1
1
  import { t as getMatrixRuntime } from "./runtime-6S3DNFNv.js";
2
2
  import { a as listBindingsForAccount, c as resolveEffectiveBindingExpiry, d as setMatrixThreadBindingManagerEntry, l as setBindingRecord, m as toSessionBindingRecord, o as removeBindingRecord, p as toMatrixBindingTargetKind, r as getMatrixThreadBindingManagerEntry, s as resolveBindingKey, t as deleteMatrixThreadBindingManagerEntry } from "./thread-bindings-shared-oNPiyMWY.js";
3
- import { M as resolveMatrixSqliteStateEnv, N as resolveMatrixSqliteStateKey, c as resolveMatrixStateFilePath, t as claimCurrentTokenStorageState } from "./storage-BsGuHngK.js";
4
- import { r as sendMessageMatrix } from "./send-BL_iH5Ox.js";
3
+ import { M as resolveMatrixSqliteStateEnv, N as resolveMatrixSqliteStateKey, c as resolveMatrixStateFilePath, t as claimCurrentTokenStorageState } from "./storage-BVf4uucD.js";
4
+ import { r as sendMessageMatrix } from "./send-DfS5ciUL.js";
5
5
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
6
6
  import { createHash } from "node:crypto";
7
7
  import path from "node:path";