refactor(channels): share turn dispatch results · openclaw/openclaw@02ebac6
steipete
·
2026-04-30
·
via Recent Commits to openclaw:main
File tree
matrix/src/matrix/monitor
msteams/src/monitor-handler
slack/src/monitor/message-handler
whatsapp/src/auto-reply/monitor
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | | -81de442c9e0c902621f316297af3ad6c48a07c0c6bbfa5ca984419cfdb7f4292 plugin-sdk-api-baseline.json |
2 | | -136836d047bd0fb0723047945fdbd931a9128552ff49e8a27937d54dba0e9709 plugin-sdk-api-baseline.jsonl |
| 1 | +ae28566c922ce79527943b069abc199de28e3898ec08eea12c4ff6050795f276 plugin-sdk-api-baseline.json |
| 2 | +79446b23832949553b23e7cf92be37b81c69d123fc09bed6f8fc04bd98e9257d plugin-sdk-api-baseline.jsonl |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -13,7 +13,10 @@ import {
|
13 | 13 | } from "openclaw/plugin-sdk/channel-reply-pipeline"; |
14 | 14 | import { resolveChannelStreamingBlockEnabled } from "openclaw/plugin-sdk/channel-streaming"; |
15 | 15 | import { recordInboundSession } from "openclaw/plugin-sdk/conversation-runtime"; |
16 | | -import { runPreparedInboundReplyTurn } from "openclaw/plugin-sdk/inbound-reply-dispatch"; |
| 16 | +import { |
| 17 | +hasFinalInboundReplyDispatch, |
| 18 | +runPreparedInboundReplyTurn, |
| 19 | +} from "openclaw/plugin-sdk/inbound-reply-dispatch"; |
17 | 20 | import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime"; |
18 | 21 | import { getAgentScopedMediaLocalRoots } from "openclaw/plugin-sdk/media-runtime"; |
19 | 22 | import { resolveChunkMode } from "openclaw/plugin-sdk/reply-chunking"; |
@@ -643,7 +646,7 @@ export async function processDiscordMessage(
|
643 | 646 | return; |
644 | 647 | } |
645 | 648 | |
646 | | -if (!dispatchResult?.queuedFinal) { |
| 649 | +if (!hasFinalInboundReplyDispatch(dispatchResult)) { |
647 | 650 | if (isGuildMessage) { |
648 | 651 | clearHistoryEntriesIfEnabled({ |
649 | 652 | historyMap: guildHistories, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -12,7 +12,10 @@ import {
|
12 | 12 | } from "openclaw/plugin-sdk/conversation-runtime"; |
13 | 13 | import { recordInboundSession } from "openclaw/plugin-sdk/conversation-runtime"; |
14 | 14 | import { normalizeScpRemoteHost } from "openclaw/plugin-sdk/host-runtime"; |
15 | | -import { runPreparedInboundReplyTurn } from "openclaw/plugin-sdk/inbound-reply-dispatch"; |
| 15 | +import { |
| 16 | +hasFinalInboundReplyDispatch, |
| 17 | +runPreparedInboundReplyTurn, |
| 18 | +} from "openclaw/plugin-sdk/inbound-reply-dispatch"; |
16 | 19 | import { isInboundPathAllowed, kindFromMime } from "openclaw/plugin-sdk/media-runtime"; |
17 | 20 | import { |
18 | 21 | clearHistoryEntriesIfEnabled, |
@@ -487,9 +490,7 @@ export async function monitorIMessageProvider(opts: MonitorIMessageOpts = {}): P
|
487 | 490 | }, |
488 | 491 | }), |
489 | 492 | }); |
490 | | -const queuedFinal = dispatchResult.queuedFinal; |
491 | | - |
492 | | -if (!queuedFinal) { |
| 493 | +if (!hasFinalInboundReplyDispatch(dispatchResult)) { |
493 | 494 | if (decision.isGroup && decision.historyKey) { |
494 | 495 | clearHistoryEntriesIfEnabled({ |
495 | 496 | historyMap: groupHistories, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,7 +2,10 @@ import type { webhook } from "@line/bot-sdk";
|
2 | 2 | import { createChannelReplyPipeline } from "openclaw/plugin-sdk/channel-reply-pipeline"; |
3 | 3 | import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types"; |
4 | 4 | import { recordInboundSession } from "openclaw/plugin-sdk/conversation-runtime"; |
5 | | -import { runPreparedInboundReplyTurn } from "openclaw/plugin-sdk/inbound-reply-dispatch"; |
| 5 | +import { |
| 6 | +hasFinalInboundReplyDispatch, |
| 7 | +runPreparedInboundReplyTurn, |
| 8 | +} from "openclaw/plugin-sdk/inbound-reply-dispatch"; |
6 | 9 | import { |
7 | 10 | dispatchReplyWithBufferedBlockDispatcher, |
8 | 11 | chunkMarkdownText, |
@@ -306,9 +309,7 @@ export async function monitorLineProvider(
|
306 | 309 | }, |
307 | 310 | }), |
308 | 311 | }); |
309 | | -const queuedFinal = dispatchResult.queuedFinal; |
310 | | - |
311 | | -if (!queuedFinal) { |
| 312 | +if (!hasFinalInboundReplyDispatch(dispatchResult)) { |
312 | 313 | logVerbose(`line: no response generated for message from ${ctxPayload.From}`); |
313 | 314 | } |
314 | 315 | } catch (err) { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3,6 +3,7 @@ import {
|
3 | 3 | evaluateSupplementalContextVisibility, |
4 | 4 | resolveChannelContextVisibilityMode, |
5 | 5 | } from "openclaw/plugin-sdk/context-visibility-runtime"; |
| 6 | +import { hasFinalInboundReplyDispatch } from "openclaw/plugin-sdk/inbound-reply-dispatch"; |
6 | 7 | import type { GetReplyOptions } from "openclaw/plugin-sdk/reply-runtime"; |
7 | 8 | import { |
8 | 9 | loadSessionStore, |
@@ -1963,7 +1964,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
1963 | 1964 | if (isRoom && triggerSnapshot) { |
1964 | 1965 | roomHistoryTracker.consumeHistory(_route.agentId, roomId, triggerSnapshot, _messageId); |
1965 | 1966 | } |
1966 | | -if (!queuedFinal) { |
| 1967 | +if (!hasFinalInboundReplyDispatch({ queuedFinal, counts })) { |
1967 | 1968 | await commitInboundEventIfClaimed(); |
1968 | 1969 | return; |
1969 | 1970 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -11,7 +11,11 @@ import {
|
11 | 11 | shouldIncludeSupplementalContext, |
12 | 12 | } from "openclaw/plugin-sdk/context-visibility-runtime"; |
13 | 13 | import { evaluateSenderGroupAccessForPolicy } from "openclaw/plugin-sdk/group-access"; |
14 | | -import { dispatchReplyFromConfigWithSettledDispatcher } from "openclaw/plugin-sdk/inbound-reply-dispatch"; |
| 14 | +import { |
| 15 | +dispatchReplyFromConfigWithSettledDispatcher, |
| 16 | +hasFinalInboundReplyDispatch, |
| 17 | +resolveInboundReplyDispatchCounts, |
| 18 | +} from "openclaw/plugin-sdk/inbound-reply-dispatch"; |
15 | 19 | import { |
16 | 20 | buildPendingHistoryContextFromMap, |
17 | 21 | clearHistoryEntriesIfEnabled, |
@@ -864,11 +868,12 @@ export function createMSTeamsMessageHandler(deps: MSTeamsMessageHandlerDeps) {
|
864 | 868 | }), |
865 | 869 | }); |
866 | 870 | const queuedFinal = dispatchResult?.queuedFinal ?? false; |
867 | | -const counts = dispatchResult?.counts ?? { tool: 0, block: 0, final: 0 }; |
| 871 | +const counts = resolveInboundReplyDispatchCounts(dispatchResult); |
| 872 | +const hasFinalResponse = hasFinalInboundReplyDispatch(dispatchResult); |
868 | 873 | |
869 | 874 | log.info("dispatch complete", { queuedFinal, counts }); |
870 | 875 | |
871 | | -if (!queuedFinal) { |
| 876 | +if (!hasFinalResponse) { |
872 | 877 | if (isRoomish && historyKey) { |
873 | 878 | clearHistoryEntriesIfEnabled({ |
874 | 879 | historyMap: conversationHistories, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -25,7 +25,10 @@ import {
|
25 | 25 | toInternalMessageReceivedContext, |
26 | 26 | triggerInternalHook, |
27 | 27 | } from "openclaw/plugin-sdk/hook-runtime"; |
28 | | -import { runPreparedInboundReplyTurn } from "openclaw/plugin-sdk/inbound-reply-dispatch"; |
| 28 | +import { |
| 29 | +hasFinalInboundReplyDispatch, |
| 30 | +runPreparedInboundReplyTurn, |
| 31 | +} from "openclaw/plugin-sdk/inbound-reply-dispatch"; |
29 | 32 | import { kindFromMime } from "openclaw/plugin-sdk/media-runtime"; |
30 | 33 | import { |
31 | 34 | buildPendingHistoryContextFromMap, |
@@ -351,8 +354,7 @@ export function createSignalEventHandler(deps: SignalEventHandlerDeps) {
|
351 | 354 | } |
352 | 355 | }, |
353 | 356 | }); |
354 | | -const queuedFinal = dispatchResult?.queuedFinal ?? false; |
355 | | -if (!queuedFinal) { |
| 357 | +if (!hasFinalInboundReplyDispatch(dispatchResult)) { |
356 | 358 | if (entry.isGroup && historyKey) { |
357 | 359 | clearHistoryEntriesIfEnabled({ |
358 | 360 | historyMap: deps.groupHistories, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -18,7 +18,10 @@ import {
|
18 | 18 | resolveChannelStreamingPreviewToolProgress, |
19 | 19 | } from "openclaw/plugin-sdk/channel-streaming"; |
20 | 20 | import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime"; |
21 | | -import { runPreparedInboundReplyTurn } from "openclaw/plugin-sdk/inbound-reply-dispatch"; |
| 21 | +import { |
| 22 | +hasVisibleInboundReplyDispatch, |
| 23 | +runPreparedInboundReplyTurn, |
| 24 | +} from "openclaw/plugin-sdk/inbound-reply-dispatch"; |
22 | 25 | import { resolveAgentOutboundIdentity } from "openclaw/plugin-sdk/outbound-runtime"; |
23 | 26 | import { clearHistoryEntriesIfEnabled } from "openclaw/plugin-sdk/reply-history"; |
24 | 27 | import { resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload"; |
@@ -1099,12 +1102,13 @@ export async function dispatchPreparedSlackMessage(prepared: PreparedSlackMessag
|
1099 | 1102 | } |
1100 | 1103 | } |
1101 | 1104 | |
1102 | | -const anyReplyDelivered = |
1103 | | -observedReplyDelivery || |
1104 | | -queuedFinal || |
1105 | | -streamFallbackDelivered || |
1106 | | -(counts.block ?? 0) > 0 || |
1107 | | -(counts.final ?? 0) > 0; |
| 1105 | +const anyReplyDelivered = hasVisibleInboundReplyDispatch( |
| 1106 | +{ queuedFinal, counts }, |
| 1107 | +{ |
| 1108 | + observedReplyDelivery, |
| 1109 | +fallbackDelivered: streamFallbackDelivered, |
| 1110 | +}, |
| 1111 | +); |
1108 | 1112 | |
1109 | 1113 | if (statusReactionsEnabled) { |
1110 | 1114 | if (dispatchError) { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -17,7 +17,10 @@ import type {
|
17 | 17 | TelegramAccountConfig, |
18 | 18 | } from "openclaw/plugin-sdk/config-types"; |
19 | 19 | import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime"; |
20 | | -import { runPreparedInboundReplyTurn } from "openclaw/plugin-sdk/inbound-reply-dispatch"; |
| 20 | +import { |
| 21 | +hasFinalInboundReplyDispatch, |
| 22 | +runPreparedInboundReplyTurn, |
| 23 | +} from "openclaw/plugin-sdk/inbound-reply-dispatch"; |
21 | 24 | import { |
22 | 25 | createOutboundPayloadPlan, |
23 | 26 | projectOutboundPayloadPlanForDelivery, |
@@ -1306,7 +1309,13 @@ export const dispatchTelegramMessage = async ({
|
1306 | 1309 | }); |
1307 | 1310 | } |
1308 | 1311 | |
1309 | | -const hasFinalResponse = queuedFinal || sentFallback || deliverySummary.delivered; |
| 1312 | +const hasFinalResponse = hasFinalInboundReplyDispatch( |
| 1313 | +{ queuedFinal }, |
| 1314 | +{ |
| 1315 | +fallbackDelivered: sentFallback, |
| 1316 | +deliverySummaryDelivered: deliverySummary.delivered, |
| 1317 | +}, |
| 1318 | +); |
1310 | 1319 | |
1311 | 1320 | if (statusReactionController && !hasFinalResponse) { |
1312 | 1321 | void finalizeTelegramStatusReaction({ outcome: "error", hasFinalResponse: false }).catch( |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { hasVisibleInboundReplyDispatch } from "openclaw/plugin-sdk/inbound-reply-dispatch"; |
1 | 2 | import { |
2 | 3 | type DeliverableWhatsAppOutboundPayload, |
3 | 4 | normalizeWhatsAppOutboundPayload, |
@@ -388,8 +389,7 @@ export async function dispatchWhatsAppBufferedReply(params: {
|
388 | 389 | }, |
389 | 390 | }); |
390 | 391 | |
391 | | -const didQueueVisibleReply = |
392 | | -queuedFinal || counts.tool > 0 || counts.block > 0 || counts.final > 0; |
| 392 | +const didQueueVisibleReply = hasVisibleInboundReplyDispatch({ queuedFinal, counts }); |
393 | 393 | if (!didQueueVisibleReply) { |
394 | 394 | if (params.shouldClearGroupHistory) { |
395 | 395 | params.groupHistories.set(params.groupHistoryKey, []); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。