11import type { OpenClawConfig } from "../config/types.openclaw.js" ;
2+ import { withReplyDispatcher } from "./dispatch-dispatcher.js" ;
23import { dispatchReplyFromConfig } from "./reply/dispatch-from-config.js" ;
34import type { DispatchFromConfigResult } from "./reply/dispatch-from-config.types.js" ;
5+ import type { GetReplyFromConfig } from "./reply/get-reply.types.js" ;
46import { finalizeInboundContext } from "./reply/inbound-context.js" ;
57import {
68 createReplyDispatcher ,
@@ -13,31 +15,14 @@ import type { FinalizedMsgContext, MsgContext } from "./templating.js";
1315import type { GetReplyOptions } from "./types.js" ;
1416
1517export type DispatchInboundResult = DispatchFromConfigResult ;
16-
17- export async function withReplyDispatcher < T > ( params : {
18- dispatcher : ReplyDispatcher ;
19- run : ( ) => Promise < T > ;
20- onSettled ?: ( ) => void | Promise < void > ;
21- } ) : Promise < T > {
22- try {
23- return await params . run ( ) ;
24- } finally {
25- // Ensure dispatcher reservations are always released on every exit path.
26- params . dispatcher . markComplete ( ) ;
27- try {
28- await params . dispatcher . waitForIdle ( ) ;
29- } finally {
30- await params . onSettled ?.( ) ;
31- }
32- }
33- }
18+ export { withReplyDispatcher } from "./dispatch-dispatcher.js" ;
3419
3520export async function dispatchInboundMessage ( params : {
3621 ctx : MsgContext | FinalizedMsgContext ;
3722 cfg : OpenClawConfig ;
3823 dispatcher : ReplyDispatcher ;
3924 replyOptions ?: Omit < GetReplyOptions , "onToolResult" | "onBlockReply" > ;
40- replyResolver ?: typeof import ( "./reply.js" ) . getReplyFromConfig ;
25+ replyResolver ?: GetReplyFromConfig ;
4126} ) : Promise < DispatchInboundResult > {
4227 const finalized = finalizeInboundContext ( params . ctx ) ;
4328 return await withReplyDispatcher ( {
@@ -58,7 +43,7 @@ export async function dispatchInboundMessageWithBufferedDispatcher(params: {
5843 cfg : OpenClawConfig ;
5944 dispatcherOptions : ReplyDispatcherWithTypingOptions ;
6045 replyOptions ?: Omit < GetReplyOptions , "onToolResult" | "onBlockReply" > ;
61- replyResolver ?: typeof import ( "./reply.js" ) . getReplyFromConfig ;
46+ replyResolver ?: GetReplyFromConfig ;
6247} ) : Promise < DispatchInboundResult > {
6348 const { dispatcher, replyOptions, markDispatchIdle, markRunComplete } =
6449 createReplyDispatcherWithTyping ( params . dispatcherOptions ) ;
@@ -84,7 +69,7 @@ export async function dispatchInboundMessageWithDispatcher(params: {
8469 cfg : OpenClawConfig ;
8570 dispatcherOptions : ReplyDispatcherOptions ;
8671 replyOptions ?: Omit < GetReplyOptions , "onToolResult" | "onBlockReply" > ;
87- replyResolver ?: typeof import ( "./reply.js" ) . getReplyFromConfig ;
72+ replyResolver ?: GetReplyFromConfig ;
8873} ) : Promise < DispatchInboundResult > {
8974 const dispatcher = createReplyDispatcher ( params . dispatcherOptions ) ;
9075 return await dispatchInboundMessage ( {
0 commit comments