fix(reply): split dispatcher shared types

This commit is contained in:
Vincent Koc
2026-04-11 16:51:11 +01:00
parent bbc3849e24
commit 796d4dfc49
12 changed files with 29 additions and 20 deletions

View File

@@ -1,4 +1,4 @@
import type { ReplyDispatcher } from "./reply/reply-dispatcher.js";
import type { ReplyDispatcher } from "./reply/reply-dispatcher.types.js";
export async function withReplyDispatcher<T>(params: {
dispatcher: ReplyDispatcher;

View File

@@ -7,10 +7,10 @@ import { finalizeInboundContext } from "./reply/inbound-context.js";
import {
createReplyDispatcher,
createReplyDispatcherWithTyping,
type ReplyDispatcher,
type ReplyDispatcherOptions,
type ReplyDispatcherWithTypingOptions,
} from "./reply/reply-dispatcher.js";
import type { ReplyDispatcher } from "./reply/reply-dispatcher.types.js";
import type { FinalizedMsgContext, MsgContext } from "./templating.js";
import type { GetReplyOptions } from "./types.js";

View File

@@ -15,7 +15,7 @@ import {
resolveAcpStreamingConfig,
} from "./acp-stream-settings.js";
import { createBlockReplyPipeline } from "./block-reply-pipeline.js";
import type { ReplyDispatchKind } from "./reply-dispatcher.js";
import type { ReplyDispatchKind } from "./reply-dispatcher.types.js";
const ACP_BLOCK_REPLY_TIMEOUT_MS = 15_000;
const ACP_LIVE_IDLE_FLUSH_FLOOR_MS = 750;

View File

@@ -11,7 +11,7 @@ import { resolveStatusTtsSnapshot } from "../../tts/status-config.js";
import { resolveConfiguredTtsMode } from "../../tts/tts-config.js";
import type { FinalizedMsgContext } from "../templating.js";
import type { ReplyPayload } from "../types.js";
import type { ReplyDispatcher, ReplyDispatchKind } from "./reply-dispatcher.js";
import type { ReplyDispatchKind, ReplyDispatcher } from "./reply-dispatcher.types.js";
let routeReplyRuntimePromise: Promise<typeof import("./route-reply.runtime.js")> | null = null;
let dispatchAcpTtsRuntimePromise: Promise<typeof import("./dispatch-acp-tts.runtime.js")> | null =

View File

@@ -28,7 +28,7 @@ import {
createAcpDispatchDeliveryCoordinator,
type AcpDispatchDeliveryCoordinator,
} from "./dispatch-acp-delivery.js";
import type { ReplyDispatcher, ReplyDispatchKind } from "./reply-dispatcher.js";
import type { ReplyDispatchKind, ReplyDispatcher } from "./reply-dispatcher.types.js";
let dispatchAcpManagerRuntimePromise: Promise<
typeof import("./dispatch-acp-manager.runtime.js")

View File

@@ -1,7 +1,7 @@
import type { OpenClawConfig } from "../../config/types.openclaw.js";
import type { FinalizedMsgContext } from "../templating.js";
import type { GetReplyOptions } from "../types.js";
import type { ReplyDispatcher, ReplyDispatchKind } from "./reply-dispatcher.js";
import type { ReplyDispatchKind, ReplyDispatcher } from "./reply-dispatcher.types.js";
export type DispatchFromConfigResult = {
queuedFinal: boolean;

View File

@@ -1,4 +1,4 @@
import { sanitizeUserFacingText } from "../../agents/pi-embedded-helpers.js";
import { sanitizeUserFacingText } from "../../agents/pi-embedded-helpers/errors.js";
import { hasReplyPayloadContent } from "../../interactive/payload.js";
import { normalizeOptionalString } from "../../shared/string-coerce.js";
import { stripHeartbeatToken } from "../heartbeat.js";

View File

@@ -5,10 +5,11 @@ import { sleep } from "../../utils.js";
import type { GetReplyOptions, ReplyPayload } from "../types.js";
import { registerDispatcher } from "./dispatcher-registry.js";
import { normalizeReplyPayload, type NormalizeReplySkipReason } from "./normalize-reply.js";
import type { ReplyDispatchKind, ReplyDispatcher } from "./reply-dispatcher.types.js";
import type { ResponsePrefixContext } from "./response-prefix-template.js";
import type { TypingController } from "./typing.js";
export type ReplyDispatchKind = "tool" | "block" | "final";
export type { ReplyDispatchKind, ReplyDispatcher } from "./reply-dispatcher.types.js";
type ReplyDispatchErrorHandler = (err: unknown, info: { kind: ReplyDispatchKind }) => void;
@@ -75,16 +76,6 @@ type ReplyDispatcherWithTypingResult = {
markRunComplete: () => void;
};
export type ReplyDispatcher = {
sendToolResult: (payload: ReplyPayload) => boolean;
sendBlockReply: (payload: ReplyPayload) => boolean;
sendFinalReply: (payload: ReplyPayload) => boolean;
waitForIdle: () => Promise<void>;
getQueuedCounts: () => Record<ReplyDispatchKind, number>;
getFailedCounts: () => Record<ReplyDispatchKind, number>;
markComplete: () => void;
};
type NormalizeReplyPayloadInternalOptions = Pick<
ReplyDispatcherOptions,
| "responsePrefix"

View File

@@ -0,0 +1,13 @@
import type { ReplyPayload } from "../types.js";
export type ReplyDispatchKind = "tool" | "block" | "final";
export type ReplyDispatcher = {
sendToolResult: (payload: ReplyPayload) => boolean;
sendBlockReply: (payload: ReplyPayload) => boolean;
sendFinalReply: (payload: ReplyPayload) => boolean;
waitForIdle: () => Promise<void>;
getQueuedCounts: () => Record<ReplyDispatchKind, number>;
getFailedCounts: () => Record<ReplyDispatchKind, number>;
markComplete: () => void;
};

View File

@@ -3,7 +3,7 @@ import {
dispatchReplyFromConfig,
type DispatchFromConfigResult,
} from "../auto-reply/reply/dispatch-from-config.js";
import type { ReplyDispatcher } from "../auto-reply/reply/reply-dispatcher.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";
import type { OpenClawConfig } from "../config/types.openclaw.js";

View File

@@ -47,6 +47,8 @@ export {
export type {
ReplyDispatchKind,
ReplyDispatcher,
} from "../auto-reply/reply/reply-dispatcher.types.js";
export type {
ReplyDispatcherOptions,
ReplyDispatcherWithTypingOptions,
} from "../auto-reply/reply/reply-dispatcher.js";

View File

@@ -17,7 +17,10 @@ import type { ModelProviderRequestTransportOverrides } from "../agents/provider-
import type { ProviderSystemPromptContribution } from "../agents/system-prompt-contribution.js";
import type { PromptMode } from "../agents/system-prompt.types.js";
import type { AnyAgentTool } from "../agents/tools/common.js";
import type { ReplyDispatchKind, ReplyDispatcher } from "../auto-reply/reply/reply-dispatcher.js";
import type {
ReplyDispatchKind,
ReplyDispatcher,
} from "../auto-reply/reply/reply-dispatcher.types.js";
import type { FinalizedMsgContext } from "../auto-reply/templating.js";
import type { ThinkLevel } from "../auto-reply/thinking.shared.js";
import type { ReplyPayload } from "../auto-reply/types.js";