diff --git a/src/auto-reply/reply/provider-dispatcher.ts b/src/auto-reply/reply/provider-dispatcher.ts index 214ede2f12a..e7903e05f60 100644 --- a/src/auto-reply/reply/provider-dispatcher.ts +++ b/src/auto-reply/reply/provider-dispatcher.ts @@ -1,40 +1,29 @@ -import type { OpenClawConfig } from "../../config/types.openclaw.js"; -import type { DispatchInboundResult } from "../dispatch.js"; import { dispatchInboundMessageWithBufferedDispatcher, dispatchInboundMessageWithDispatcher, } from "../dispatch.js"; -import type { FinalizedMsgContext, MsgContext } from "../templating.js"; -import type { GetReplyOptions } from "../types.js"; -import type { GetReplyFromConfig } from "./get-reply.types.js"; import type { - ReplyDispatcherOptions, - ReplyDispatcherWithTypingOptions, -} from "./reply-dispatcher.js"; + DispatchReplyWithBufferedBlockDispatcher, + DispatchReplyWithDispatcher, +} from "./provider-dispatcher.types.js"; -export async function dispatchReplyWithBufferedBlockDispatcher(params: { - ctx: MsgContext | FinalizedMsgContext; - cfg: OpenClawConfig; - dispatcherOptions: ReplyDispatcherWithTypingOptions; - replyOptions?: Omit; - replyResolver?: GetReplyFromConfig; -}): Promise { - return await dispatchInboundMessageWithBufferedDispatcher({ - ctx: params.ctx, - cfg: params.cfg, - dispatcherOptions: params.dispatcherOptions, - replyResolver: params.replyResolver, - replyOptions: params.replyOptions, - }); -} +export type { + DispatchReplyWithBufferedBlockDispatcher, + DispatchReplyWithDispatcher, +} from "./provider-dispatcher.types.js"; -export async function dispatchReplyWithDispatcher(params: { - ctx: MsgContext | FinalizedMsgContext; - cfg: OpenClawConfig; - dispatcherOptions: ReplyDispatcherOptions; - replyOptions?: Omit; - replyResolver?: GetReplyFromConfig; -}): Promise { +export const dispatchReplyWithBufferedBlockDispatcher: DispatchReplyWithBufferedBlockDispatcher = + async (params) => { + return await dispatchInboundMessageWithBufferedDispatcher({ + ctx: params.ctx, + cfg: params.cfg, + dispatcherOptions: params.dispatcherOptions, + replyResolver: params.replyResolver, + replyOptions: params.replyOptions, + }); + }; + +export const dispatchReplyWithDispatcher: DispatchReplyWithDispatcher = async (params) => { return await dispatchInboundMessageWithDispatcher({ ctx: params.ctx, cfg: params.cfg, @@ -42,4 +31,4 @@ export async function dispatchReplyWithDispatcher(params: { replyResolver: params.replyResolver, replyOptions: params.replyOptions, }); -} +}; diff --git a/src/auto-reply/reply/provider-dispatcher.types.ts b/src/auto-reply/reply/provider-dispatcher.types.ts new file mode 100644 index 00000000000..1f944a05a37 --- /dev/null +++ b/src/auto-reply/reply/provider-dispatcher.types.ts @@ -0,0 +1,28 @@ +import type { OpenClawConfig } from "../../config/types.openclaw.js"; +import type { FinalizedMsgContext, MsgContext } from "../templating.js"; +import type { GetReplyOptions } from "../types.js"; +import type { DispatchFromConfigResult } from "./dispatch-from-config.types.js"; +import type { GetReplyFromConfig } from "./get-reply.types.js"; +import type { + ReplyDispatcherOptions, + ReplyDispatcherWithTypingOptions, +} from "./reply-dispatcher.js"; + +type DispatchReplyContext = MsgContext | FinalizedMsgContext; +type DispatchReplyOptions = Omit; + +export type DispatchReplyWithBufferedBlockDispatcher = (params: { + ctx: DispatchReplyContext; + cfg: OpenClawConfig; + dispatcherOptions: ReplyDispatcherWithTypingOptions; + replyOptions?: DispatchReplyOptions; + replyResolver?: GetReplyFromConfig; +}) => Promise; + +export type DispatchReplyWithDispatcher = (params: { + ctx: DispatchReplyContext; + cfg: OpenClawConfig; + dispatcherOptions: ReplyDispatcherOptions; + replyOptions?: DispatchReplyOptions; + replyResolver?: GetReplyFromConfig; +}) => Promise; diff --git a/src/plugin-sdk/direct-dm.ts b/src/plugin-sdk/direct-dm.ts index 67416a1eddb..f080c49fde2 100644 --- a/src/plugin-sdk/direct-dm.ts +++ b/src/plugin-sdk/direct-dm.ts @@ -1,3 +1,4 @@ +import type { DispatchReplyWithBufferedBlockDispatcher } from "../auto-reply/reply/provider-dispatcher.types.js"; import type { FinalizedMsgContext } from "../auto-reply/templating.js"; import type { ChannelId } from "../channels/plugins/types.public.js"; import type { OpenClawConfig } from "../config/types.openclaw.js"; @@ -215,7 +216,7 @@ type DirectDmRuntime = { ) => ReturnType; formatAgentEnvelope: typeof import("../auto-reply/envelope.js").formatAgentEnvelope; finalizeInboundContext: typeof import("../auto-reply/reply/inbound-context.js").finalizeInboundContext; - dispatchReplyWithBufferedBlockDispatcher: typeof import("../auto-reply/reply/provider-dispatcher.js").dispatchReplyWithBufferedBlockDispatcher; + dispatchReplyWithBufferedBlockDispatcher: DispatchReplyWithBufferedBlockDispatcher; }; }; }; diff --git a/src/plugin-sdk/inbound-reply-dispatch.ts b/src/plugin-sdk/inbound-reply-dispatch.ts index 29d31d177ff..1be59e0a636 100644 --- a/src/plugin-sdk/inbound-reply-dispatch.ts +++ b/src/plugin-sdk/inbound-reply-dispatch.ts @@ -3,6 +3,7 @@ import { dispatchReplyFromConfig, type DispatchFromConfigResult, } from "../auto-reply/reply/dispatch-from-config.js"; +import type { DispatchReplyWithBufferedBlockDispatcher } from "../auto-reply/reply/provider-dispatcher.types.js"; import type { ReplyDispatcher } from "../auto-reply/reply/reply-dispatcher.types.js"; import type { FinalizedMsgContext } from "../auto-reply/templating.js"; import type { GetReplyOptions } from "../auto-reply/types.js"; @@ -15,8 +16,6 @@ type ReplyOptionsWithoutModelSelected = Omit< "onModelSelected" >; type RecordInboundSessionFn = typeof import("../channels/session.js").recordInboundSession; -type DispatchReplyWithBufferedBlockDispatcherFn = - typeof import("../auto-reply/reply/provider-dispatcher.js").dispatchReplyWithBufferedBlockDispatcher; type ReplyDispatchFromConfigOptions = Omit; @@ -60,7 +59,7 @@ export function buildInboundReplyDispatchBase(params: { recordInboundSession: RecordInboundSessionFn; }; reply: { - dispatchReplyWithBufferedBlockDispatcher: DispatchReplyWithBufferedBlockDispatcherFn; + dispatchReplyWithBufferedBlockDispatcher: DispatchReplyWithBufferedBlockDispatcher; }; }; }; @@ -112,7 +111,7 @@ export async function recordInboundSessionAndDispatchReply(params: { storePath: string; ctxPayload: FinalizedMsgContext; recordInboundSession: RecordInboundSessionFn; - dispatchReplyWithBufferedBlockDispatcher: DispatchReplyWithBufferedBlockDispatcherFn; + dispatchReplyWithBufferedBlockDispatcher: DispatchReplyWithBufferedBlockDispatcher; deliver: (payload: OutboundReplyPayload) => Promise; onRecordError: (err: unknown) => void; onDispatchError: (err: unknown, info: { kind: string }) => void; diff --git a/src/plugins/runtime/types-channel.ts b/src/plugins/runtime/types-channel.ts index a805bf0d50a..97cbcd7d334 100644 --- a/src/plugins/runtime/types-channel.ts +++ b/src/plugins/runtime/types-channel.ts @@ -5,6 +5,8 @@ * inside the owning plugin package instead of hanging off core runtime slots * like `channel.discord` or `channel.slack`. */ +import type { DispatchReplyWithBufferedBlockDispatcher } from "../../auto-reply/reply/provider-dispatcher.types.js"; + type ReadChannelAllowFromStore = typeof import("../../pairing/pairing-store.js").readChannelAllowFromStore; type UpsertChannelPairingRequest = @@ -87,7 +89,7 @@ export type PluginRuntimeChannel = { convertMarkdownTables: typeof import("../../markdown/tables.js").convertMarkdownTables; }; reply: { - dispatchReplyWithBufferedBlockDispatcher: typeof import("../../auto-reply/reply/provider-dispatcher.js").dispatchReplyWithBufferedBlockDispatcher; + dispatchReplyWithBufferedBlockDispatcher: DispatchReplyWithBufferedBlockDispatcher; createReplyDispatcherWithTyping: typeof import("../../auto-reply/reply/reply-dispatcher.js").createReplyDispatcherWithTyping; resolveEffectiveMessagesConfig: typeof import("../../agents/identity.js").resolveEffectiveMessagesConfig; resolveHumanDelayConfig: typeof import("../../agents/identity.js").resolveHumanDelayConfig;