|
| 1 | +import type { ChannelThreadingToolContext } from "openclaw/plugin-sdk/channel-contract"; |
1 | 2 | import { |
2 | 3 | dispatchInboundDirectDm, |
3 | 4 | recordChannelBotPairLoopAndCheckSuppression, |
@@ -94,6 +95,12 @@ function replyText(payload: unknown): string { |
94 | 95 | : ""; |
95 | 96 | } |
96 | 97 |
|
| 98 | +function matchesReefToolTarget(target: string, toolContext?: ChannelThreadingToolContext): boolean { |
| 99 | + const currentTarget = toolContext?.currentMessagingTarget ?? toolContext?.currentChannelId; |
| 100 | + const normalizedCurrent = normalizeReefTarget(currentTarget ?? ""); |
| 101 | + return normalizedCurrent !== undefined && normalizeReefTarget(target) === normalizedCurrent; |
| 102 | +} |
| 103 | + |
97 | 104 | export const reefPlugin: ChannelPlugin<ReefAccount> = { |
98 | 105 | id: "reef", |
99 | 106 | meta: { |
@@ -168,6 +175,26 @@ export const reefPlugin: ChannelPlugin<ReefAccount> = { |
168 | 175 | : null; |
169 | 176 | }, |
170 | 177 | }, |
| 178 | + threading: { |
| 179 | + threadAddressing: "message", |
| 180 | + matchesToolContextTarget: ({ target, toolContext }) => |
| 181 | + matchesReefToolTarget(target, toolContext), |
| 182 | + resolveReplyToMode: () => "all", |
| 183 | + buildToolContext: ({ context, hasRepliedRef }) => { |
| 184 | + const currentTarget = context.To?.trim() || undefined; |
| 185 | + return { |
| 186 | + currentChannelId: currentTarget, |
| 187 | + currentMessagingTarget: currentTarget, |
| 188 | + currentMessageId: context.CurrentMessageId, |
| 189 | + currentThreadTs: |
| 190 | + context.MessageThreadId != null ? String(context.MessageThreadId) : undefined, |
| 191 | + replyToMode: context.ReplyToMode ?? "all", |
| 192 | + hasRepliedRef, |
| 193 | + }; |
| 194 | + }, |
| 195 | + resolveAutoThreadId: ({ to, toolContext }) => |
| 196 | + matchesReefToolTarget(to, toolContext) ? toolContext?.currentThreadTs : undefined, |
| 197 | + }, |
171 | 198 | directory: createChannelDirectoryAdapter({ |
172 | 199 | listPeers: async ({ cfg, query, limit }) => |
173 | 200 | listTrustedPeerDirectoryEntries({ |
|
0 commit comments