mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-28 21:43:39 +00:00
* feat(telegram): render rich messages through rich html * docs(telegram): teach agents rich formatting * fix(telegram): bound rich draft payloads (#93286) * fix(telegram): narrow rich draft payload type (#93286) * fix(telegram): preserve rich table cell formatting (#93286) * fix(telegram): honor rich table mode config (#93286) * fix(telegram): default rich markdown tables (#93286) * fix(telegram): gate rich table block mode (#93286) * fix(telegram): normalize raw rich html limits (#93286) * fix(telegram): preserve link preview suppression (#93286) * fix(telegram): preserve rich markdown headings (#93286) * fix(telegram): reject unsupported rich media sources (#93286) * fix(telegram): honor link preview off in rich chunks (#93286) * fix(telegram): avoid double escaping markdown media (#93286) * fix(telegram): render markdown media via placeholders (#93286) * fix(telegram): preserve table text in prompt context (#93286)
84 lines
3.5 KiB
TypeScript
84 lines
3.5 KiB
TypeScript
// Text chunking helpers split long outbound text while preserving readable line boundaries.
|
|
import { chunkTextByBreakResolver } from "../shared/text-chunking.js";
|
|
|
|
/**
|
|
* Splits outbound channel text into chunks no longer than the requested limit.
|
|
* Newline boundaries win over spaces; text without usable separators falls back
|
|
* to a hard character split so channel senders always receive bounded strings.
|
|
*/
|
|
export function chunkTextForOutbound(text: string, limit: number): string[] {
|
|
return chunkTextByBreakResolver(text, limit, (window) => {
|
|
const lastNewline = window.lastIndexOf("\n");
|
|
const lastSpace = window.lastIndexOf(" ");
|
|
return lastNewline > 0 ? lastNewline : lastSpace;
|
|
});
|
|
}
|
|
|
|
/** Markdown IR parsing and slicing primitives for plugin-owned renderers. */
|
|
export {
|
|
chunkMarkdownIR,
|
|
markdownToIR,
|
|
markdownToIRWithMeta,
|
|
sliceMarkdownIR,
|
|
type MarkdownIR,
|
|
type MarkdownLinkSpan,
|
|
type MarkdownParseOptions,
|
|
type MarkdownStyle,
|
|
type MarkdownStyleSpan,
|
|
type MarkdownTableCell,
|
|
type MarkdownTableMeta,
|
|
} from "../../packages/markdown-core/src/ir.js";
|
|
/** Render-size-aware Markdown chunking for channel payload limits. */
|
|
export {
|
|
renderMarkdownIRChunksWithinLimit,
|
|
type RenderMarkdownIRChunksWithinLimitOptions,
|
|
} from "../../packages/markdown-core/src/render-aware-chunking.js";
|
|
/** Marker-based Markdown rendering hooks for channel-specific formatting. */
|
|
export {
|
|
renderMarkdownWithMarkers,
|
|
type RenderLink,
|
|
type RenderOptions,
|
|
type RenderStyleMap,
|
|
type RenderStyleMarker,
|
|
} from "../../packages/markdown-core/src/render.js";
|
|
/** Markdown table conversion helper shared by text-only channel renderers. */
|
|
export { convertMarkdownTables } from "../../packages/markdown-core/src/tables.js";
|
|
/** Assistant-visible text sanitizers for removing internal scaffolding before delivery. */
|
|
export {
|
|
sanitizeAssistantVisibleText,
|
|
sanitizeAssistantVisibleTextWithOptions,
|
|
sanitizeAssistantVisibleTextWithProfile,
|
|
stripAssistantInternalScaffolding,
|
|
stripToolCallXmlTags,
|
|
type AssistantVisibleTextSanitizerProfile,
|
|
} from "../shared/text/assistant-visible-text.js";
|
|
/** File-reference detection helpers for avoiding accidental autolinks. */
|
|
export {
|
|
FILE_REF_EXTENSIONS_WITH_TLD,
|
|
isAutoLinkedFileRef,
|
|
} from "../shared/text/auto-linked-file-ref.js";
|
|
/** Code-region helpers for markdown-aware text transformations. */
|
|
export { findCodeRegions, isInsideCode, type CodeRegion } from "../shared/text/code-regions.js";
|
|
/** Reasoning-tag stripping helpers for public channel output. */
|
|
export {
|
|
stripReasoningTagsFromText,
|
|
type ReasoningTagMode,
|
|
type ReasoningTagTrim,
|
|
} from "../shared/text/reasoning-tags.js";
|
|
/** Plain-text markdown stripper for transports without markdown support. */
|
|
export { stripMarkdown } from "../shared/text/strip-markdown.js";
|
|
/** Terminal-safe text sanitizer for CLI-facing plugin output. */
|
|
export { sanitizeTerminalText } from "../../packages/terminal-core/src/safe-text.js";
|
|
/** System-message marker helpers for preserving generated status lines. */
|
|
export { SYSTEM_MARK, hasSystemMark, prefixSystemMessage } from "../infra/system-message.ts";
|
|
/** Inline directive stripping helpers for display and delivery boundaries. */
|
|
export {
|
|
stripInlineDirectiveTagsForDelivery,
|
|
stripInlineDirectiveTagsForDisplay,
|
|
stripInlineDirectiveTagsFromMessageForDisplay,
|
|
type DisplayMessageWithContent,
|
|
type InlineDirectiveParseResult,
|
|
} from "../utils/directive-tags.js";
|
|
/** Generic item chunker for plugin payload planning. */
|
|
export { chunkItems } from "../utils/chunk-items.js";
|