mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:40:44 +00:00
chore(qqbot): inline legacy text chunk helper
This commit is contained in:
@@ -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<typeof import("./bridge/gateway.js")> | undefined;
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
Reference in New Issue
Block a user