@openclaw/matrix 2026.8.1-beta.2 → 2026.8.1-beta.3

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 (51) hide show
  1. package/dist/api.js +6 -6
  2. package/dist/{approval-handler.runtime-CJXCUdRg.js → approval-handler.runtime-CSvueU9P.js} +5 -4
  3. package/dist/{approval-ids-7rf7etWE.js → approval-ids-CEcf-EiM.js} +1 -1
  4. package/dist/{approval-reaction-auth-wBwbEDpZ.js → approval-reaction-auth-CziKXatm.js} +1 -1
  5. package/dist/{channel-VSrHgTON.js → channel-CzQw5OZN.js} +228 -20
  6. package/dist/channel-plugin-api.js +1 -1
  7. package/dist/{channel.runtime-pOOL0uT_.js → channel.runtime-I9pBRQb3.js} +24 -14
  8. package/dist/{channel.setup-PpxRP9Du.js → channel.setup-aNaa3Uyn.js} +3 -9
  9. package/dist/{cli-CkTfKC_c.js → cli-iR6QJ5U0.js} +8 -8
  10. package/dist/{cli-metadata-B1d1aGM5.js → cli-metadata-BmUYWjuM.js} +1 -1
  11. package/dist/cli-metadata.js +1 -1
  12. package/dist/{client-CeGw0G5S.js → client-BBQdBG7t.js} +34 -19
  13. package/dist/{client-sJesKQmp.js → client-D8XghqmX.js} +2 -2
  14. package/dist/{client-bootstrap-BFwT_2VT.js → client-bootstrap-Co3RlItb.js} +1 -1
  15. package/dist/contract-api.js +2 -2
  16. package/dist/{directory-live-Bvg2wAnR.js → directory-live-DLQzel12.js} +2 -2
  17. package/dist/doctor-contract-api.js +7 -1
  18. package/dist/{draft-stream-BRi7PRRS.js → draft-stream-DQ7QNC-l.js} +1 -1
  19. package/dist/index.js +1 -1
  20. package/dist/{media-text-JudlYOSc.js → media-text-Dh-DpTc3.js} +4 -1
  21. package/dist/{messages-BW0s-6Y9.js → messages-DEqg7HVy.js} +27 -7
  22. package/dist/{monitor-Ddfc-vjX.js → monitor-FNrfkuWL.js} +33 -35
  23. package/dist/plugin-entry.handlers.runtime.js +1 -1
  24. package/dist/probe.runtime-NIJZYqc2.js +2 -0
  25. package/dist/{profile-update-BkgWYDIp.js → profile-update-BQlE5s2J.js} +1 -1
  26. package/dist/{reaction-events-nfUbFLdV.js → reaction-events-BKOLlnCo.js} +3 -3
  27. package/dist/{resolve-targets-BJAPY4Vb.js → resolve-targets-e7AI0P75.js} +2 -2
  28. package/dist/{resolver.runtime-LWJELYq5.js → resolver.runtime-V8u0pHEb.js} +1 -1
  29. package/dist/runtime-api.js +1 -1
  30. package/dist/{sdk-DjaQFCHc.js → sdk-NxK3vzMa.js} +17 -3
  31. package/dist/{send-ZDLU4JTk.js → send-ClHgDZLT.js} +11 -10
  32. package/dist/session-binding-contract-api.js +2 -3
  33. package/dist/{setup-bootstrap-BaXkhgJg.js → setup-bootstrap-BGPjbA5N.js} +1 -1
  34. package/dist/{setup-core-DQn6b5vi.js → setup-core-DigrLebY.js} +1 -1
  35. package/dist/setup-plugin-api.js +1 -1
  36. package/dist/{setup-surface-DlhJdrNI.js → setup-surface-Dtn8sAWs.js} +10 -9
  37. package/dist/subagent-hooks-CMoZaARG.js +48 -0
  38. package/dist/subagent-hooks-api.js +1 -1
  39. package/dist/{target-ids-B-5aQxwn.js → target-ids-Nwx7cMVE.js} +11 -1
  40. package/dist/{thread-binding-api-DRbBZlhS.js → thread-binding-api-CzkeLZCU.js} +1 -1
  41. package/dist/thread-binding-api.js +1 -1
  42. package/dist/{thread-bindings-CcHZP3w2.js → thread-bindings-BYEGfw3h.js} +11 -7
  43. package/dist/thread-bindings-runtime.js +1 -1
  44. package/dist/{thread-bindings-shared-CKnY4LSd.js → thread-bindings-shared-oNPiyMWY.js} +1 -6
  45. package/dist/{tool-actions.runtime-DmdRL0bN.js → tool-actions.runtime-ck6IJyP0.js} +8 -8
  46. package/dist/{verification-C7ig-bQE.js → verification-CabtBTtB.js} +1 -1
  47. package/openclaw.plugin.json +7 -0
  48. package/package.json +4 -4
  49. package/dist/probe.runtime-Dr91B_X3.js +0 -2
  50. package/dist/route-DY6at4qJ.js +0 -161
  51. package/dist/subagent-hooks-dkPAF6Et.js +0 -143
@@ -1,161 +0,0 @@
1
- import { n as MATRIX_REACTION_EVENT_TYPE } from "./reaction-common-DkrQdBSZ.js";
2
- import { buildAgentSessionKey, deriveLastRoutePolicy, resolveAgentIdFromSessionKey, resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
3
- import { resolveConfiguredAcpBindingRecord } from "openclaw/plugin-sdk/acp-binding-resolve-runtime";
4
- import { getSessionBindingService } from "openclaw/plugin-sdk/session-binding-runtime";
5
- //#region extensions/matrix/src/matrix/monitor/types.ts
6
- const EventType = {
7
- RoomMessage: "m.room.message",
8
- RoomMessageEncrypted: "m.room.encrypted",
9
- RoomMember: "m.room.member",
10
- Location: "m.location",
11
- Reaction: MATRIX_REACTION_EVENT_TYPE
12
- };
13
- const RelationType = {
14
- Replace: "m.replace",
15
- Thread: "m.thread"
16
- };
17
- //#endregion
18
- //#region extensions/matrix/src/matrix/monitor/threads.ts
19
- function resolveMatrixThreadSessionKeys(params) {
20
- return resolveThreadSessionKeys({
21
- ...params,
22
- normalizeThreadId: (threadId) => threadId
23
- });
24
- }
25
- function resolveMatrixRelatedReplyToEventId(relates) {
26
- if (!relates || typeof relates !== "object") return;
27
- if ("m.in_reply_to" in relates && typeof relates["m.in_reply_to"] === "object" && relates["m.in_reply_to"] && "event_id" in relates["m.in_reply_to"] && typeof relates["m.in_reply_to"].event_id === "string") return relates["m.in_reply_to"].event_id;
28
- }
29
- function resolveMatrixThreadRouting(params) {
30
- const effectiveThreadReplies = params.isDirectMessage && params.dmThreadReplies !== void 0 ? params.dmThreadReplies : params.threadReplies;
31
- const messageId = params.messageId.trim();
32
- const threadRootId = params.threadRootId?.trim();
33
- const inboundThreadId = threadRootId && threadRootId !== messageId ? threadRootId : void 0;
34
- return { threadId: effectiveThreadReplies === "off" ? void 0 : effectiveThreadReplies === "inbound" ? inboundThreadId : inboundThreadId ?? (messageId || void 0) };
35
- }
36
- function resolveMatrixThreadRootId(params) {
37
- const relates = params.content["m.relates_to"];
38
- if (!relates || typeof relates !== "object") return;
39
- if ("rel_type" in relates && relates.rel_type === RelationType.Thread) {
40
- if ("event_id" in relates && typeof relates.event_id === "string") return relates.event_id;
41
- return resolveMatrixRelatedReplyToEventId(relates);
42
- }
43
- }
44
- function resolveMatrixReplyToEventId(content) {
45
- return resolveMatrixRelatedReplyToEventId(content["m.relates_to"]);
46
- }
47
- //#endregion
48
- //#region extensions/matrix/src/matrix/monitor/route.ts
49
- function resolveMatrixDmSessionKey(params) {
50
- if (params.dmSessionScope !== "per-room") return params.fallbackSessionKey;
51
- return buildAgentSessionKey({
52
- agentId: params.agentId,
53
- channel: "matrix",
54
- accountId: params.accountId,
55
- peer: {
56
- kind: "channel",
57
- id: params.roomId
58
- }
59
- });
60
- }
61
- function shouldApplyMatrixPerRoomDmSessionScope(params) {
62
- return params.isDirectMessage && !params.configuredSessionKey;
63
- }
64
- function resolveMatrixInboundRoute(params) {
65
- const baseRoute = params.resolveAgentRoute({
66
- cfg: params.cfg,
67
- channel: "matrix",
68
- accountId: params.accountId,
69
- peer: {
70
- kind: params.isDirectMessage ? "direct" : "channel",
71
- id: params.isDirectMessage ? params.senderId : params.roomId
72
- },
73
- parentPeer: params.isDirectMessage ? {
74
- kind: "channel",
75
- id: params.roomId
76
- } : void 0
77
- });
78
- const bindingConversationId = params.threadId ?? params.roomId;
79
- const bindingParentConversationId = params.threadId ? params.roomId : void 0;
80
- const runtimeBinding = getSessionBindingService().resolveByConversation({
81
- channel: "matrix",
82
- accountId: params.accountId,
83
- conversationId: bindingConversationId,
84
- parentConversationId: bindingParentConversationId
85
- });
86
- const boundSessionKey = runtimeBinding?.targetSessionKey?.trim();
87
- if (runtimeBinding && boundSessionKey) return {
88
- route: {
89
- ...baseRoute,
90
- sessionKey: boundSessionKey,
91
- agentId: resolveAgentIdFromSessionKey(boundSessionKey) || baseRoute.agentId,
92
- lastRoutePolicy: deriveLastRoutePolicy({
93
- sessionKey: boundSessionKey,
94
- mainSessionKey: baseRoute.mainSessionKey
95
- }),
96
- matchedBy: "binding.channel"
97
- },
98
- configuredBinding: null,
99
- runtimeBindingId: runtimeBinding.bindingId
100
- };
101
- const configuredBinding = runtimeBinding == null ? resolveConfiguredAcpBindingRecord({
102
- cfg: params.cfg,
103
- channel: "matrix",
104
- accountId: params.accountId,
105
- conversationId: bindingConversationId,
106
- parentConversationId: bindingParentConversationId
107
- }) : null;
108
- const configuredSessionKey = configuredBinding?.record.targetSessionKey?.trim();
109
- const effectiveRoute = configuredBinding && configuredSessionKey ? {
110
- ...baseRoute,
111
- sessionKey: configuredSessionKey,
112
- agentId: resolveAgentIdFromSessionKey(configuredSessionKey) || configuredBinding.spec.agentId || baseRoute.agentId,
113
- lastRoutePolicy: deriveLastRoutePolicy({
114
- sessionKey: configuredSessionKey,
115
- mainSessionKey: baseRoute.mainSessionKey
116
- }),
117
- matchedBy: "binding.channel"
118
- } : baseRoute;
119
- const dmSessionKey = shouldApplyMatrixPerRoomDmSessionScope({
120
- isDirectMessage: params.isDirectMessage,
121
- configuredSessionKey
122
- }) ? resolveMatrixDmSessionKey({
123
- accountId: params.accountId,
124
- agentId: effectiveRoute.agentId,
125
- roomId: params.roomId,
126
- dmSessionScope: params.dmSessionScope,
127
- fallbackSessionKey: effectiveRoute.sessionKey
128
- }) : effectiveRoute.sessionKey;
129
- const routeWithDmScope = dmSessionKey === effectiveRoute.sessionKey ? effectiveRoute : {
130
- ...effectiveRoute,
131
- sessionKey: dmSessionKey,
132
- lastRoutePolicy: "session"
133
- };
134
- if (!configuredBinding && !configuredSessionKey && params.threadId) {
135
- const threadKeys = resolveMatrixThreadSessionKeys({
136
- baseSessionKey: routeWithDmScope.sessionKey,
137
- threadId: params.threadId,
138
- parentSessionKey: routeWithDmScope.sessionKey
139
- });
140
- return {
141
- route: {
142
- ...routeWithDmScope,
143
- sessionKey: threadKeys.sessionKey,
144
- mainSessionKey: threadKeys.parentSessionKey ?? routeWithDmScope.sessionKey,
145
- lastRoutePolicy: deriveLastRoutePolicy({
146
- sessionKey: threadKeys.sessionKey,
147
- mainSessionKey: threadKeys.parentSessionKey ?? routeWithDmScope.sessionKey
148
- })
149
- },
150
- configuredBinding,
151
- runtimeBindingId: null
152
- };
153
- }
154
- return {
155
- route: routeWithDmScope,
156
- configuredBinding,
157
- runtimeBindingId: null
158
- };
159
- }
160
- //#endregion
161
- export { EventType as a, resolveMatrixThreadRouting as i, resolveMatrixReplyToEventId as n, RelationType as o, resolveMatrixThreadRootId as r, resolveMatrixInboundRoute as t };
@@ -1,143 +0,0 @@
1
- import { a as resolveMatrixTargetIdentity } from "./target-ids-B-5aQxwn.js";
2
- import { a as listBindingsForAccount, c as resolveBindingKey, i as listAllBindings, n as getMatrixThreadBindingManager, o as removeBindingRecord } from "./thread-bindings-shared-CKnY4LSd.js";
3
- import { formatThreadBindingDisabledError, formatThreadBindingSpawnDisabledError, resolveThreadBindingSpawnPolicy } from "openclaw/plugin-sdk/conversation-runtime";
4
- import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
- import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
6
- import { getSessionBindingService } from "openclaw/plugin-sdk/conversation-binding-runtime";
7
- //#region extensions/matrix/src/matrix/subagent-hooks.ts
8
- function summarizeError(err) {
9
- if (err instanceof Error) return err.message;
10
- if (typeof err === "string") return err;
11
- return "error";
12
- }
13
- function resolveMatrixBindingThreadId(binding) {
14
- const { conversationId, parentConversationId } = binding.conversation;
15
- return parentConversationId && parentConversationId !== conversationId ? conversationId : void 0;
16
- }
17
- function resolveMatrixBindingDeliveryOrigin(binding, fallbackAccountId) {
18
- const boundRoomId = binding.conversation.parentConversationId ?? binding.conversation.conversationId;
19
- const threadId = resolveMatrixBindingThreadId(binding);
20
- return {
21
- channel: "matrix",
22
- accountId: binding.conversation.accountId ?? fallbackAccountId,
23
- to: `room:${boundRoomId}`,
24
- ...threadId ? { threadId } : {}
25
- };
26
- }
27
- async function handleMatrixSubagentSpawning(api, event) {
28
- if (!event.threadRequested) return;
29
- if (event.requester?.channel?.trim().toLowerCase() !== "matrix") return;
30
- const accountId = normalizeOptionalString(event.requester?.accountId) || DEFAULT_ACCOUNT_ID;
31
- const policy = resolveThreadBindingSpawnPolicy({
32
- cfg: api.config,
33
- channel: "matrix",
34
- accountId,
35
- kind: "subagent"
36
- });
37
- if (!policy.enabled) return {
38
- status: "error",
39
- error: formatThreadBindingDisabledError({
40
- channel: policy.channel,
41
- accountId: policy.accountId,
42
- kind: "subagent"
43
- })
44
- };
45
- if (!policy.spawnEnabled) return {
46
- status: "error",
47
- error: formatThreadBindingSpawnDisabledError({
48
- channel: policy.channel,
49
- accountId: policy.accountId,
50
- kind: "subagent"
51
- })
52
- };
53
- const rawTo = normalizeOptionalString(event.requester?.to) ?? "";
54
- const matrixTarget = rawTo ? resolveMatrixTargetIdentity(rawTo) : null;
55
- const roomId = matrixTarget?.kind === "room" ? matrixTarget.id : "";
56
- if (!roomId) return {
57
- status: "error",
58
- error: "Cannot create Matrix thread binding: no room target in spawn request (requester.to must be a Matrix room ID)."
59
- };
60
- const bindingService = getSessionBindingService();
61
- const capabilities = bindingService.getCapabilities({
62
- channel: "matrix",
63
- accountId
64
- });
65
- if (!capabilities.adapterAvailable || !capabilities.bindSupported) return {
66
- status: "error",
67
- error: `No Matrix session binding adapter available for account "${accountId}". Is the Matrix channel running?`
68
- };
69
- if (!capabilities.placements.includes("child")) return {
70
- status: "error",
71
- error: `Matrix session binding adapter for account "${accountId}" does not support child thread bindings.`
72
- };
73
- try {
74
- return {
75
- status: "ok",
76
- threadBindingReady: true,
77
- deliveryOrigin: resolveMatrixBindingDeliveryOrigin(await bindingService.bind({
78
- targetSessionKey: event.childSessionKey,
79
- targetKind: "subagent",
80
- conversation: {
81
- channel: "matrix",
82
- accountId,
83
- conversationId: roomId
84
- },
85
- placement: "child",
86
- metadata: {
87
- agentId: event.agentId?.trim() || void 0,
88
- label: normalizeOptionalString(event.label) || void 0,
89
- boundBy: "system"
90
- }
91
- }), accountId)
92
- };
93
- } catch (err) {
94
- return {
95
- status: "error",
96
- error: `Matrix thread bind failed: ${summarizeError(err)}`
97
- };
98
- }
99
- }
100
- async function handleMatrixSubagentEnded(event) {
101
- const accountId = normalizeOptionalString(event.accountId) || void 0;
102
- const matching = (accountId ? listBindingsForAccount(accountId) : listAllBindings()).filter((entry) => entry.targetSessionKey === event.targetSessionKey && entry.targetKind === "subagent");
103
- const removedBindingKeys = /* @__PURE__ */ new Set();
104
- if (event.sendFarewell) {
105
- const bindingService = getSessionBindingService();
106
- const reason = normalizeOptionalString(event.reason) || "subagent-ended";
107
- for (const binding of matching) {
108
- const bindingId = resolveBindingKey(binding);
109
- if ((await bindingService.unbind({
110
- bindingId,
111
- reason
112
- })).some((entry) => entry.bindingId === bindingId)) removedBindingKeys.add(bindingId);
113
- }
114
- }
115
- const affectedAccountIds = /* @__PURE__ */ new Set();
116
- for (const binding of matching) {
117
- if (removedBindingKeys.has(resolveBindingKey(binding))) continue;
118
- if (removeBindingRecord(binding)) affectedAccountIds.add(binding.accountId);
119
- }
120
- for (const acctId of affectedAccountIds) await getMatrixThreadBindingManager(acctId)?.persist();
121
- }
122
- function handleMatrixSubagentDeliveryTarget(event) {
123
- if (!event.expectsCompletionMessage) return;
124
- if (event.requesterOrigin?.channel?.trim().toLowerCase() !== "matrix") return;
125
- const requesterAccountId = normalizeOptionalString(event.requesterOrigin?.accountId);
126
- const requesterThreadId = event.requesterOrigin?.threadId != null && event.requesterOrigin.threadId !== "" ? String(event.requesterOrigin.threadId).trim() : "";
127
- const bindings = (requesterAccountId ? listBindingsForAccount(requesterAccountId) : listAllBindings()).filter((entry) => entry.targetSessionKey === event.childSessionKey && entry.targetKind === "subagent");
128
- if (bindings.length === 0) return;
129
- let binding;
130
- if (requesterThreadId) binding = bindings.find((entry) => entry.conversationId === requesterThreadId && (!requesterAccountId || entry.accountId === requesterAccountId));
131
- if (!binding && bindings.length === 1) binding = bindings[0];
132
- if (!binding) return;
133
- const roomId = binding.parentConversationId ?? binding.conversationId;
134
- const threadId = binding.parentConversationId && binding.parentConversationId !== binding.conversationId ? binding.conversationId : void 0;
135
- return { origin: {
136
- channel: "matrix",
137
- accountId: binding.accountId,
138
- to: `room:${roomId}`,
139
- ...threadId ? { threadId } : {}
140
- } };
141
- }
142
- //#endregion
143
- export { handleMatrixSubagentDeliveryTarget, handleMatrixSubagentEnded, handleMatrixSubagentSpawning };