From 404446f75845ecccc7f8f55e119b0aef6102f936 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 1 May 2026 11:26:48 +0100 Subject: [PATCH] chore(qqbot): inline legacy text chunk helper --- extensions/qqbot/src/channel.ts | 17 +++++++++++ .../qqbot/src/engine/utils/text-chunk.ts | 28 ------------------- 2 files changed, 17 insertions(+), 28 deletions(-) delete mode 100644 extensions/qqbot/src/engine/utils/text-chunk.ts diff --git a/extensions/qqbot/src/channel.ts b/extensions/qqbot/src/channel.ts index 866b2ab83f0..87a5153b027 100644 --- a/extensions/qqbot/src/channel.ts +++ b/extensions/qqbot/src/channel.ts @@ -23,6 +23,23 @@ import { } from "./engine/messaging/target-parser.js"; import type { ResolvedQQBotAccount } from "./types.js"; +/** Maximum text length for a single QQ Bot message. */ +export const TEXT_CHUNK_LIMIT = 5000; + +/** + * Naive text chunking fallback. + * + * The outbound pipeline normally uses `runtime.channel.text.chunkMarkdownText`; + * this remains exported for callers that need the legacy channel helper. + */ +export function chunkText(text: string, limit: number = TEXT_CHUNK_LIMIT): string[] { + const chunks: string[] = []; + for (let i = 0; i < text.length; i += limit) { + chunks.push(text.slice(i, i + limit)); + } + return chunks.length > 0 ? chunks : [text]; +} + // Shared promise so concurrent multi-account startups serialize the dynamic // import of the gateway module, avoiding an ESM circular-dependency race. let _gatewayModulePromise: Promise | undefined; diff --git a/extensions/qqbot/src/engine/utils/text-chunk.ts b/extensions/qqbot/src/engine/utils/text-chunk.ts deleted file mode 100644 index c13e1a3c5e5..00000000000 --- a/extensions/qqbot/src/engine/utils/text-chunk.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Text chunking constants and fallback. - * - * The actual chunking logic is provided by the framework runtime - * (`runtime.channel.text.chunkMarkdownText`) and injected via the - * outbound dispatch pipeline — NOT via a global singleton. - * - * This module only exports the chunk limit constant and a naive - * fallback splitter for edge cases outside the pipeline. - */ - -/** Maximum text length for a single QQ Bot message. */ -export const TEXT_CHUNK_LIMIT = 5000; - -/** - * Naive text chunking fallback. - * - * Used only by code outside the outbound pipeline that needs a - * simple split. The real markdown-aware chunking is always done - * via `runtime.channel.text.chunkMarkdownText` inside the pipeline. - */ -export function chunkText(text: string, limit: number = TEXT_CHUNK_LIMIT): string[] { - const chunks: string[] = []; - for (let i = 0; i < text.length; i += limit) { - chunks.push(text.slice(i, i + limit)); - } - return chunks.length > 0 ? chunks : [text]; -}