mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-28 09:20:40 +00:00
refactor(core): share JSON utf8 byte counting helper
This commit is contained in:
@@ -9,6 +9,7 @@ import { createReplyDispatcher } from "../../auto-reply/reply/reply-dispatcher.j
|
||||
import type { MsgContext } from "../../auto-reply/templating.js";
|
||||
import { createReplyPrefixOptions } from "../../channels/reply-prefix.js";
|
||||
import { resolveSessionFilePath } from "../../config/sessions.js";
|
||||
import { jsonUtf8Bytes } from "../../infra/json-utf8-bytes.js";
|
||||
import { resolveSendPolicy } from "../../sessions/send-policy.js";
|
||||
import {
|
||||
stripInlineDirectiveTagsForDisplay,
|
||||
@@ -198,14 +199,6 @@ function sanitizeChatHistoryMessages(messages: unknown[]): unknown[] {
|
||||
return changed ? next : messages;
|
||||
}
|
||||
|
||||
function jsonUtf8Bytes(value: unknown): number {
|
||||
try {
|
||||
return Buffer.byteLength(JSON.stringify(value), "utf8");
|
||||
} catch {
|
||||
return Buffer.byteLength(String(value), "utf8");
|
||||
}
|
||||
}
|
||||
|
||||
function buildOversizedHistoryPlaceholder(message?: unknown): Record<string, unknown> {
|
||||
const role =
|
||||
message &&
|
||||
|
||||
Reference in New Issue
Block a user