

















@@ -157,3 +157,90 @@ describe("googlechat monitor bot loop protection", () => {
157157expect(runTurn).not.toHaveBeenCalled();
158158});
159159});
160+161+describe("googlechat monitor direct messages", () => {
162+it("omits thread metadata from DM reply context and typing messages", async () => {
163+const runTurn = vi.fn();
164+const buildContext = vi.fn((payload: unknown) => payload);
165+const core = {
166+logging: { shouldLogVerbose: () => false },
167+channel: {
168+routing: {
169+resolveAgentRoute: () => ({
170+agentId: "agent-1",
171+accountId: "work",
172+sessionKey: "session-1",
173+}),
174+},
175+session: {
176+resolveStorePath: () => "/tmp/openclaw-googlechat-test",
177+readSessionUpdatedAt: () => undefined,
178+recordInboundSession: vi.fn(),
179+},
180+reply: {
181+resolveEnvelopeFormatOptions: () => ({}),
182+formatAgentEnvelope: ({ body }: { body: string }) => body,
183+dispatchReplyWithBufferedBlockDispatcher: vi.fn(),
184+},
185+turn: { buildContext, run: runTurn },
186+},
187+} as unknown as GoogleChatCoreRuntime;
188+const runtime = { error: vi.fn(), log: vi.fn() } satisfies GoogleChatRuntimeEnv;
189+const account = {
190+accountId: "work",
191+config: {
192+typingIndicator: "message",
193+},
194+credentialSource: "inline",
195+} as ResolvedGoogleChatAccount;
196+const event = {
197+type: "MESSAGE",
198+eventTime: "2026-03-22T00:00:00.001Z",
199+space: { name: "spaces/DM", type: "DM" },
200+message: {
201+name: "spaces/DM/messages/2",
202+text: "hello",
203+thread: { name: "spaces/DM/threads/thread-1" },
204+sender: { name: "users/alice", displayName: "Alice", type: "HUMAN" },
205+},
206+} satisfies GoogleChatEvent;
207+208+accessMocks.applyGoogleChatInboundAccessPolicy.mockResolvedValue({
209+ok: true,
210+commandAuthorized: undefined,
211+effectiveWasMentioned: undefined,
212+groupBotLoopProtection: undefined,
213+groupSystemPrompt: undefined,
214+});
215+apiMocks.sendGoogleChatMessage.mockResolvedValue({
216+messageName: "spaces/DM/messages/typing",
217+});
218+219+await testing.processMessageWithPipeline({
220+ event,
221+ account,
222+config: {},
223+ runtime,
224+ core,
225+mediaMaxMb: 10,
226+});
227+228+expect(buildContext).toHaveBeenCalledWith(
229+expect.objectContaining({
230+reply: {
231+to: "googlechat:spaces/DM",
232+originatingTo: "googlechat:spaces/DM",
233+replyToId: undefined,
234+replyToIdFull: undefined,
235+},
236+}),
237+);
238+expect(apiMocks.sendGoogleChatMessage).toHaveBeenCalledWith({
239+ account,
240+space: "spaces/DM",
241+text: "_OpenClaw is typing..._",
242+thread: undefined,
243+});
244+expect(runTurn).toHaveBeenCalledOnce();
245+});
246+});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。