


















@@ -243,4 +243,77 @@ describe("googlechat monitor direct messages", () => {
243243});
244244expect(runTurn).toHaveBeenCalledOnce();
245245});
246+247+it("drops invalid event timestamps from inbound runtime payloads", async () => {
248+const runTurn = vi.fn();
249+const buildContext = vi.fn((payload: unknown) => payload);
250+const formatAgentEnvelope = vi.fn(({ body }: { body: string }) => body);
251+const core = {
252+logging: { shouldLogVerbose: () => false },
253+channel: {
254+routing: {
255+resolveAgentRoute: () => ({
256+agentId: "agent-1",
257+accountId: "work",
258+sessionKey: "session-1",
259+}),
260+},
261+session: {
262+resolveStorePath: () => "/tmp/openclaw-googlechat-test",
263+readSessionUpdatedAt: () => undefined,
264+recordInboundSession: vi.fn(),
265+},
266+reply: {
267+resolveEnvelopeFormatOptions: () => ({}),
268+ formatAgentEnvelope,
269+dispatchReplyWithBufferedBlockDispatcher: vi.fn(),
270+},
271+inbound: { buildContext, run: runTurn },
272+},
273+} as unknown as GoogleChatCoreRuntime;
274+const runtime = { error: vi.fn(), log: vi.fn() } satisfies GoogleChatRuntimeEnv;
275+const account = {
276+accountId: "work",
277+config: {
278+typingIndicator: "message",
279+},
280+credentialSource: "inline",
281+} as ResolvedGoogleChatAccount;
282+const event = {
283+type: "MESSAGE",
284+eventTime: "not-a-timestamp",
285+space: { name: "spaces/DM", type: "DM" },
286+message: {
287+name: "spaces/DM/messages/2",
288+text: "hello",
289+sender: { name: "users/alice", displayName: "Alice", type: "HUMAN" },
290+},
291+} satisfies GoogleChatEvent;
292+293+accessMocks.applyGoogleChatInboundAccessPolicy.mockResolvedValue({
294+ok: true,
295+commandAuthorized: undefined,
296+effectiveWasMentioned: undefined,
297+groupBotLoopProtection: undefined,
298+groupSystemPrompt: undefined,
299+});
300+301+await testing.processMessageWithPipeline({
302+ event,
303+ account,
304+config: {},
305+ runtime,
306+ core,
307+mediaMaxMb: 10,
308+});
309+310+expect(formatAgentEnvelope).toHaveBeenCalledWith(
311+expect.objectContaining({ timestamp: undefined }),
312+);
313+expect(buildContext).toHaveBeenCalledWith(expect.objectContaining({ timestamp: undefined }));
314+const runArg = runTurn.mock.calls[0]?.[0] as
315+| { adapter?: { ingest?: () => { timestamp?: number } } }
316+| undefined;
317+expect(runArg?.adapter?.ingest?.().timestamp).toBeUndefined();
318+});
246319});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。