




















@@ -3024,21 +3024,29 @@ describe("dispatchReplyFromConfig", () => {
30243024const replyResolver = async () => ({ text: "hi" }) satisfies ReplyPayload;
30253025await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });
302630263027-expect(internalHookMocks.createInternalHookEvent).toHaveBeenCalledWith(
3028-"message",
3029-"received",
3030-"agent:main:main",
3031-expect.objectContaining({
3032-from: ctx.From,
3033-content: "/help",
3034-channelId: "telegram",
3035-messageId: "msg-42",
3036-metadata: expect.objectContaining({
3037-guildId: "guild-456",
3038-channelName: "ops-room",
3039-}),
3040-}),
3041-);
3027+const createHookCall = internalHookMocks.createInternalHookEvent.mock.calls[0] as
3028+| [
3029+unknown,
3030+unknown,
3031+unknown,
3032+{
3033+channelId?: unknown;
3034+content?: unknown;
3035+from?: unknown;
3036+messageId?: unknown;
3037+metadata?: Record<string, unknown>;
3038+},
3039+]
3040+| undefined;
3041+expect(createHookCall?.[0]).toBe("message");
3042+expect(createHookCall?.[1]).toBe("received");
3043+expect(createHookCall?.[2]).toBe("agent:main:main");
3044+expect(createHookCall?.[3]?.from).toBe(ctx.From);
3045+expect(createHookCall?.[3]?.content).toBe("/help");
3046+expect(createHookCall?.[3]?.channelId).toBe("telegram");
3047+expect(createHookCall?.[3]?.messageId).toBe("msg-42");
3048+expect(createHookCall?.[3]?.metadata?.guildId).toBe("guild-456");
3049+expect(createHookCall?.[3]?.metadata?.channelName).toBe("ops-room");
30423050expect(internalHookMocks.triggerInternalHook).toHaveBeenCalledTimes(1);
30433051});
30443052@@ -3076,15 +3084,14 @@ describe("dispatchReplyFromConfig", () => {
30763084const replyResolver = async () => ({ text: "reply" }) satisfies ReplyPayload;
30773085await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });
307830863079-expect(internalHookMocks.createInternalHookEvent).toHaveBeenCalledWith(
3080-"message",
3081-"received",
3082-"agent:main:discord:guild:123",
3083-expect.objectContaining({
3084-content: "hello",
3085-messageId: "msg-99",
3086-}),
3087-);
3087+const createHookCall = internalHookMocks.createInternalHookEvent.mock.calls[0] as
3088+| [unknown, unknown, unknown, { content?: unknown; messageId?: unknown }]
3089+| undefined;
3090+expect(createHookCall?.[0]).toBe("message");
3091+expect(createHookCall?.[1]).toBe("received");
3092+expect(createHookCall?.[2]).toBe("agent:main:discord:guild:123");
3093+expect(createHookCall?.[3]?.content).toBe("hello");
3094+expect(createHookCall?.[3]?.messageId).toBe("msg-99");
30883095expect(internalHookMocks.triggerInternalHook).toHaveBeenCalledTimes(1);
30893096});
30903097@@ -3109,13 +3116,12 @@ describe("dispatchReplyFromConfig", () => {
31093116state: "processing",
31103117reason: "message_start",
31113118});
3112-expect(diagnosticMocks.logMessageProcessed).toHaveBeenCalledWith(
3113-expect.objectContaining({
3114-channel: "slack",
3115-outcome: "completed",
3116-sessionKey: "agent:main:main",
3117-}),
3118-);
3119+const processedEvent = diagnosticMocks.logMessageProcessed.mock.calls[0]?.[0] as
3120+| { channel?: unknown; outcome?: unknown; sessionKey?: unknown }
3121+| undefined;
3122+expect(processedEvent?.channel).toBe("slack");
3123+expect(processedEvent?.outcome).toBe("completed");
3124+expect(processedEvent?.sessionKey).toBe("agent:main:main");
31193125});
3120312631213127it("marks diagnostic progress for real reply events but not reply start callbacks", async () => {
@@ -3261,26 +3267,29 @@ describe("dispatchReplyFromConfig", () => {
3261326732623268expect(result).toEqual({ queuedFinal: false, counts: { tool: 0, block: 0, final: 0 } });
32633269expect(sessionBindingMocks.touch).toHaveBeenCalledWith("binding-1");
3264-expect(hookMocks.runner.runInboundClaimForPluginOutcome).toHaveBeenCalledWith(
3265-"openclaw-codex-app-server",
3266-expect.objectContaining({
3267-channel: "discord",
3268-accountId: "default",
3269-conversationId: "channel:1481858418548412579",
3270-content: "who are you",
3271-}),
3272-expect.objectContaining({
3273-channelId: "discord",
3274-accountId: "default",
3275-conversationId: "channel:1481858418548412579",
3276-pluginBinding: expect.objectContaining({
3277-data: expect.objectContaining({
3278-kind: "codex-app-server-session",
3279-sessionFile: "/tmp/session.jsonl",
3280-}),
3281-}),
3282-}),
3283-);
3270+const inboundClaimCall = hookMocks.runner.runInboundClaimForPluginOutcome.mock
3271+.calls[0] as unknown as
3272+| [
3273+unknown,
3274+{ accountId?: unknown; channel?: unknown; content?: unknown; conversationId?: unknown },
3275+{
3276+accountId?: unknown;
3277+channelId?: unknown;
3278+conversationId?: unknown;
3279+pluginBinding?: { data?: Record<string, unknown> };
3280+},
3281+]
3282+| undefined;
3283+expect(inboundClaimCall?.[0]).toBe("openclaw-codex-app-server");
3284+expect(inboundClaimCall?.[1]?.channel).toBe("discord");
3285+expect(inboundClaimCall?.[1]?.accountId).toBe("default");
3286+expect(inboundClaimCall?.[1]?.conversationId).toBe("channel:1481858418548412579");
3287+expect(inboundClaimCall?.[1]?.content).toBe("who are you");
3288+expect(inboundClaimCall?.[2]?.channelId).toBe("discord");
3289+expect(inboundClaimCall?.[2]?.accountId).toBe("default");
3290+expect(inboundClaimCall?.[2]?.conversationId).toBe("channel:1481858418548412579");
3291+expect(inboundClaimCall?.[2]?.pluginBinding?.data?.kind).toBe("codex-app-server-session");
3292+expect(inboundClaimCall?.[2]?.pluginBinding?.data?.sessionFile).toBe("/tmp/session.jsonl");
32843293expect(hookMocks.runner.runInboundClaim).not.toHaveBeenCalled();
32853294expect(replyResolver).not.toHaveBeenCalled();
32863295});
@@ -3395,20 +3404,22 @@ describe("dispatchReplyFromConfig", () => {
3395340433963405expect(result).toEqual({ queuedFinal: false, counts: { tool: 0, block: 0, final: 0 } });
33973406expect(sessionBindingMocks.touch).toHaveBeenCalledWith("binding-dm-1");
3398-expect(hookMocks.runner.runInboundClaimForPluginOutcome).toHaveBeenCalledWith(
3399-"openclaw-codex-app-server",
3400-expect.objectContaining({
3401-channel: "discord",
3402-accountId: "default",
3403-conversationId: "1480574946919846079",
3404-content: "who are you",
3405-}),
3406-expect.objectContaining({
3407-channelId: "discord",
3408-accountId: "default",
3409-conversationId: "1480574946919846079",
3410-}),
3411-);
3407+const inboundClaimCall = hookMocks.runner.runInboundClaimForPluginOutcome.mock
3408+.calls[0] as unknown as
3409+| [
3410+unknown,
3411+{ accountId?: unknown; channel?: unknown; content?: unknown; conversationId?: unknown },
3412+{ accountId?: unknown; channelId?: unknown; conversationId?: unknown },
3413+]
3414+| undefined;
3415+expect(inboundClaimCall?.[0]).toBe("openclaw-codex-app-server");
3416+expect(inboundClaimCall?.[1]?.channel).toBe("discord");
3417+expect(inboundClaimCall?.[1]?.accountId).toBe("default");
3418+expect(inboundClaimCall?.[1]?.conversationId).toBe("1480574946919846079");
3419+expect(inboundClaimCall?.[1]?.content).toBe("who are you");
3420+expect(inboundClaimCall?.[2]?.channelId).toBe("discord");
3421+expect(inboundClaimCall?.[2]?.accountId).toBe("default");
3422+expect(inboundClaimCall?.[2]?.conversationId).toBe("1480574946919846079");
34123423expect(hookMocks.runner.runInboundClaim).not.toHaveBeenCalled();
34133424expect(replyResolver).not.toHaveBeenCalled();
34143425});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。