Skip to content

Commit 441fbf1

Browse files
Merge 0eb3dc6 into a20c091
2 parents a20c091 + 0eb3dc6 commit 441fbf1

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

extensions/googlechat/src/channel.adapters.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import { adaptScopedAccountAccessor } from "openclaw/plugin-sdk/channel-config-helpers";
2+
import type {
3+
ChannelThreadingContext,
4+
ChannelThreadingToolContext,
5+
} from "openclaw/plugin-sdk/channel-contract";
26
import {
37
createMessageReceiptFromOutboundResults,
48
defineChannelMessageAdapter,
@@ -136,6 +140,30 @@ export const googlechatThreadingAdapter = {
136140
account.config.replyToMode,
137141
fallback: "off" as const,
138142
},
143+
buildToolContext: ({
144+
cfg,
145+
accountId,
146+
context,
147+
hasRepliedRef,
148+
}: {
149+
cfg: OpenClawConfig;
150+
accountId?: string | null;
151+
context: ChannelThreadingContext;
152+
hasRepliedRef?: { value: boolean };
153+
}): ChannelThreadingToolContext => {
154+
const currentChannelId = normalizeOptionalString(context.To);
155+
const replyToId = normalizeOptionalString(context.ReplyToId);
156+
const currentMessageId =
157+
replyToId ?? normalizeOptionalString(context.CurrentMessageId);
158+
159+
return {
160+
currentChannelId,
161+
currentMessageId,
162+
currentThreadTs: replyToId,
163+
replyToMode: resolveGoogleChatAccount({ cfg, accountId }).config.replyToMode,
164+
hasRepliedRef,
165+
};
166+
},
139167
};
140168

141169
export const googlechatPairingTextAdapter = {

extensions/googlechat/src/channel.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,36 @@ describe("googlechatPlugin threading", () => {
439439
googlechatThreadingAdapter.scopedAccountReplyToMode.resolveReplyToMode(defaultAccount),
440440
).toBe("all");
441441
});
442+
443+
it("uses the inbound thread resource as the current tool reply target", () => {
444+
const cfg = {
445+
channels: {
446+
googlechat: {
447+
replyToMode: "all",
448+
},
449+
},
450+
} as OpenClawConfig;
451+
const hasRepliedRef = { value: false };
452+
453+
const context = googlechatThreadingAdapter.buildToolContext({
454+
cfg,
455+
accountId: "default",
456+
context: {
457+
To: "spaces/AAA",
458+
CurrentMessageId: "spaces/AAA/messages/msg-1",
459+
ReplyToId: "spaces/AAA/threads/thread-1",
460+
},
461+
hasRepliedRef,
462+
});
463+
464+
expect(context).toMatchObject({
465+
currentChannelId: "spaces/AAA",
466+
currentMessageId: "spaces/AAA/threads/thread-1",
467+
currentThreadTs: "spaces/AAA/threads/thread-1",
468+
replyToMode: "all",
469+
hasRepliedRef,
470+
});
471+
});
442472
});
443473

444474
const resolveTarget = googlechatOutboundAdapter.base.resolveTarget;

0 commit comments

Comments
 (0)