DingTalk Message Chunker (shared/message-chunker.ts)

openclaw-channel-dingtalk · src/shared/message-chunker.ts · typescript · MIT
chat, tag:dingtalk, tag:text-splitting, tag:unicode, tag:markdown

Splits long outbound DingTalk text/markdown into safe-sized chunks respecting code-point boundaries, code fences, and card block limits to avoid truncation or blank rendering.

// Source: https://github.com/soimy/openclaw-channel-dingtalk | License: MIT | Copyright 2026 YM Shen and contributors
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Shared message chunking policy for all outbound DingTalk text surfaces.
 *
 * DingTalk rejects (or silently fails to render) long payloads differently per
 * surface: session webhook text/markdown messages truncate around ~3800 chars,
 * and AI Card markdown blocks render blank past ~3000 CJK chars (issue #615).
 * All surfaces must therefore split through this module so the sizing rules —
 * code-point counting (never splits surrogate pairs), code-fence awareness and
 * no-newline fallback — stay consistent.
 */

/** Safe max length (code points) for session webhook text/markdown messages. */
export c

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key