@@ -28,6 +28,7 @@ import {
2828} from "openclaw/plugin-sdk/runtime-group-policy" ;
2929import { resolvePinnedMainDmOwnerFromAllowlist } from "openclaw/plugin-sdk/security-runtime" ;
3030import { normalizeOptionalString , uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime" ;
31+ import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime" ;
3132import { resolveFeishuRuntimeAccount } from "./accounts.js" ;
3233import {
3334 checkBotMentioned ,
@@ -336,7 +337,7 @@ function formatMentionNameForAgentContext(name: string): string {
336337 const normalized = stripped . replace ( / \s + / g, " " ) . trim ( ) ;
337338 const bounded =
338339 normalized . length > MAX_MENTION_CONTEXT_NAME_LENGTH
339- ? `${ normalized . slice ( 0 , MAX_MENTION_CONTEXT_NAME_LENGTH - 3 ) } ...`
340+ ? `${ truncateUtf16Safe ( normalized , MAX_MENTION_CONTEXT_NAME_LENGTH - 3 ) } ...`
340341 : normalized ;
341342 return JSON . stringify ( bounded || "unknown" ) ;
342343}
@@ -1000,7 +1001,7 @@ export async function handleFeishuMessage(params: {
10001001 }
10011002 }
10021003
1003- const preview = ctx . content . replace ( / \s + / g, " " ) . slice ( 0 , 160 ) ;
1004+ const preview = truncateUtf16Safe ( ctx . content . replace ( / \s + / g, " " ) , 160 ) ;
10041005 const inboundLabel = isGroup
10051006 ? `Feishu[${ account . accountId } ] message in group ${ ctx . chatId } `
10061007 : `Feishu[${ account . accountId } ] DM from ${ ctx . senderOpenId } ` ;
@@ -1054,7 +1055,7 @@ export async function handleFeishuMessage(params: {
10541055 ) {
10551056 quotedContent = quotedMessageInfo . content ;
10561057 log (
1057- `feishu[${ account . accountId } ]: fetched quoted message: ${ quotedContent ?. slice ( 0 , 100 ) } ` ,
1058+ `feishu[${ account . accountId } ]: fetched quoted message: ${ truncateUtf16Safe ( quotedContent , 100 ) } ` ,
10581059 ) ;
10591060 } else if ( quotedMessageInfo ) {
10601061 log (
0 commit comments