perf(test): lazy-load discord reply runtime

This commit is contained in:
Vincent Koc
2026-04-02 00:18:45 +09:00
parent 19724340f8
commit b6ba45c4a4

View File

@@ -25,10 +25,8 @@ import {
clearHistoryEntriesIfEnabled,
} from "openclaw/plugin-sdk/reply-history";
import { resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
import { resolveChunkMode } from "openclaw/plugin-sdk/reply-runtime";
import { dispatchInboundMessage } from "openclaw/plugin-sdk/reply-runtime";
import { finalizeInboundContext } from "openclaw/plugin-sdk/reply-runtime";
import { createReplyDispatcherWithTyping } from "openclaw/plugin-sdk/reply-runtime";
import { resolveChunkMode } from "openclaw/plugin-sdk/reply-chunking";
import { finalizeInboundContext } from "openclaw/plugin-sdk/reply-dispatch-runtime";
import type { ReplyPayload } from "openclaw/plugin-sdk/reply-runtime";
import { buildAgentSessionKey } from "openclaw/plugin-sdk/routing";
import { resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
@@ -68,6 +66,12 @@ function sleep(ms: number): Promise<void> {
}
const DISCORD_TYPING_MAX_DURATION_MS = 20 * 60_000;
let replyRuntimePromise: Promise<typeof import("openclaw/plugin-sdk/reply-runtime")> | undefined;
async function loadReplyRuntime() {
replyRuntimePromise ??= import("openclaw/plugin-sdk/reply-runtime");
return await replyRuntimePromise;
}
function isProcessAborted(abortSignal?: AbortSignal): boolean {
return Boolean(abortSignal?.aborted);
@@ -217,6 +221,7 @@ export async function processDiscordMessage(
if (statusReactionsEnabled) {
void statusReactions.setQueued();
}
const { createReplyDispatcherWithTyping, dispatchInboundMessage } = await loadReplyRuntime();
const fromLabel = isDirectMessage
? buildDirectLabel(author)