@@ -2026,6 +2026,70 @@ describe("dispatchReplyFromConfig", () => {
|
2026 | 2026 | expect(dispatcher.sendFinalReply).toHaveBeenCalledTimes(1); |
2027 | 2027 | }); |
2028 | 2028 | |
| 2029 | +it("forwards channel-owned group progress callbacks while source delivery is suppressed", async () => { |
| 2030 | +setNoAbort(); |
| 2031 | +sessionStoreMocks.currentEntry = { |
| 2032 | +verboseLevel: "off", |
| 2033 | +}; |
| 2034 | +const cfg = automaticGroupReplyConfig; |
| 2035 | +const dispatcher = createDispatcher(); |
| 2036 | +const ctx = buildTestCtx({ |
| 2037 | +Provider: "telegram", |
| 2038 | +Surface: "telegram", |
| 2039 | +ChatType: "group", |
| 2040 | +From: "telegram:group:-100123", |
| 2041 | +SessionKey: "agent:main:telegram:group:-100123", |
| 2042 | +}); |
| 2043 | +const onToolStart = vi.fn(); |
| 2044 | +const onItemEvent = vi.fn(); |
| 2045 | +const onCommandOutput = vi.fn(); |
| 2046 | +const onToolResult = vi.fn(); |
| 2047 | + |
| 2048 | +const replyResolver = async ( |
| 2049 | +_ctx: MsgContext, |
| 2050 | +opts?: GetReplyOptions, |
| 2051 | +_cfg?: OpenClawConfig, |
| 2052 | +) => { |
| 2053 | +await opts?.onToolStart?.({ name: "exec", phase: "start" }); |
| 2054 | +await opts?.onItemEvent?.({ itemId: "1", kind: "tool", progressText: "running exec" }); |
| 2055 | +await opts?.onCommandOutput?.({ phase: "end", name: "exec", status: "ok", exitCode: 0 }); |
| 2056 | +await opts?.onToolResult?.({ text: "exec: ok" }); |
| 2057 | +return { text: "done" } satisfies ReplyPayload; |
| 2058 | +}; |
| 2059 | + |
| 2060 | +await dispatchReplyFromConfig({ |
| 2061 | + ctx, |
| 2062 | + cfg, |
| 2063 | + dispatcher, |
| 2064 | + replyResolver, |
| 2065 | +replyOptions: { |
| 2066 | +sourceReplyDeliveryMode: "message_tool_only", |
| 2067 | +suppressDefaultToolProgressMessages: true, |
| 2068 | +allowProgressCallbacksWhenSourceDeliverySuppressed: true, |
| 2069 | + onToolStart, |
| 2070 | + onItemEvent, |
| 2071 | + onCommandOutput, |
| 2072 | + onToolResult, |
| 2073 | +}, |
| 2074 | +}); |
| 2075 | + |
| 2076 | +expect(onToolStart).toHaveBeenCalledWith({ name: "exec", phase: "start" }); |
| 2077 | +expect(onItemEvent).toHaveBeenCalledWith({ |
| 2078 | +itemId: "1", |
| 2079 | +kind: "tool", |
| 2080 | +progressText: "running exec", |
| 2081 | +}); |
| 2082 | +expect(onCommandOutput).toHaveBeenCalledWith({ |
| 2083 | +phase: "end", |
| 2084 | +name: "exec", |
| 2085 | +status: "ok", |
| 2086 | +exitCode: 0, |
| 2087 | +}); |
| 2088 | +expect(onToolResult).not.toHaveBeenCalled(); |
| 2089 | +expect(dispatcher.sendToolResult).not.toHaveBeenCalled(); |
| 2090 | +expect(dispatcher.sendFinalReply).not.toHaveBeenCalled(); |
| 2091 | +}); |
| 2092 | + |
2029 | 2093 | it("exposes live tool-summary state to reply_dispatch hooks", () => { |
2030 | 2094 | let shouldSendToolSummaries = false; |
2031 | 2095 | const event = dispatchFromConfigTesting.createReplyDispatchEvent({ |
|