MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / isValidMessage

Function isValidMessage

packages/mcp-server/src/format.ts:87–99  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

85 * Check if message content is meaningful (not noise).
86 */
87export function isValidMessage(content: string): boolean {
88 const trimmed = content.trim()
89 if (!trimmed) return false
90
91 if (trimmed.length <= 2 && !MEANINGFUL_SHORT_ZH.has(trimmed)) return false
92 if (MEANINGLESS_SHORT_EN.has(trimmed.toLowerCase())) return false
93 if (EMOJI_ONLY.test(trimmed)) return false
94 if (PLACEHOLDER_CONTENTS.has(trimmed.toLowerCase())) return false
95 if (SYSTEM_PATTERNS_ZH.some((p) => p.test(trimmed))) return false
96 if (SYSTEM_PATTERNS_EN.some((p) => p.test(trimmed))) return false
97
98 return true
99}
100
101function truncate(text: string, maxLen: number): string {
102 return text.length <= maxLen ? text : text.slice(0, maxLen) + '...'

Callers 1

formatMessagesCompactFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected