fix: avoid invalid UTF-16 in truncation (#567)
This commit is contained in:
@@ -49,7 +49,7 @@ import {
|
||||
import { registerAgentRunContext } from "../infra/agent-events.js";
|
||||
import { parseTelegramTarget } from "../telegram/targets.js";
|
||||
import { resolveTelegramToken } from "../telegram/token.js";
|
||||
import { normalizeE164 } from "../utils.js";
|
||||
import { normalizeE164, truncateUtf16Safe } from "../utils.js";
|
||||
import type { CronJob } from "./types.js";
|
||||
|
||||
export type RunCronAgentTurnResult = {
|
||||
@@ -68,7 +68,7 @@ function pickSummaryFromOutput(text: string | undefined) {
|
||||
const clean = (text ?? "").trim();
|
||||
if (!clean) return undefined;
|
||||
const limit = 2000;
|
||||
return clean.length > limit ? `${clean.slice(0, limit)}…` : clean;
|
||||
return clean.length > limit ? `${truncateUtf16Safe(clean, limit)}…` : clean;
|
||||
}
|
||||
|
||||
function pickSummaryFromPayloads(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import crypto from "node:crypto";
|
||||
|
||||
import { truncateUtf16Safe } from "../utils.js";
|
||||
import { computeNextRunAtMs } from "./schedule.js";
|
||||
import { loadCronStore, saveCronStore } from "./store.js";
|
||||
import type {
|
||||
@@ -61,7 +62,7 @@ function normalizeOptionalText(raw: unknown) {
|
||||
|
||||
function truncateText(input: string, maxLen: number) {
|
||||
if (input.length <= maxLen) return input;
|
||||
return `${input.slice(0, Math.max(0, maxLen - 1)).trimEnd()}…`;
|
||||
return `${truncateUtf16Safe(input, Math.max(0, maxLen - 1)).trimEnd()}…`;
|
||||
}
|
||||
|
||||
function inferLegacyName(job: {
|
||||
|
||||
Reference in New Issue
Block a user