mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 01:31:08 +00:00
fix(runtime): split reply dispatcher type surface
This commit is contained in:
@@ -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<GetReplyOptions, "onToolResult" | "onBlockReply">;
|
||||
replyResolver?: GetReplyFromConfig;
|
||||
}): Promise<DispatchInboundResult> {
|
||||
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<GetReplyOptions, "onToolResult" | "onBlockReply">;
|
||||
replyResolver?: GetReplyFromConfig;
|
||||
}): Promise<DispatchInboundResult> {
|
||||
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,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
28
src/auto-reply/reply/provider-dispatcher.types.ts
Normal file
28
src/auto-reply/reply/provider-dispatcher.types.ts
Normal file
@@ -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<GetReplyOptions, "onToolResult" | "onBlockReply">;
|
||||
|
||||
export type DispatchReplyWithBufferedBlockDispatcher = (params: {
|
||||
ctx: DispatchReplyContext;
|
||||
cfg: OpenClawConfig;
|
||||
dispatcherOptions: ReplyDispatcherWithTypingOptions;
|
||||
replyOptions?: DispatchReplyOptions;
|
||||
replyResolver?: GetReplyFromConfig;
|
||||
}) => Promise<DispatchFromConfigResult>;
|
||||
|
||||
export type DispatchReplyWithDispatcher = (params: {
|
||||
ctx: DispatchReplyContext;
|
||||
cfg: OpenClawConfig;
|
||||
dispatcherOptions: ReplyDispatcherOptions;
|
||||
replyOptions?: DispatchReplyOptions;
|
||||
replyResolver?: GetReplyFromConfig;
|
||||
}) => Promise<DispatchFromConfigResult>;
|
||||
@@ -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<typeof import("../auto-reply/envelope.js").resolveEnvelopeFormatOptions>;
|
||||
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;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -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<GetReplyOptions, "onToolResult" | "onBlockReply">;
|
||||
|
||||
@@ -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<void>;
|
||||
onRecordError: (err: unknown) => void;
|
||||
onDispatchError: (err: unknown, info: { kind: string }) => void;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user